Ric,
Do you actually find your result faster and leaner? In j902 I find Henry's is
quicker and leaner even in higher dimensions.
1000 timespacex '6 (4 $. $.@:=) i. 3 4'
1.194e_6 4096
1000 timespacex '6 ($@] #: I.@(= ,)) i. 3 4'
8.57e_7 2496
1000 timespacex '6 (4 $. $.@:=) i. 2 3 4'
1.131e_6 4096
1000 timespacex '6 ($@] #: I.@(= ,)) i. 2 3 4'
9.95e_7 3008
1000 timespacex '6 (4 $. $.@:=) i. 6 2 3 4'
1.264e_6 4224
1000 timespacex '6 ($@] #: I.@(= ,)) i. 6 2 3 4'
1.08e_6 3008
1000 timespacex '6 (4 $. $.@:=) i. 5 5 6 2 3 4'
4.345e_6 41408
1000 timespacex '6 ($@] #: I.@(= ,)) i.5 5 6 2 3 4'
2.618e_6 39552
JVERSION
Engine: j902/j64avx2/darwin
Beta-l: commercial/2020-11-05T14:07:25
Library: 9.02.07
Qt IDE: 1.8.7/5.12.7(5.12.7)
Platform: Darwin 64
Installer: J902 install
InstallPath: /users/bobtherriault/j902
Contact: www.jsoftware.com
I know for certain my earlier approach is not in the running! And I do like
your approach in terms of getting the computer to do the work for you!
Cheers, bob
> On Nov 13, 2020, at 15:12, Ric Sherlock <[email protected]> wrote:
>
> I understand the sentiment, but when it's more concise, faster and leaner,
> it is hard to ignore!
>
> On Sat, 14 Nov 2020, 09:37 Henry Rich, <[email protected]> wrote:
>
>> /Et tu, R. E.?/
>>
>> Using $. for this is using a sledgehammer to crack an egg.
>>
>> Henry Rich
>>
>> On 11/13/2020 3:00 PM, R.E. Boss wrote:
>>> $.$.M
>>> 0 0 │ 1
>>> 0 1 │ 2
>>> 0 2 │ 3
>>> 0 3 │ 4
>>> 1 0 │ 5
>>> 1 1 │ 6
>>> 1 2 │ 7
>>> 1 3 │ 8
>>> 2 0 │ 9
>>> 2 1 │ 10
>>> 2 2 │ 11
>>> 2 3 │ 12
>>>
>>>
>>> R.E. Boss
>>>
>>>
>>> -----Original Message-----
>>> From: Programming <[email protected]> On Behalf
>> Of thomas.bulka via Programming
>>> Sent: vrijdag 13 november 2020 18:05
>>> To: [email protected]
>>> Subject: [Jprogramming] Getting indices of matrix elements
>>>
>>> Hi everyone,
>>>
>>> still learning J, I stumbled across a problem which should be easy to
>> solve, but somehow I have not been able to do so, yet. Say, I have defined
>> a matrix M:
>>>
>>> M =: 3 4 $ >: i. 12
>>>
>>> I now want to get the row and column index of 6 in M, which is 1 2. If M
>> was a vector, I could easily get the index of 6 with the help of I.:
>>>
>>> I. 6 = , M
>>>
>>> Applying I. to M in its original shape, however, returns a boolean
>> vector which indicates in which rows 6 has been found (at least that is my
>> interpretation).
>>>
>>> Is it possible to apply I. to higher rank arrays in order to receive the
>> complete indices of the elements I'm looking for? Or should I approach that
>> problem in another way?
>>>
>>> Thank you very much in advance for your help!
>>>
>>> Kind regards,
>>>
>>> Thomas
>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
>> --
>> This email has been checked for viruses by AVG.
>> https://www.avg.com
>>
>> ----------------------------------------------------------------------
>> 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