[SciPy-dev] Lambert W implementation
Pauli Virtanen
pav+sp at iki.fi
Fri Oct 30 05:28:24 EDT 2009
Fri, 30 Oct 2009 10:54:40 +0200, Yosef Meller wrote:
[clip]
> Ok, the mpmath implementation seems suitable, and they also have a
> reference and some test values. What I see as the way forward is to take
> all mpmath-related wrapping out and provide a simpler floating-point
> version. I think I'll do a Cython function for scalar argument, then
> count on the usual vectorization facilities in NumPy to handle the rest
> (np.vectorize).
It's faster to make it a Ufunc -- np.vectorize will likely sacrifice
much of the speed gained from using Cython since it's going to box and unbox
numbers in Python floats. There's an example how to do Ufuncs in
Cython here:
http://projects.scipy.org/scipy/browser/trunk/scipy/special/orthogonal_eval.pyx
If you get it done, please post the result (preferably, create
a ticket on http://projects.scipy.org/scipy/ and attach the file) and
we'll integrate it in scipy.special. If you also write tests, that'd
be great!
Note that newer Cythons also have support for native complex numbers, so
you can do
cdef double complex a = ...
The same algorithm probably works both for real and complex parameters.
--
Pauli Virtanen
More information about the SciPy-Dev
mailing list