Help / Release / J 6.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: 2006-03-28
last updated: 2006-03-31


The dyad x +/ .* y has been made more efficient in the following circumstances:

  • x is Boolean, or
  • y is Boolean, or
  • *./1=}.$y , in particular if y is a vector

(There is no change if both x and y are Boolean.) The amount of improvement depends on the size of the arguments and on the number of 1s in a Boolean argument. The following benchmarks demonstrate the improvement:

ts=: 6!:2 , 7!:2@]  NB. time and space
ts 'x +/ .* y'
      x          y    J 6.01    J 5.04    Ratio
2e4 ?@$ 2  2e4 100 ?@$ 0  0.00407861  2112 0.00656611  264384 1.61 125.18
5 2e4 ?@$ 2  2e4 100 ?@$ 0  0.02057971  5184 0.03784747  1053888 1.84 203.30
0=2e4 ?@$ 10  2e4 100 ?@$ 0  0.00102496  2112 0.00197282  264384 1.92 125.18
0=5 2e4 ?@$ 10  2e4 100 ?@$ 0  0.00518482  5184 0.01039583  1053888 2.01 203.30
 
100 2e4 ?@$ 0  2e4 ?@$ 2  0.01304037  2112 0.04706877  264384 3.61 125.18
100 2e4 ?@$ 0  2e4 5?@$ 2  0.08213707  5184 0.15116245  1053888 1.84 203.30
100 2e4 ?@$ 0  0=2e4 ?@$ 10  0.00993831  2112 0.03910959  264384 3.94 125.18
100 2e4 ?@$ 0  0=2e4 5?@$ 10  0.04794872  5184 0.09891527  1053888 2.06 203.30
 
100 2e4 ?@$ 0  2e4 ?@$ 0  0.00667827  2112 0.03896374  2240 5.83  1.06
j./2 100 2e4 ?@$ 0 j./2 2e4 ?@$ 0 0.02276409  3136 0.04351965  3264 1.91  1.04
 
2e5 ?@$ 0  2e5 ?@$ 0  0.00138537  1152  0.00445404  1280 3.22  1.11
2e6 ?@$ 0  2e6 ?@$ 0  0.01210311  1152  0.04429559  1280 3.66  1.11
j./2 2e5 ?@$ 0  j./2 2e5 ?@$ 0 0.00293892  1152  0.00473435  1280 1.61  1.11
j./2 2e6 ?@$ 0  j./2 2e6 ?@$ 0 0.02595096  1152  0.04706550  1280 1.81  1.11



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