Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86472 - trunk/boost/math/special_functions/detail
From: john_at_[hidden]
Date: 2013-10-27 05:23:16


Author: johnmaddock
Date: 2013-10-27 05:23:16 EDT (Sun, 27 Oct 2013)
New Revision: 86472
URL: http://svn.boost.org/trac/boost/changeset/86472

Log:
Prevent spurious underflow in Bessel K.

Text files modified:
   trunk/boost/math/special_functions/detail/bessel_ik.hpp | 6 +++++-
   1 files changed, 5 insertions(+), 1 deletions(-)

Modified: trunk/boost/math/special_functions/detail/bessel_ik.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/bessel_ik.hpp Sat Oct 26 19:35:40 2013 (r86471)
+++ trunk/boost/math/special_functions/detail/bessel_ik.hpp 2013-10-27 05:23:16 EDT (Sun, 27 Oct 2013) (r86472)
@@ -271,6 +271,7 @@
         // S converges slower than f
         BOOST_MATH_INSTRUMENT_VARIABLE(Q * delta);
         BOOST_MATH_INSTRUMENT_VARIABLE(abs(S) * tolerance);
+ BOOST_MATH_INSTRUMENT_VARIABLE(S);
         if (abs(Q * delta) < abs(S) * tolerance)
         {
            break;
@@ -278,7 +279,10 @@
     }
     policies::check_series_iterations<T>("boost::math::bessel_ik<%1%>(%1%,%1%) in CF2_ik", k, pol);
 
- *Kv = sqrt(pi<T>() / (2 * x)) * exp(-x) / S;
+ if(x >= tools::log_max_value<T>())
+ *Kv = exp(0.5f * log(pi<T>() / (2 * x)) - x - log(S));
+ else
+ *Kv = sqrt(pi<T>() / (2 * x)) * exp(-x) / S;
     *Kv1 = *Kv * (0.5f + v + x + (v * v - 0.25f) * f) / x;
     BOOST_MATH_INSTRUMENT_VARIABLE(*Kv);
     BOOST_MATH_INSTRUMENT_VARIABLE(*Kv1);


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