I'd like to rotate the rows of a matrix, X, independently. For instance, I
have an arbitrary matrix

 

 1    2    3    4

 5    6    7    8

 9   10   11   12

13   14   15   16

 

Which I'd like to become

 

 1    2    3     4

 8    5    6     7

11   12    9   10

14   15   16   13  

 

I seem to recall that this could be done relatively easily in APL but can't
find the equivalent primitive command in J. ie. 0 1 2 3 verb X which shifts
rows of X  0, 1, 2 and 3 places. The rotate verb, |. , appears to only allow
shifts by axis. I've looked through the forum archive and couldn't find what
I wanted either. 

 

Have I missed something? Can this be done as inputs to a primitive verb in
J?

 

Bob

 

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to