<div dir="ltr">I have not tested this, but I suspect that the MATLAB routine is using the erf implementation from the Intel Math Kernel Libraries (MKL).    <div><br></div><div>There is a function in MKL called vdErf that takes a vector of doubles and is likely tuned to the hardware.    This could be linked to NumPy with similar speed benefits. <div><div><div><br></div><div>-Travis</div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 20, 2015 at 5:02 PM, Julian Taylor <span dir="ltr"><<a href="mailto:jtaylor.debian@googlemail.com" target="_blank">jtaylor.debian@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 20.03.2015 22:08, Pauli Virtanen wrote:<br>
> 20.03.2015, 20:29, Will Adler kirjoitti:<br>
> [clip]<br>
>> Is there anything that can be done to speed up SciPy’s erf()?<br>
><br>
> Possibly.<br>
><br>
> <a href="https://github.com/scipy/scipy/blob/master/scipy/special/cephes/ndtr.c#L483" target="_blank">https://github.com/scipy/scipy/blob/master/scipy/special/cephes/ndtr.c#L483</a><br>
><br>
> The simplest thing would probably be just to write the Pade approximant<br>
> in a form the C compiler can inline. erf and erfc are also in C99, so<br>
> glibc may have a fast implementation.<br>
><br>
<br>
</span>using glibc is unlikely to be faster, as they focus on correctness and<br>
not speed. Though its worth a try.<br>
<br>
The two 4 coefficient evaluations can be perfectly vectorized, just<br>
needs rearranging the static coefficient tables, that should give a<br>
decent speedup.<br>
Also the isnan call could be turned into a builtin instead of the<br>
function call gcc/glibc does.<br>
In total with this implementation I guess 40-50% improvement should be<br>
possible.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
SciPy-Dev mailing list<br>
<a href="mailto:SciPy-Dev@scipy.org">SciPy-Dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/scipy-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/scipy-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><br><div>Travis Oliphant</div><div>CEO</div><div>Continuum Analytics, Inc.<br></div><div><a href="http://www.continuum.io" target="_blank">http://www.continuum.io</a></div></div></div>
</div>