Given a shape (n,m,k) and a nonzero vector (u,v,w) with entries in {-1,0,1}, I would like to create a numpy array of shape (n,m,k). The entries of the array should start at 1 and increase in the direction of the vector.
Although I am specifically asking for 3d arrays, let me illustrate with 2d examples:
(n,m) = (3,4) and (u,v) = (-1,0) gives:
4 3 2 1
4 3 2 1
4 3 2 1
(n,m) = (4,3) and (u,v) = (1,-1) gives:
1 2 3
2 3 4
3 4 5
4 5 6
I can create them using nested for loops, but I am wondering if there is a faster solution since I will be working with larger arrays.
(u,v) = (1,1)? and the first on(u,v) = (0,-1)?