Re: options Transpose[] ?

*To*: mathgroup at smc.vnet.net*Subject*: [mg48997] Re: options Transpose[] ?*From*: koopman at sfu.ca (Ray Koopman)*Date*: Mon, 28 Jun 2004 04:13:40 -0400 (EDT)*References*: <cbi6v2$lb6$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Petr Kujan <kujanp at fel.cvut.cz> wrote in message news:<cbi6v2$lb6$1 at smc.vnet.net>... > Hello Mathematica User Group. > > If I have an multidimensional array A: > > In[1] := > A = Array[Random[]&, dims = {3,2,4}] > > Than I expect that dimension of transposed A with options per = {3,1,2} > is equal {4,3,2} === dims[[per]] , but it is not equal! > > Dimensions of transposed A with options per = {3,1,2} is: > {2,4,3}. > > In[2] := > Dimensions[Transpose[A, per = {3, 1, 2}]] > dims[[per]] > > It' s correct or it's bug? > How can I get the same dimensions? > [...] Mathematica treats per as a "TO" list, in which the i-th value specifies which new dimension the old i-th dimension goes TO. It interprets {3,1,2} as meaning that old dimension 1 --> new dimension 3, old dimension 2 --> new dimension 1, old dimension 3 --> new dimension 2. You're treating per as a "FROM" list, in which the i-th value specifies which old dimension the new i-th dimension comes FROM: you want {3,1,2} to mean that new dimension 1 <-- old dimension 3, new dimension 2 <-- old dimension 1, new dimension 3 <-- old dimension 2. In this case, per = {2,3,1} will get you what you want. More generally, convert[per_] := Last@Transpose@Sort@Transpose@{per,Range@Length@per} will convert one form of permutation list to the other.

**Follow-Ups**:**Re: Re: options Transpose[] ?***From:*DrBob <drbob@bigfoot.com>