Why does decode of a matrix work by column and not row
4 posts
• Page 1 of 1
Why does decode of a matrix work by column and not row
I have matrix ← 4 3 ⍴ 0 0 0 1 1 0 0 1 1 1 1 1
I wish to convert each row from binary to decimal with the ⊥ primitive. The result is
I thought/expected to get 0 6 3 7. I had to transpose the matrix to get what I thought.
Yet if I sum reduce the matrix, it operates by rows
So why does the ⊥ seem to function on rank 2, while the / functions on rank 1? There is a separate ⌿ function to operate on rank 2.
This seems inconsistent between the two primitives with one operating column-wise and the other row-wise.
- Code: Select all
0 0 0
1 1 0
0 1 1
1 1 1
I wish to convert each row from binary to decimal with the ⊥ primitive. The result is
- Code: Select all
2⊥ matrix
5 7 3
I thought/expected to get 0 6 3 7. I had to transpose the matrix to get what I thought.
- Code: Select all
2⊥⍉matrix
0 6 3 7
Yet if I sum reduce the matrix, it operates by rows
- Code: Select all
+/matrix
0 2 2 3
So why does the ⊥ seem to function on rank 2, while the / functions on rank 1? There is a separate ⌿ function to operate on rank 2.
- Code: Select all
+⌿matrix
2 3 2
This seems inconsistent between the two primitives with one operating column-wise and the other row-wise.
+←--------------------------------------------------------------→
+ Jay Moskowitz
+←--------------------------------------------------------------→
+ http://www.linkedin.com/in/jay-moskowitz-5745b83
+
+ Jay Moskowitz
+←--------------------------------------------------------------→
+ http://www.linkedin.com/in/jay-moskowitz-5745b83
+
-
jmosk - Posts: 69
- Joined: Thu Jul 18, 2013 5:15 am
Re: Why does decode of a matrix work by column and not row
In fact decode works not on rank 2 but on the first dimension. The fact that reduction works on the last dimension is a mistake or oversight made in the earliest impementations and only corrected by Ken and Roger when they implemented J.
So the why is history.
So the why is history.
-
Phil Last - Posts: 628
- Joined: Thu Jun 18, 2009 6:29 pm
- Location: Wessex
Re: Why does decode of a matrix work by column and not row
Hello,
Decode syntax is derived from internal product syntax which operates on last dimension of left argument and first dimension of right argument.
Regards.
--
Yves-Antoine Emmanuelli
Decode syntax is derived from internal product syntax which operates on last dimension of left argument and first dimension of right argument.
Regards.
--
Yves-Antoine Emmanuelli
--
Yves-Antoine Emmanuelli
Yves-Antoine Emmanuelli
-
yaemmanuelli - Posts: 16
- Joined: Sat Aug 01, 2020 6:29 pm
- Location: Recloses, France
Re: Why does decode of a matrix work by column and not row
To summarise previous posts:
- Regard ⌿ as the primary form and works along the leading axis, and / is convenient name for ⌿⍤1 which works along the trailing axis
- ⊥ is a convenient wrapper on +.× namely {⍵+.×⍨⌽×\1,⍺⍴⍨¯1+≢⍵} making it work along the leading axis
- As with ⌿ you can make ⊥ work along the trailing axis with ⍤1:
- Code: Select all
2(⊥⍤1)matrix
0 6 3 7
-
Adam|Dyalog - Posts: 143
- Joined: Thu Jun 25, 2015 1:13 pm
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: Google [Bot] and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group