Re: Re: options Transpose[] ?

• To: mathgroup at smc.vnet.net
• Subject: [mg49035] Re: [mg48997] Re: options Transpose[] ?
• From: DrBob <drbob at bigfoot.com>
• Date: Tue, 29 Jun 2004 04:50:14 -0400 (EDT)
• References: <cbi6v2\$lb6\$1@smc.vnet.net> <200406280813.EAA04245@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```There's a simpler substitute for "convert", namely Ordering.

convert[per_]:=Last@Transpose@Sort@Transpose@{per,Range@Length@per}
n=5;
Permutations@Range@n;
And@@(Ordering[#]\[Equal]convert[#]&/@%)

True

Bobby

On Mon, 28 Jun 2004 04:13:40 -0400 (EDT), Ray Koopman <koopman at sfu.ca> wrote:

> 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.
>
>

--
DrBob at bigfoot.com
www.eclecticdreams.net

```

• Prev by Date: Re: Union - simple question
• Next by Date: Re: PlotLabel with assigned variables *and* on several lines
• Previous by thread: Re: options Transpose[] ?
• Next by thread: Re: options Transpose[] ?