Help / Release / J 7.01 / {/: and {/:~ Improved

From J Wiki
Jump to navigation Jump to search


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



{/: and {/:~ Improved

initial writing: 2008-03-20
last updated: 2010-03-31


The dyads x{/:y and x{/:~y can be used to compute order statistics such as the median. They have been made more efficient for integer atom x and integer or floating-point list y . The following benchmarks demonstrate the improvements.

x=: ?1e6
i=: 1e6 ?@$ 2e9
d=: 0.01 * i 

ts=: 6!:2 , 7!:2@]  NB. time and space
100 ts 'Expression'
Expression    J 7.01    J 6.02    Ratio
x ({/: ) i 0.028988 2.09856e6 0.214498 8.91366e6 7.40 4.25
x ({/:~) i 0.027497 4.19584e6 0.137272 8.91386e6 4.99 2.12
x ({/: ) d 0.045599 4.19571e6 0.340021 8.91366e6 7.46 2.12
x ({/:~) d 0.046481 4.19584e6 0.161224 1.73025e7 3.47 4.12



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