> > The standard idiom for doing this is
> >
> > array =: (array = 0)} array ,: _
> 
> Thanks Henry, I'd remembered there was something like that 
> and had been searching for it unsuccessfully! Can you point 
> me to a reference to note for the future?

I can't find one, except for the Dictionary and the Special Code page.

> 
> > If array is big, you get a big boost from performing
> > the update in place.  To do that, you have to write
> >
> > zeros =. array = 0
> > inf =. ($array) $ _
> > array =: zeros} array ,: inf
> 
> The performance boost doesn't seem to be that big in this 
> case and comes at the cost of space.

Agreed.  Maybe Roger should think about special-casing the case of

a =: c}a,:b

where b has the shape of a cell of a .

As things stand now you would need to precompute & reuse
'inf' to see a huge benefit.


Henry Rich



> I'm not sure if there isn't a simpler way to compare the 
> performance of these different algorithms?
> 
> M=: ((1024*1024),4)[EMAIL PROTECTED]
> M2=: M
> ts=: 6!:2 , 7!:[EMAIL PROTECTED]
> 
> amZ0=: 3 : 'M=: (M=0)}M,:_'
> 
> amZ1=: 3 : 0
>   zeros=. M = 0
>   inf=. ($M) $ _
>   M=: zeros} M ,: inf
> )
> 
> amZ2=: 3 : 0
>   dat=. ,M
>   dat=. _ (I. dat=0)} dat
>   M=: ($M)$dat
> )
> 
> amZ3=: 3 : 'M=: _&(([: I. 0 = ,@])}) M'
> 
> amZ4=: 3 : 'M=: (+ _*0=]) M'
> 
>    ts 'amZ0'''''
> 0.27791011148 310380800
>    M=: M2
>    ts 'amZ1'''''
> 0.08244288031 444598976
>    M=: M2
>    ts 'amZ2'''''
> 0.11220713806 134219840
>    M=: M2
>    ts 'amZ3'''''
> 0.12162285989 71305856
>    M=: M2
>    ts 'amZ4'''''
> 0.20750486445 134219904
> ----------------------------------------------------------------------
> For information about J forums see 
> http://www.jsoftware.com/forums.htm

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

Reply via email to