Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86415 - branches/release/boost/math/special_functions
From: john_at_[hidden]
Date: 2013-10-24 04:35:41


Author: johnmaddock
Date: 2013-10-24 04:35:41 EDT (Thu, 24 Oct 2013)
New Revision: 86415
URL: http://svn.boost.org/trac/boost/changeset/86415

Log:
Fix initialization of power series so that we don't get a spurious overflow error from tgamma when the result is actually zero.

Text files modified:
   branches/release/boost/math/special_functions/bessel.hpp | 14 +++++++++++++-
   1 files changed, 13 insertions(+), 1 deletions(-)

Modified: branches/release/boost/math/special_functions/bessel.hpp
==============================================================================
--- branches/release/boost/math/special_functions/bessel.hpp Thu Oct 24 02:10:34 2013 (r86414)
+++ branches/release/boost/math/special_functions/bessel.hpp 2013-10-24 04:35:41 EDT (Thu, 24 Oct 2013) (r86415)
@@ -48,7 +48,13 @@
    {
       BOOST_MATH_STD_USING
       mult = x / 2;
- term = pow(mult, T(v)) / boost::math::tgamma(v+1+T(0.5f), Policy());
+ if(v + 3 > max_factorial<T>::value)
+ {
+ term = v * log(mult) - boost::math::lgamma(v+1+T(0.5f), Policy());
+ term = exp(term);
+ }
+ else
+ term = pow(mult, T(v)) / boost::math::tgamma(v+1+T(0.5f), Policy());
       mult *= -mult;
    }
    T operator()()
@@ -142,6 +148,11 @@
    if(n == 0)
       return boost::math::sinc_pi(x, pol);
    //
+ // Special case for x == 0:
+ //
+ if(x == 0)
+ return 0;
+ //
    // When x is small we may end up with 0/0, use series evaluation
    // instead, especially as it converges rapidly:
    //
@@ -752,3 +763,4 @@
 
 #endif // BOOST_MATH_BESSEL_HPP
 
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk