In accordance with leading-axis theory, an array of shape 4 4 is best seen as
an array of 4 major cells, each of which happens to itself be another array of
4 atoms. Structural operations like shifts work primarily on the leading
axis, on major cells. Another, perhaps clearer way of seeing the distinction
is to use rank:
]a=. =/~i.4
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
_1 |.!._1 "1 a
_1 1 0 0
_1 0 1 0
_1 0 0 1
_1 0 0 0
This says: shift at rank 1; that is, shift _each_ of the rows. The effect may
also be clarified by using a higher-dimensional array:
]a=. i.3 3 3
0 1 2
3 4 5
6 7 8
9 10 11
12 13 14
15 16 17
18 19 20
21 22 23
24 25 26
_1 |.!._1 "3 a
_1 _1 _1
_1 _1 _1
_1 _1 _1
0 1 2
3 4 5
6 7 8
9 10 11
12 13 14
15 16 17
_1 |.!._1 "2 a
_1 _1 _1
0 1 2
3 4 5
_1 _1 _1
9 10 11
12 13 14
_1 _1 _1
18 19 20
21 22 23
_1 |.!._1 "1 a
_1 0 1
_1 3 4
_1 6 7
_1 9 10
_1 12 13
_1 15 16
_1 18 19
_1 21 22
_1 24 25
If |. defaulted to working at rank 1, it would be very difficult to get it to
work along other axes. The current scheme is flexible and easy to adapt.
-E
On Tue, 10 May 2022, P Padilcdx wrote:
Hopefully this works:
https://code.jsoftware.com/wiki/Vocabulary/bardot#dyadicfit
I figured it out but for someone "more newbie” than me it might be frustrating.
Note that the _1 indicating is a right shift seems, at least to me, counter to
the x axis orientation on a right-handed coordinate system representation, but
is not a real problem. The main issue I had is that I took the result of |.!.f
to be the same for any data rank, i.e. |.!.f meant a right shift, thus I was
surprised by (as noted below):
|.!._1 a
_1 _1 _1 _1
1 0 0 0
0 1 0 0
0 0 1 0
Just another one of those little J quirks that tend to throw me off. Thanks.
On May 10, 2022, at 4:11 PM, Raul Miller <rauldmil...@gmail.com> wrote:
Which page was it that you found confusing?
(I think that the ordering is consistent with the left-to-right
top-to-bottom ordering of english text, but I don't know what you were
looking at.)
--
Raul
On Tue, May 10, 2022 at 4:44 PM P Padilcdx <ppadil...@gmail.com> wrote:
Something confused me on the subject page. The shift right is only for a vector
and behaves differently for a matrix.
|.!.f says it will shift right 1, but when I tried it on a matrix, it shifts
down.
]a=:4 4 $ 1 0 0 0 0
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
|.!._1 a
_1 _1 _1 _1
1 0 0 0
0 1 0 0
0 0 1 0
same as:
_1 |.!._1 a
_1 _1 _1 _1
1 0 0 0
0 1 0 0
0 0 1 0
For it to shift right it needs to identify the second axis:
0 _1|.!._1 a
_1 1 0 0
_1 0 1 0
_1 0 0 1
_1 0 0 0
Anyway just thought to mention it since, at least for newbies, they might find
it confusing.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm