Page 1 of 1

Reduction and the rank operator

Posted: Wed Sep 16, 2015 1:12 pm
by marc
Would anyone be able to clarify the interaction between the rank and reduction operators? For example, given the following session:

      +⌿[1]a←2 3 4⍴⍳24
12 15 18 21
48 51 54 57
+/[1]a
12 15 18 21
48 51 54 57
(+⌿⍤2)a
12 15 18 21
48 51 54 57
(+/⍤2)a
6 22 38
54 70 86


it's unclear to me why reduce and reduce first behave differently. Shouldn't the rank operator determine the domain of reduction (analgous to the way in which the axis operator collapses the distinction in the first two expressions)?

Re: Reduction and the rank operator

Posted: Wed Sep 16, 2015 4:10 pm
by Phil Last
Note origin zero and the origin independent nature of the words "first", "second" and "last".

You probably know that the first two are the same because the axis spec overrides the difference between / and ⌿ and reduces (removes) the second ([1]) dimension.

The next is the same because you are removing the first dimension of each three-by-four two-cell which again is the second ([1]) dimension.

The last is different because you are removing the last dimension of the two-cells which is the last ([2]) dimension.

Roger will correct me if I'm wrong but I believe that there is never any purpose to using / and ⍤ together.

Re: Reduction and the rank operator

Posted: Wed Sep 16, 2015 4:47 pm
by marc
Thanks Phil, that makes sense.