Help / Release / J 7.01 / +/ .* Improved

From J Wiki
Jump to navigation Jump to search


>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release



+/ .* Improved

initial writing: 2009-05-01
last updated: 2009-06-07


x +/ .*y is now more efficient on vector and sparse matrix arguments. The following benchmarks illustrate the improvements in time and space.


sa=: 4 : 0  NB. random sparse array with density x and shape y
 m=. >.x**/y
 1$.y;(i.#y);0;((m,#y)?@$y);65536%~_5e8+m ?@$ 1e9
)

ts=: 6!:2 , 7!:2@]  NB. time and space

x=. d sa 2$n
y=. d sa 2$n
ts 'x +/ .* y'
d  n      J 7.01    J 6.02    Ratio
0.01  200 0.000479 2.60480e4 0.012485 5.57312e5 26.06 21.40
0.01  400 0.003083 2.09344e5 0.092145 3.89229e6 29.89 18.59
0.01  800 0.008078 1.59162e6 0.628309 3.01444e7 77.78 18.94
0.01 1600  0.053682 1.26232e7 4.999638 2.36795e8 93.13 18.76
 
0.1   200 0.008470 1.58342e6 0.118047 6.44698e6 13.94  4.07
0.1   400 0.042008 6.30714e6 0.853741 3.86877e7 20.32  6.13
0.1   800 0.084491 2.51917e7 7.353612 2.59295e8 87.03 10.29
0.1  1600  0.499803 1.00714e8 out of memory  -   -




>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release