Help / Release / J 5.03 / u;.n Improved
< Help
Jump to navigation
Jump to search
>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release
u;.n Improved |
initial writing: 2003-09-09 |
u;.n is now supported by special code for the following cases, for n= 1, 2, _1, or _2 and monad or dyad, unless otherwise indicated. Moreover, if ;@:g is supported by special code, then so is the equivalent [: ; g .
- the dyad ;@:(<;.0) when the right argument is a boolean or literal list
- f/;.n where f is atomic (= < <. + +. +: etc.)
- the result of u on each cut is boxed and atomic (for example if the leftmost verb in u is the monad <)
- ;@:(<@u;.n)
- ;@:(<@(f/\);.n) and ;@:(<@(f/\.);.n) where f is atomic. Such cases compute the partitioned f-scan functions.
The following benchmarks demonstrate the improvements in time and space:
p=: 0=?1e5$10 i1=: ?1e5 $100 i2=: ?1e5 5$100 b1=: ?1e5 $2 b2=: ?1e5 12$2 ts=: 6!:2 , 7!:2@] dtb=: #~ ([: +./\. ' '&~:) NB. delete trailing blanks lf=: 10{a. s=: (?1e6$#t){t=: ((97+i.26){a.),26$' ' b=: ?1e6$2 ts=: 6!:2 , 7!:2@] ts ' <@dtb;.1 x' [ x=: lf (0,?n$#s)}s ts '([: ; <@dtb;.1) x' NB. delete trailing blanks ts 'x#~(x=lf) ([: ; <@(+./\.);.1) '' ''~:x' NB. delete trailing blanks ts 'p <@(+./\.);.1 b' [ p=: (i.#b) e. 0,?n$#b ts 'p ([: ; <@(+./\.);.1) b'
Expression | n | J 5.03 | J 5.02 | Ratio | |||||||||||||||
p + /;.1 i1 | 0.0067520 6.694400e4 | 0.0373595 2.037440e6 | 5.53 | 30.43 | |||||||||||||||
p + /;.1 i2 | 0.0187937 2.635520e5 | 0.0582348 4.567680e6 | 3.10 | 17.33 | |||||||||||||||
p *./;.1 b1 | 0.0037164 1.779200e4 | 0.0343734 1.571008e6 | 9.25 | 88.30 | |||||||||||||||
p *./;.1 b2 | 0.0112738 1.324800e5 | 0.0467945 3.417088e6 | 4.15 | 25.79 | |||||||||||||||
<@dtb;.1 x | |||||||||||||||||||
20000 | 0.2964201 2.764800e6 | 0.4308346 6.992384e6 | 1.45 | 2.53 | |||||||||||||||
40000 | 0.5552815 4.046464e6 | 0.8056859 1.097107e7 | 1.45 | 2.71 | |||||||||||||||
60000 | 0.8143004 5.147328e6 | 1.1502487 1.454963e7 | 1.41 | 2.83 | |||||||||||||||
80000 | 1.0695007 6.490112e6 | 1.5129828 1.858253e7 | 1.41 | 2.86 | |||||||||||||||
100000 | 1.3321813 7.563072e6 | 1.8697742 2.205626e7 | 1.40 | 2.92 | |||||||||||||||
([: ; <@dtb;.1) x | |||||||||||||||||||
20000 | 0.2151028 1.052224e6 | 0.4813159 6.991488e6 | 2.24 | 6.64 | |||||||||||||||
40000 | 0.3706147 1.051200e6 | 0.8320175 1.096083e7 | 2.24 | 10.43 | |||||||||||||||
60000 | 0.5425854 1.050816e6 | 1.1930329 1.457338e7 | 2.20 | 13.87 | |||||||||||||||
80000 | 0.7052606 1.050816e6 | 1.5473053 1.857261e7 | 2.19 | 17.67 | |||||||||||||||
100000 | 0.8756591 1.050816e6 | 1.9243666 2.204339e7 | 2.20 | 20.98 | |||||||||||||||
x#~(x=lf) ([: ; <@(+./\.);.1) ' '~:x | |||||||||||||||||||
20000 | 0.0898821 4.197056e6 | 0.2540219 9.115904e6 | 2.83 | 2.17 | |||||||||||||||
40000 | 0.0861936 4.197056e6 | 0.4006755 1.309920e7 | 4.65 | 3.12 | |||||||||||||||
60000 | 0.0911792 4.197056e6 | 0.5452727 1.671565e7 | 5.98 | 3.98 | |||||||||||||||
80000 | 0.0936711 4.197056e6 | 0.6927660 2.072307e7 | 7.40 | 4.94 | |||||||||||||||
100000 | 0.0931079 4.197056e6 | 0.8457122 2.420698e7 | 9.08 | 5.77 | |||||||||||||||
p <@(+./\.);.1 b | |||||||||||||||||||
20000 | 0.1156180 2.787712e6 | 0.1610699 7.011968e6 | 1.39 | 2.52 | |||||||||||||||
40000 | 0.2040379 4.075328e6 | 0.2891990 1.098374e7 | 1.42 | 2.70 | |||||||||||||||
60000 | 0.2950473 5.207552e6 | 0.4189239 1.461914e7 | 1.42 | 2.81 | |||||||||||||||
80000 | 0.3929801 6.546368e6 | 0.5521369 1.863699e7 | 1.40 | 2.85 | |||||||||||||||
100000 | 0.4859380 7.610432e6 | 0.6947852 2.209325e7 | 1.43 | 2.90 | |||||||||||||||
p ([: ; <@(+./\.);.1) b | |||||||||||||||||||
20000 | 0.0284265 1.050432e6 | 0.2083843 7.016960e6 | 7.33 | 6.68 | |||||||||||||||
40000 | 0.0283919 1.050432e6 | 0.3735461 1.100512e7 | 13.16 | 10.48 | |||||||||||||||
60000 | 0.0304595 1.050432e6 | 0.5332460 1.460691e7 | 17.51 | 13.91 | |||||||||||||||
80000 | 0.0302851 1.050432e6 | 0.6730847 1.864077e7 | 22.22 | 17.75 | |||||||||||||||
100000 | 0.0335300 1.050432e6 | 0.7799402 2.210182e7 | 23.26 | 21.04 |