You win,  Louis! Yes, it looks as if outer-product methods suffer,
naturally enough,  with larger problem size.  Presumably they're
~ O(n^2) in time and space.

NB. in J806 with avx,  fairly pedestrian Lenovo
   ts'new ^:5000 #~200'   NB. the one I posted eariler

0.758277 20992

ts'run ^:5000 #~200'  NB. Louis' tacit

0.205593 19328

   ts'RUN ^:5000 #~200'   NB. Louis' explicit

0.195446 20736


I'd tried a keyed sum (+//.) together with indexed assignment,  but it
seemed too slow,  so I gave up.

The nice thing with my,  slower,  method is that the assignment of the
donations to their "correct", albeit random donees, is determined without
recourse to newvalue u } x ,  but at the expense of the length of the key
and the summand being twice as much as your approach demands.

Why is the explicit form faster than the tacit?

Thanks,

Mike


On 20/07/2017 04:56, Louis de Forcrand wrote:
NB. tacit
run=: upd rec
upd=: [ ((({~ 0{::]) + 1{::])`(0{::])`[} - 2{::]) ~.@] ; ] (+//. ; ]) 1 <: [

NB. explicit
RUN=: UPD rec
UPD=: 4 : 0
  b -~ x u}~ (x {~ u=. ~.y) + y +//. b=. x >: 1
)
rec=: ((] + ] >: i.@[) (?@$ <:))@#


Slower on short vectors, faster on larger ones (j805):

    1e2 ts 'tick^:1e4#~20'
0.0408952 3840
    1e2 ts 'run^:1e4#~20'
0.0802917 4864
    1e2 ts 'RUN^:1e4#~20'
0.0636084 7040
10 ts 'tick^:1e4#~100'
0.243663 23552
    10 ts 'run^:1e4#~100'
0.12502 11904
    10 ts 'RUN^:1e4#~100'
0.104644 14848

Probably because of =/.

Louis



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to