|
Boost-Commit : |
From: john_at_[hidden]
Date: 2007-10-23 14:41:17
Author: johnmaddock
Date: 2007-10-23 14:41:17 EDT (Tue, 23 Oct 2007)
New Revision: 40368
URL: http://svn.boost.org/trac/boost/changeset/40368
Log:
Fix for negative guesses.
Text files modified:
sandbox/math_toolkit/boost/math/tools/toms748_solve.hpp | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 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-10-23 14:41:17 EDT (Tue, 23 Oct 2007)
@@ -488,7 +488,7 @@
//
boost::uintmax_t count = max_iter - 1;
- if((fa < 0) == rising)
+ if((fa < 0) == (guess < 0 ? !rising : rising))
{
//
// Zero is to the right of b, so walk upwards
@@ -551,7 +551,15 @@
}
max_iter -= count;
max_iter += 1;
- std::pair<T, T> r = toms748_solve(f, a, b, fa, fb, tol, count, pol);
+ std::pair<T, T> r = toms748_solve(
+ f,
+ (a < 0 ? b : a),
+ (a < 0 ? a : b),
+ (a < 0 ? fb : fa),
+ (a < 0 ? fa : fb),
+ tol,
+ count,
+ pol);
max_iter += count;
BOOST_MATH_INSTRUMENT_CODE("max_iter = " << max_iter << " count = " << count);
return r;
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