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

From J Wiki
Jump to navigation Jump to search


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



f/ on Sparse Arguments Improved

initial writing: 2001-07-29
last updated: 2004-10-26


The monads f/ on sparse arguments have been made more efficient in time and space. The following table compares the time and space required for +/s and +/"1 s for sparse s of various shapes.


   s=: 1 $. shape
   r=: ?. 1e5   $ 1e6
   i=: ?. (1e5,#$s) $ $s
   s=: r (<"1 i)}s

   ts=: 6!:2 , 7!:2@]   NB. time and space
   ts '+/   s'
   ts '+/"1 s'

    Shape Expression     J 5.01    J 4.06    Ratio
10 10 10 10 1e6     +/   s 0.237968  3802752 0.328043 12846848 1.38  3.38
+/"1 s 0.025751  526144 0.191156  3229632 7.42  6.14
1e6 10 10 10 10 +/   s 0.346326  1050432 0.445293  9520896 1.29  9.06
+/"1 s 0.051208  3278656 0.206031  6555584 4.02  2.00
2 10 10 10 10 1e6 +/   s 0.225852  3802752 0.430299 21171776 1.91  5.57
+/"1 s 0.037085  919360 0.221206  3704768 5.96  4.03
1e6 10 10 10 10 2 +/   s 0.362589  1443648 0.475774 14190336 1.31  9.83
+/"1 s 0.056411  3278656 0.421492 21172160 7.47  6.46
4$1e6 +/   s 0.299557  3802752 0.381521 12846848 1.27  3.38
+/"1 s 0.044956  3278656 0.180579  6555584 4.02  2.00
8$1e3 +/   s 0.338152  5900096 0.551470 21235712 1.63  3.60
+/"1 s 0.078596  5376000 0.464777 10750080 5.91  2.00




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