Help / Release / J 5.03 / u/. Improved

From J Wiki
Jump to navigation Jump to search


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



u/. Improved

initial writing: 2003-09-03
last updated: 2007-07-31


The key adverb u/. has been made more efficient for the following cases:

  • The dyad x #/. y
  • The cases x </.i.#x and (</. i.@#) x (group the indices of identical items of x)
  • The dyad x f//. y where y is a vector, and f and y are one of the following combinations:
        verb f      y type
      = <. >. + +. * *. ~:  Boolean
      <. >. +   integer, floating-point
      n b. for n= 17 22 23 25  integer

    (In J 6.02 the restriction that y be a vector is removed.)

The following benchmarks demonstrate the improvements in time and space.

x1=: ?1e6$10
x2=: ?1e6$100
x3=: ?1e6$1000
x4=: ?1e6$10000

c=: (?1e6$10000){a.{~?1e4 6$#a.
b=: ?1e6$2
i=: ?1e6$1000
d=: 0.01*?1e6$1e6

ts=: 6!:2 , 7!:2@]
ts 'Expression'
Expression    J 5.03    J 5.02    Ratio
x1 #/. i  0.054980 1088  0.142855 1.258374e7  2.60 11565.94
x2 #/. i  0.061149 1856  0.148341 1.258374e7  2.43 6780.03
x3 #/. i  0.057310 9024  0.151128 1.258374e7  2.64 1394.48
x4 #/. i  0.058312 131904  0.163465 1.258374e7  2.80 95.40
c  #/. i  0.46666212583808  0.523424 1.258381e7  1.12 1.00
 
x1 </.i.#x1  0.146615  9.438592e6 0.5413703.565293e7 3.693.78
x2 </.i.#x2  0.1618431.075046e7 0.5710603.696403e7 3.533.44
x3 </.i.#x3  0.1736699.655296e6 0.6038633.588218e7 3.483.72
x4 </.i.#x4  0.2464109.731584e6 0.7092073.582688e7 2.883.68
c  </.i.#c  0.7385281.799411e7 1.0947353.580832e7 1.481.99
 
(</. i.@#) x1  0.1102505.244480e6 0.5432623.565312e7 4.936.80
(</. i.@#) x2  0.1178836.556352e6 0.5714063.696422e7 4.855.64
(</. i.@#) x3  0.1301145.461184e6 0.6055033.588237e7 4.656.57
(</. i.@#) x4  0.2039805.537472e6 0.7167863.582707e7 3.516.47
(</. i.@#) c  0.6510081.380013e7 1.1018983.580864e7 1.692.59
 
x1 +//. i  0.089229 1472  0.489221  3.145965e7  5.48 21372.04
x2 +//. i  0.091571 2240  0.545150 3.277690e7  5.95 14632.54
x3 +//. i  0.089238 9408  0.580384 3.169478e7  6.50 3368.92
x4 +//. i  0.093303 132288  0.696549 3.237165e7  7.47 244.71
 
x1 +//. b  0.061756 1472  0.422279 2.438176e7  6.84 16563.70
x2 +//. b  0.061645 2240  0.494004 2.471597e7  8.01 11033.91
x3 +//. b  0.061742 9408  0.510600 2.489747e7  8.27 2646.41
x4 +//. b  0.065804 132288  0.639285 2.635066e7  9.71 199.19
 
x1 +.//. b  0.057070 1344  0.422874 2.438170e7  7.41 18141.14
x2 +.//. b  0.057171 1728  0.493326 2.471571e7  8.63 14303.07
x3 +.//. b  0.057439 5312  0.516077 2.489747e7  8.98 4687.02
x4 +.//. b  0.061470 33984  0.650361 2.630214e7  10.58 773.96
 
x1 23 b.//. i  0.088951 1856  0.514752 3.145997e7  5.79 16950.41
x2 23 b.//. i  0.088652 2816  0.541060 3.277722e7  6.10 11639.64
x3 23 b.//. i  0.091216 11776  0.580654 3.173197e7  6.37 2694.63
x4 23 b.//. i  0.092286 148992  0.696234 3.237453e7  7.54 217.29
 
x4 +//. d  0.099751 279744  0.740266 4.168851e7  7.42 149.02
c  +//. d  0.536441 12584192  1.096851 4.167213e7  2.04 3.31



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