Boost logo

Boost-Commit :

From: johnmaddock_at_[hidden]
Date: 2007-06-05 05:20:23


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

Log:
Bug Fix: If we reach a denormalised result and it's still not small enough, return zero as we're not going to find a better value.

Text files modified:
   sandbox/math_toolkit/boost/math/tools/toms748_solve.hpp | 7 +++++++
   1 files changed, 7 insertions(+), 0 deletions(-)

Modified: sandbox/math_toolkit/boost/math/tools/toms748_solve.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/tools/toms748_solve.hpp (original)
+++ sandbox/math_toolkit/boost/math/tools/toms748_solve.hpp 2007-06-05 05:20:23 EDT (Tue, 05 Jun 2007)
@@ -464,6 +464,13 @@
       //
       while(sign(fb) == sign(fa))
       {
+ if(fabs(a) < tools::min_value<T>())
+ {
+ // Escape route just in case the answer is zero!
+ max_iter -= count;
+ max_iter += 1;
+ return a > 0 ? std::make_pair(T(0), T(a)) : std::make_pair(T(a), T(0));
+ }
          if(count == 0)
             tools::logic_error(BOOST_CURRENT_FUNCTION, "Unable to bracket root, last nearest value was %1%", a);
          b = a;


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