Good one.
----- Original Message ----- From: Don Guinn <[EMAIL PROTECTED]> Date: Thursday, June 12, 2008 4:42 Subject: Re: [Jprogramming] find row and column indices To: Programming forum <[email protected]> > How about? > 4$.$.tst > 0 3 > 2 0 > 3 3 > 5 0 > > On Wed, Jun 11, 2008 at 6:34 PM, Sherlock, Ric > <[EMAIL PROTECTED]>wrote: > > > Thanks Roger & Henry, > > They are much simpler than the other way I just realised I had > already> created in the other thread. > > > > ind0=: (1 , {:@$) *"1 [: (<. ,. 1&|) {:@$ %~ [: I. , > NB. RS > > ind1=: [:;(i.@:# ,.&.> <@I.) NB. RS > > ind2=: $ #: I.@, NB. RH & HR > > ind3=: , # (#: i.@(*/))@$ NB. HR > > > > Interestingly ind0 is actually very competitive with ind2, but > would need > > more work to sort out tolerance (and is specific to matrices). > > tmp=: 0.0000001>1e6 [EMAIL PROTECTED] > > +/+/tmp > > 9 > > ts=: 6!:2 , 7!:[EMAIL PROTECTED] > > > > ts 'ind0 tmp' > > 0.264977043172 134218688 > > ts 'ind1 tmp' > > 3.26141171573 221066560 > > ts 'ind2 tmp' > > 0.2667722434 134218688 > > ts 'ind3 tmp' > > |out of memory: ind3 > > | ind3 tmp > > > > ---Roger Hui wrote: > > > ($tst) #: I. , tst > > > > > > Works for any rank array, not just matrices. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
