Boost logo

Boost-Commit :

From: johnmaddock_at_[hidden]
Date: 2007-06-05 05:14:03


Author: johnmaddock
Date: 2007-06-05 05:14:03 EDT (Tue, 05 Jun 2007)
New Revision: 4450
URL: http://svn.boost.org/trac/boost/changeset/4450

Log:
Bug fix: denormalised values are just as bad for the subsequent logic as a zero.

Text files modified:
   sandbox/math_toolkit/boost/math/special_functions/beta.hpp | 4 +++-
   1 files changed, 3 insertions(+), 1 deletions(-)

Modified: sandbox/math_toolkit/boost/math/special_functions/beta.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/special_functions/beta.hpp (original)
+++ sandbox/math_toolkit/boost/math/special_functions/beta.hpp 2007-06-05 05:14:03 EDT (Tue, 05 Jun 2007)
@@ -470,6 +470,8 @@
       // Non-normalised, just compute the power:
       result = pow(x, a);
    }
+ if(result < tools::min_value<T>())
+ return 0; // Safeguard: series can't cope with denorms.
    ibeta_series_t<T> s(a, b, x, result);
    boost::uintmax_t max_iter = BOOST_MATH_MAX_ITER;
    result = boost::math::tools::sum_series(s, boost::math::tools::digits<T>(), max_iter, s0);
@@ -710,7 +712,7 @@
    // and from from 9.2:
    T prefix;
    T h = regularised_gamma_prefix(b, u, l);
- if(h == 0)
+ if(h <= tools::min_value<T>())
       return s0;
    if(normalised)
    {


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