transpose =: |:

does what you describe.

Henry Rich

On 1/25/2022 2:46 PM, Pawel Jakubas wrote:
Dear J enthusiasts,

I am wondering what is an elegant way to realize transpose for arrays of
any dimension.
I imagine the transpose would take permutation as x and an array as y:
So for tensor we would have a permutation of (0,1,2) so 6 possibilities of
the transpose.

    ]t=:i. 3 2 2
  0  1
  2  3

  4  5
  6  7

  8  9
10 11

     (0 1 2) transpose t
  0  1
  2  3

  4  5
  6  7

  8  9
10 11

     NB. This will transform (ijk) -> (jki)
     (1 2 0) transpose t
0 4 8
1 5 9

2 6 10
3 7 11

Thanks in advance and cheers
Pawel
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


--
This email has been checked for viruses by AVG.
https://www.avg.com

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

Reply via email to