[SciPy-dev] Bessel functions from Boost

Charles R Harris charlesr.harris at gmail.com
Sun Feb 8 13:39:55 EST 2009


On Sun, Feb 8, 2009 at 10:23 AM, Pauli Virtanen <pav at iki.fi> wrote:

>
> Some of the real-valued Bessel function implementations from the Cephes
> library currently used in scipy.special have problems. (See #503, #851,
> #853, #854.) Fixing some of these (eg. #503) would require implementing
> robust computation algorithms from scratch. (The Specfun code is IMHO too
> obscure and badly commented to be relied on as an alternative.)
>
> However, the Boost library seems to have good implementations Bessel
> (and some other) special functions:
>
>
> http://svn.boost.org/svn/boost/trunk/boost/math/special_functions/detail/
>
> http://www.boost.org/doc/libs/1_37_0/libs/math/doc/sf_and_dist/html/math_toolkit/special.html
>
> Also the license seems Scipy-compatible:
>
>        http://www.boost.org/LICENSE_1_0.txt
>
> So, I'd like to bring these over to Scipy, to replace some of the Cephes
> routines.
>
> The only problem is that being in Boost, they are written in C++, and I
> guess we can't make Scipy to depend on it.
>
> I see two options:
>
>  A) Bundle the relevant subset of Boost with Scipy. The problem here
>     is that the special functions seem to pull in a sizable subset
>     of the whole Boost library.
>

That's a common problem with big c++ libraries.

>
>     Also, I don't know how well compilers handle the template-happy
>     C++ in boost today on all platforms where Scipy must work on.
>
>  B) Convert the Boost code from C++ to C. This is in fact quite trivial
>     search-and-replace operation. One example here:
>
>
> http://github.com/pv/scipy/blob/ticket-503-special-iv-fix/scipy/special/cephes/scipy_iv.c
>
> I'd like to see (B) happen in scipy.special. Thoughts?
>

I think it's a good idea. It would also be nice if we picked best of breed
from several libraries to make up our own special functions collection. For
instance, there are several log gamma functions. That's probably a big job
though and we would need extensive tests for the functions before trying it.
Do you know of any other project that has put together such a test suite?

Does boost have versions for log1p? We need a better implementation in numpy
itself.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20090208/4a2d41e9/attachment.html>


More information about the SciPy-Dev mailing list