Here is small tweak that seems to make a big difference to both the memory 
consumed and performance:

From this:

ed=: 4 : 0

row=. 4 : '+/ *: (x - (|: y))'

> (row & y) each < "1 x

)

to this:

ed=: 4 : 0 NB. Euclidean distance

row=. +/ @: *: @: (- & (|: y))

> row each < "1 x

)


The row function is here tacified so that I could implicitly use the data 
passed in the variable y without having to pass it into each call.

Doing this seems to use about 1/4 less memory, reduces compute time by almost a 
half.

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

Reply via email to