It's good that you spotted this.
When you write (x + y), you automatically get a doubly-nested loop over
the shapes/frames. When you write (x +"n y) you get two more levels of
looping. In the case of (x +"0 _ y) on list x/atom y, the code was
looping through the outer loop while the inner loops were running only
one iteration per loop. This is much less efficient than using the
inner loop, which can run 4 operations in parallel.
The cases I can see to improve are
* where the inner loop is a single atom
* when the n-cells require no repetition and the n-frames are identical
On 9/17/2020 3:55 AM, Joseph Novakovich wrote:
Hi,
I was writing off the stats/base addon, and I noticed the
implementation for deviation from mean is slower than should be for
lists:
x =: ? 1e6 $ 0
dev =: (-"_1 _ mean) NB. current
dev0=: (- mean)`(-"_1 _ mean)@.(1<#@$) NB. proposed
10 (6!:2) 'dev x'
0.155722
10 (6!:2) 'dev0 x'
0.0015065
I sent a patch https://github.com/jsoftware/stats_base/pull/2 and Ric
Sherlock suggested I should inquire here if it's something to look at
in the language implementation instead.
Thanks,
Joseph
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by AVG.
https://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm