<p dir="auto"><em>Original ticket <a href="http://projects.scipy.org/scipy/ticket/726" rel="nofollow">http://projects.scipy.org/scipy/ticket/726</a> on 2008-08-24 by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ilanschnell/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ilanschnell">@ilanschnell</a>, assigned to unknown.</em></p>
<p dir="auto">I have implemented, documented and tested a new function<br>
called 'fast_vectorize'.  This function is intended to be used<br>
as a decorator, and it's purpose is to easily create Ufunc<br>
objects for a given python function.  The function translates a<br>
Python function, actually an RPython (resticted Python) function,<br>
which is still valid Python, into C using the PyPy translator.<br>
Therefore this functions has a dependency on pypy.  However, pypy<br>
is imported in a lazy manner, such that scipy itself will not depend<br>
on pypy, which is a big project.</p>
<p dir="auto">Included in the patch is the core implementation, tests, benchmarks,<br>
as well as examples.</p>
<p dir="auto">I have tested this patch against latest svn numpy trunk (which<br>
is required for the current scipy trunk), Python2.4 on SuSE Linux<br>
and Python2.5 on OSX10.4.</p>
<p dir="auto">To apply the patch, you need to go change to the scipy root and run patch:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ cd scipy
$ ls
FORMAT_GUIDELINES.txt  MANIFEST.in      setupegg.py       THANKS.txt
INSTALL.txt            new_manifest.sh  setup.py          TOCHANGE.txt
LATEST.txt             README.txt       setupscons.py
LICENSE.txt            scipy            site.cfg.example
$ md5sum path_to/fast_vec.diff
9ecfa0351b5742a18819cd241e3f54c9
$ patch -p1 &lt; path_to/fast_vec.diff"><pre class="notranslate"><code class="notranslate">$ cd scipy
$ ls
FORMAT_GUIDELINES.txt  MANIFEST.in      setupegg.py       THANKS.txt
INSTALL.txt            new_manifest.sh  setup.py          TOCHANGE.txt
LATEST.txt             README.txt       setupscons.py
LICENSE.txt            scipy            site.cfg.example
$ md5sum path_to/fast_vec.diff
9ecfa0351b5742a18819cd241e3f54c9
$ patch -p1 &lt; path_to/fast_vec.diff
</code></pre></div>
<p dir="auto">Numpy 1.17 has adopted the C version of pocketfft (<a href="https://gitlab.mpcdf.mpg.de/mtr/pocketfft" rel="nofollow">https://gitlab.mpcdf.mpg.de/mtr/pocketfft</a>) as their FFT implementation. Since then I have been working on the pocketfft code, converted it to C++ and added a Python wrapper.</p>
<p dir="auto">The new library (<a href="https://gitlab.mpcdf.mpg.de/mtr/pypocketfft" rel="nofollow">https://gitlab.mpcdf.mpg.de/mtr/pypocketfft</a>)</p>
<ul dir="auto">
<li>supports complex and half-complex transforms, also Hartley transforms</li>
<li>supports float, double and long double precision</li>
<li>supports multi-dimensional FFTs</li>
<li>uses CPU vector instructions for ndim&gt;1 (i.e. it computes several 1D FFTs dimultaneously).</li>
<li>uses the Bluestein algorithm for FFTs with large prime factors</li>
</ul>
<p dir="auto">Performance is significantly better than FFTPACK's, accuracy as well. For benchmarks and dicussion see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="357329719" data-permission-text="Title is private" data-url="https://github.com/numpy/numpy/issues/11888" data-hovercard-type="pull_request" data-hovercard-url="/numpy/numpy/pull/11888/hovercard" href="https://github.com/numpy/numpy/pull/11888">numpy/numpy#11888</a> and recent comments in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="357136402" data-permission-text="Title is private" data-url="https://github.com/numpy/numpy/issues/11885" data-hovercard-type="issue" data-hovercard-url="/numpy/numpy/issues/11885/hovercard" href="https://github.com/numpy/numpy/issues/11885">numpy/numpy#11885</a>.<br>
I have also added an interface which is very similar to <code class="notranslate">scipy.fftpack</code>.</p>
<p dir="auto">Potential problems for adaptation:</p>
<ul dir="auto">
<li>written in C++, requires a C++11 compiler and pybind11</li>
<li>cosine/sine transforms are missing, and I probaly won't have the time ti implement them. They would have to be added on top of the existing machinery.</li>
</ul>
<p dir="auto">Would this be of interest for Scipy?</p>