Recent changes to feature-requestshttps://sourceforge.net/p/jnumerical/feature-requests/Recent changes to feature-requestsenTue, 18 Jun 2002 22:08:46 -0000Tune performance of cross_correlate()https://sourceforge.net/p/jnumerical/feature-requests/3/<div class="markdown_content"><p>I've been benchmarking the new cross_correlate() <br />
function against code written in pure Jython, as well as <br />
against CPython. Here's what I've learned:</p>
<p>On average, JNumeric runs about 15 times slower than <br />
CPython, at least for this function, under my particular <br />
setup (I've read somewhere that others find Jython runs <br />
only 1.7 times slower than CPython - your milage may <br />
vary).</p>
<p>Part of the reason for this is the difference in algorithms <br />
used to compute the cross-correlation. Jnumeric uses <br />
an FFT-based algorithm, which is Nlog(N). Cnumeric <br />
uses a simple multiply-and-add algorithm, with some <br />
clever usage of the mode information. </p>
<p>Here are some example data for cross-correlating two <br />
vectors of 1024 elements, 1000 times each. The column <br />
headings are:<br />
CNumeric: use the cross_correlate() function<br />
CPy: write a function that implements an FFT-based <br />
cross-correlation, but use only the fft() function and write <br />
it in pure Python</p>
<p>Mode CNumeric CPy JNumeric Ratio (C/J)<br />
0 0.0103 3.75 52.3 5076<br />
1 3.4422 3.8 57 16.6<br />
2 4.62 4.2 62 13.4</p>
<p>That's great, but what happens when you go up to 8192 <br />
elements:</p>
<p>Mode CNumeric CPy <br />
0 .043 63 <br />
1 231 80 <br />
2 308 73</p>
<p>(For a vector 8 times as long, CPy takes about 20 times <br />
longer, while in the worst case, CNumeric takes over 64 <br />
times longer. This is as you'd expect for those <br />
algorithms.)</p>
<p>It's clear from this that the CNumeric algorithm is not to <br />
be recommended for long vector lengths (but we knew <br />
that from reading Numerical Recipes). And yet, for short <br />
lengths, it's really much faster (5000x!) than the FFT-<br />
based algorithm. Just goes to show that 1000*N*logN <br />
will always be much larger than N^2 for some small <br />
enough N! </p>
<p>To get decent performance for short and long vectors, <br />
we need to go with a dual algorithm, using ideas from <br />
CNumeric's implementation, but keeping the FFT-based <br />
algorithm as implemented so far.</p>
<p>Incidentally, comparing the build-in cross_correlate() <br />
function with the same functionality implemented in <br />
Jython using fft() shows that the performance is only 1-<br />
5x faster. What's up with that?</p>
<p>-Frank</p></div>Frank GibbonsTue, 18 Jun 2002 22:08:46 -0000https://sourceforge.netc3ca7a070887ebc139f5776f9de590e5c2b34a05Regression tests.https://sourceforge.net/p/jnumerical/feature-requests/2/<div class="markdown_content"><p>We need tests, both to test the current functionality, <br />
and the ensure we don't break it as we develop it.</p></div>Frank GibbonsThu, 18 Apr 2002 13:53:22 -0000https://sourceforge.netaee172478907fedfe2abba49f1256476c871ee5dAdd cross_correlate()https://sourceforge.net/p/jnumerical/feature-requests/1/<div class="markdown_content"><p>JNumeric doesn't have it, CNumeric does. We need it.</p></div>Frank GibbonsThu, 18 Apr 2002 13:52:08 -0000https://sourceforge.net1e472bd74d85af4eefb4af210e466303bf9faa04