Help / Release / J 5.04 / m&i. Improved
< Help
Jump to navigation
Jump to search
>> << Pri JfC LJ Phr Dic Voc !: Rel NuVoc wd Help Release
m&i. Improved |
initial writing: 2004-04-16 |
Certain verbs in the “index of” family with a fixed noun argument m are now supported by special code. That is,
m&i. m&(i.!.0) m&i: m&(i:!.0) -.&m -.!.0&m e.&m e.!.0&m (e.i.0:)&m + /@e.&m (e.i.1:)&m +./@e.&m (e.i:0:)&m *./@e.&m (e.i:1:)&m I.@e.&m
are now supported by special code, so that for most m and y the phrase m&i. y takes time proportional to the size of y . (“Most” means amenable to hashing or some other fast pre-processing technique.) There is no change in performance with just one application; there can be a substantial improvement in performance with repeated applications. The following benchmarks demonstrate the improvement:
x9=: 1e6 ?@$ 2e9 y9=: 1e5 ?@$ 2e9 x6=: 1e6 ?@$ 2e6 y6=: 1e5 ?@$ 2e6 c =: a {~ 1e6 4 ?@$ #a=: ' 0123456789',(97+i.26){a. d =: a {~ 1e5 4 ?@$ #a f9=: x9&i. f6=: x6&i. fc=: c&i. g9=: +/@e.&x9 g6=: +/@e.&x6 ts=: 6!:2 , 7!:2@] NB. time and space ts 'Expression'
Expression | J 5.04 | J 5.03 | Ratio | |||||||||
x9&i. y9 | 0.1481414 | 8913856 | 0.1503398 | 8913728 | 1.01 | 1.00 | ||||||
f9=:x9&i. | 0.1315829 | 8389568 | 0.0000033 | 832 | 0.00 | 0.00 | ||||||
f9 y9 | 0.0166099 | 525120 | 0.1503235 | 8913728 | 9.05 | 16.97 | ||||||
f6 y6 | 0.0033488 | 525120 | 0.0685174 | 8913728 | 20.46 | 16.97 | ||||||
fc d | 0.0155472 | 525120 | 0.1523457 | 8913728 | 9.80 | 16.97 | ||||||
g9 y9 | 0.0160221 | 896 | 0.1505100 | 8520512 | 9.39 | 9509.50 | ||||||
g6 y6 | 0.0025613 | 896 | 0.1506287 | 8520512 | 58.81 | 9509.50 |