Folks;
The following gives an answer with the desired width:
,&1 1"0 1]4 $. $. tst
but not the proper length.
Roger Hui wrote:
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
--
------------------------------------------------------------------------
|\/| Randy A MacDonald | APL: If you can say it, it's done.. (ram)
|/\| ramacd <at> nbnet.nb.ca |
|\ | | The only real problem with APL is that
BSc(Math) UNBF'83 | it is "still ahead of its time."
Sapere Aude | - Morten Kromberg
Natural Born APL'er |
-----------------------------------------------------(INTP)----{ gnat }-
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm