[Scipy-tickets] [SciPy] #1757: new upstream of complex erf code (special.wofz) - performance, accuracy improvements
SciPy Trac
scipy-tickets@scipy....
Wed Oct 31 10:58:46 CDT 2012
#1757: new upstream of complex erf code (special.wofz) - performance, accuracy
improvements
---------------------------+------------------------------------------------
Reporter: stevenj | Owner: pv
Type: defect | Status: new
Priority: normal | Milestone: Unscheduled
Component: scipy.special | Version: devel
Keywords: |
---------------------------+------------------------------------------------
Comment(by stevenj):
I have also noticed that Faddeeva_w is generally faster, and sometimes a
bit more accurate, than the Fortran CERROR
(scipy/scipy/special/specfun/specfun.f) function that SciPy is currently
using to implement the erf(z) function for complex arguments.
In particular, you would compute erf(z) from Faddeeva_w using something
like:
static complex<double> Faddeeva_erf(complex<double> z)
{
double x = real(z), y = imag(z);
double mRe_z2 = (y - x) * (x + y); // Re(-z^2), being careful of
overflow
double mIm_z2 = -2*x*y; // Im(z^2)
if (mRe_z2 < -27) // underflow
return (x >= 0 ? 1.0 : -1.0);
else if (x >= 0)
return 1.0 - (exp(complex<double>(mRe_z2, mIm_z2))
* Faddeeva_w(complex<double>(-y,x)));
else // x < 0
return (exp(complex<double>(mRe_z2, mIm_z2))
* Faddeeva_w(complex<double>(y,-x))) - 1.0;
}
--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1757#comment:4>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
More information about the Scipy-tickets
mailing list