bug-apl
[Top][All Lists]

## Five-dimensional transpose results in incorrect shape

 From: Elias Mårtenson Subject: Five-dimensional transpose results in incorrect shape Date: Wed, 11 Mar 2020 00:57:09 +0800

At least I believe the result is incorrect.

Let me show my observations. All tests done with ⎕IO←0

I will show 4 invocations of transpose, with the first three being correct but the fourth one returning the wrong result.

First, let's establish the identity operation for a transpose:

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

As we can see, the shape of the result is identical to the input.

Now, let's try reversing the axes:

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

Good, the shape has reversed sizes. That's also expected.

Now, another slightly more complex version:

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

This result is also correct.

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

Regards,
Elias