[Jprogramming] Getting indices of matrix elements
thomas.bulka via Programming
programming at jsoftware.com
Fri Nov 13 17:05:09 UTC 2020
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
More information about the Programming
mailing list