I have a 3D matrix such as:
array([[[3., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[2., 0., 0.],
[0., 0., 0.]],
[[0., 0., 0.],
[12., 0., 0.],
[0., 0., 0.]]])
I want to slice this in [: , 0, :], [-1,: :].. and all 6 directions in the order with a for loop. So for each dimension, slicing from the first (0) and last (-1).
What is the proper way of applying the for loop?
Lets assume the name of the array is A:
A[0, :, :]
A[:, :, 0]
A[:, 0, :]
A[-1, :, :]
A[:, -1, :]
A[:, :, -1]
I want to have these 6 submatrices (lets say in a list) in one loop.
np.arange(24).reshape(2,3,4)- distinct dimensions, and values.