(i,j) is the catalog (carteisan product), eg
   [ix=. {;~i.3
+---+---+---+
|0 0|0 1|0 2|
+---+---+---+
|1 0|1 1|1 2|
+---+---+---+
|2 0|2 1|2 2|
+---+---+---+

the linear index of non-zero of arr is
   I.,arr
0 4 8

finally, the (i,j) index you wanted are
   0 4 8{,ix
+---+---+---+
|0 0|1 1|2 2|
+---+---+---+


Сб, 31 май 2014, Jon Hough написал(а):
> Probably a very simple question. For a single dimension array I can do 
> I.  1 0 1 1 1 0 0 0 1 0 1
> 0 2 3 4 8 10
> to  get the nonzero indices.
> But I am not sure how to do this for a larger dimension. i.e. get the (i,j) 
> or (i,j,k) index of nonzero elements.
> e.g. for this matrix:
>  arr =. 3 3 $ 1 0 0 0 1 0 0 0 1
> I. doesn't work because it only gives me the ith value of the position of the 
> nonzero elements.
> Any help appreciated.
> Regards.                                        
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to