A minor improvement to your fast version is to work on both sides with the transposed data (which as you noted is faster, as more data in a row is usually better than a lot of short rows). -/"1&|: will create two big tables for 2d data quite efficient. (If you can store the data with shape 2 100 instead of 100 2 you could even skip the negligible |:)
slow=:+/@:*:@:-"1/ ed=: 4 : 0 row=. 4 : '+/ *: (x - (|: y))' > (row & y) each < "1 x ) ed2=: [:+/ [:*: -/"1&|: foo=:? 100 2 $ 0 bar=:? 100 2 $ 0 1000&(6!:2)&> 'foo slow bar';'foo ed bar';'foo ed2 bar' NB. 0.00536232 0.000197306 8.22493e_5 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
