David Ward Lambert wrote:
> 
> Is there a shorter sentence?    [: |: [: (i. >./)"1 |:
> 
A bit shorter than Brian's is

   f=:(i. >./)"1&.|:

and indeed about the same speed.


> 
> I'm thinking this could work:  i."SOME RANK >./  
> 
>    ]a=: (?.@$ */)2 3 6  NB. data, rank 3
> 18 20 28 30 29 28
> 22 28  8  7 21 32
> 31 17 25 32 33 28
> 
> 13 17 29 15  1 25
> 18 28 33 26 22  9
> 17  6 34 15 23 35
>    
>    >./a  NB. want the index of a plane having these maximums
> 18 20 29 30 29 28
> 22 28 33 26 22 32
> 31 17 34 32 33 35
> 
>    NB. this works but involves two transposes
>    |: (i. >./)"1 |: a
> 0 0 1 0 0 0
> 0 0 1 1 1 0
> 0 0 1 0 0 1
> 
>    NB. this version is ridiculous
>    <./ (<:@+ >:@# * 0 = ]) (>:@i.@# * (="2 >./)) a
> 0 0 1 0 0 0
> 0 0 1 1 1 0
> 0 0 1 0 0 1
> 

   g=:[: <: [: +/ >:@i.@# * (="2 >./)

is about 1.7 to 3+ times faster.

-- 
View this message in context: 
http://old.nabble.com/index-of-max%2C-high-rank-array-tp32345994s24193p32346887.html
Sent from the J Programming mailing list archive at Nabble.com.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to