Assuming a as an input array to add values ββto, and val scalar value to be added, you can use an approach that works for any multi-dimensional array a using broadcasting and reshaping . Here's the implementation -
shp = a.shape
Run Example -
In [437]: a Out[437]: array([[[8, 1], [0, 5]], [[3, 2], [5, 1]]]) In [438]: val Out[438]: 20 In [439]: out Out[439]: array([[[[ 28., 1.], [ 0., 5.]], [[ 3., 2.], [ 5., 1.]]], [[[ 8., 21.], [ 0., 5.]], [[ 3., 2.], [ 5., 1.]]], [[[ 8., 1.], [ 20., 5.]], [[ 3., 2.], [ 5., 1.]]], [[[ 8., 1.], [ 0., 25.]], [[ 3., 2.], [ 5., 1.]]], [[[ 8., 1.], [ 0., 5.]], [[ 23., 2.], [ 5., 1.]]], ....
If you want to create separate arrays from out , you can use an additional step: np.array_split(out,a.size) . But for efficiency, I would recommend using indexing to access all such submatrices as out[0] (for the first submatrix), out[1] (for the second submatrix), etc.