bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Five-dimensional transpose results in incorrect shape


From: Dr . Jürgen Sauermann
Subject: Re: Five-dimensional transpose results in incorrect shape
Date: Tue, 10 Mar 2020 20:03:32 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Hi,

the IBM APL2 language reference says (page 251):

if Z←L⍉R then:
(⍴Z) ←→ (⍴R)[⍋L]

In our case we have (GNU APL):

      ⎕IO←0
      R←3 4 5 6 7 ⍴ ⍳100
      L←2 4 1 0 3
      Z←L⍉R
      ⍴Z
6 5 3 7 4
      (⍴R)[⍋L]
6 5 3 7 4

Dyalog seems to give the same ⍴Z (haven't compared the ravel of Z though :-)).

Best Regards,
Jürgen



On 3/10/20 7:36 PM, Kacper Gutowski wrote:
On Wed, Mar 11, 2020 at 12:57:09AM +0800, Elias Mårtenson wrote:
Now, for the problematic version:

*      ⍴ 2 4 1 0 3 ⍉ 3 4 5 6 7 ⍴ ⍳100*
┏→━━━━━━━━┓
┃6 5 3 7 4┃
┗━━━━━━━━━┛

As you can see, the numbers are all over the place. For some reason, it seems to have interpreted the left arguments to transpose as if they were:
3 2 0 4 1

They aren't just “all over the place,” if you consider it as a permutation on shape list, it's an inverse of a permutation you expected (previous three cases happened to be self-inverses!).
You expected that Z≡⍴A⍉B⍴⍳100 iff Z≡B[A] but it's actually Z[A]≡B.

      (6 5 3 7 4)[2 4 1 0 3]
3 4 5 6 7

If I read the ISO right, it seems to be correct: values in left argument correspond to axes of result and positions to axes of right argument.

-k






reply via email to

[Prev in Thread] Current Thread [Next in Thread]