I was initially surprised by the big differences in performance between
different formulations of the sum of the quotients

tstdata=: _2 */\ 1+2*i.1000000

50 timespacex '+/ 8 % tstdata'

0.00206915 4.19581e6

50 timespacex '8 +/@:% tstdata'

0.0686648 1792

The first is up to 113 times faster (depending on platform and J version),
the 2nd is over 2000 times leaner. I see similar differences back to J602.
I think this surprised me because I am usually comparing the sum of
products. In that case I guess the special code for +/@:* hides the "usual"
difference

50 timespacex '+/ 8 * tstdata'

0.00193723 4.19581e6

50 timespacex '8 +/@:* tstdata'

0.00042151 1664


It does make we wonder if we can't do better for quotient? I imagine the
answer is yes but whether it is worth it depends on how often it is used.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to