[Jprogramming] |.!.f y Shift Right 1
P Padilcdx
ppadilcdx at gmail.com
Tue May 10 23:30:33 UTC 2022
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 <rauldmiller at 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 <ppadilcdx at 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
More information about the Programming
mailing list