Help / Release / J 5.01 / + on Sparse Arguments Improved

From J Wiki
Jump to navigation Jump to search


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



+ on Sparse Arguments Improved

initial writing: 2001-08-02
last updated: 2004-10-26


The dyad + (and other atomic functions such as - * ) on sparse arguments are now more efficient in time and space. For example:

   s=: 13 17 19
   x=: ?.1600$1e6
   i=: ?.(1600,#s)$s
   
   p=: (800{.x) (<"1 ]800{.i)}1$.s
   q=: (800}.x) (<"1 ]800}.i)}1$.s

   ts=: 6!:2 , 7!:2@]   NB. time and space
   ts 'p+q'
Expression     J 5.01    J 4.06    Ratio
p + q 0.000450895  33792 0.001660546 153856 3.68  4.55
p - q 0.000447822  33792 0.001658311 153856 3.70  4.55
p * q 0.000249473  5248 0.000749537  52608 3.00 10.02
p % q 0.000645613  33792 0.001753016 153856 2.72  4.55
p = q 0.000742552  19456 0.001741841 127232 2.35  6.54
p ~:q 0.000748978  19456 0.001632051 127232 2.18  6.54
p < q 0.000670756  19456 0.001730108 136448 2.58  7.01




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