Chris@16: // (C) Copyright John Maddock 2006. Chris@16: // Use, modification and distribution are subject to the Chris@16: // Boost Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_MATH_TOOLS_SOLVE_ROOT_HPP Chris@16: #define BOOST_MATH_TOOLS_SOLVE_ROOT_HPP Chris@16: Chris@16: #ifdef _MSC_VER Chris@16: #pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@101: #ifdef BOOST_MATH_LOG_ROOT_ITERATIONS Chris@101: # define BOOST_MATH_LOGGER_INCLUDE Chris@101: # include BOOST_MATH_LOGGER_INCLUDE Chris@101: # undef BOOST_MATH_LOGGER_INCLUDE Chris@101: #else Chris@101: # define BOOST_MATH_LOG_COUNT(count) Chris@101: #endif Chris@101: Chris@16: namespace boost{ namespace math{ namespace tools{ Chris@16: Chris@16: template Chris@16: class eps_tolerance Chris@16: { Chris@16: public: Chris@16: eps_tolerance(unsigned bits) Chris@16: { Chris@16: BOOST_MATH_STD_USING Chris@16: eps = (std::max)(T(ldexp(1.0F, 1-bits)), T(4 * tools::epsilon())); Chris@16: } Chris@16: bool operator()(const T& a, const T& b) Chris@16: { Chris@16: BOOST_MATH_STD_USING Chris@16: return fabs(a - b) <= (eps * (std::min)(fabs(a), fabs(b))); Chris@16: } Chris@16: private: Chris@16: T eps; Chris@16: }; Chris@16: Chris@16: struct equal_floor Chris@16: { Chris@16: equal_floor(){} Chris@16: template Chris@16: bool operator()(const T& a, const T& b) Chris@16: { Chris@16: BOOST_MATH_STD_USING Chris@16: return floor(a) == floor(b); Chris@16: } Chris@16: }; Chris@16: Chris@16: struct equal_ceil Chris@16: { Chris@16: equal_ceil(){} Chris@16: template Chris@16: bool operator()(const T& a, const T& b) Chris@16: { Chris@16: BOOST_MATH_STD_USING Chris@16: return ceil(a) == ceil(b); Chris@16: } Chris@16: }; Chris@16: Chris@16: struct equal_nearest_integer Chris@16: { Chris@16: equal_nearest_integer(){} Chris@16: template Chris@16: bool operator()(const T& a, const T& b) Chris@16: { Chris@16: BOOST_MATH_STD_USING Chris@16: return floor(a + 0.5f) == floor(b + 0.5f); Chris@16: } Chris@16: }; Chris@16: Chris@16: namespace detail{ Chris@16: Chris@16: template Chris@16: void bracket(F f, T& a, T& b, T c, T& fa, T& fb, T& d, T& fd) Chris@16: { Chris@16: // Chris@16: // Given a point c inside the existing enclosing interval Chris@16: // [a, b] sets a = c if f(c) == 0, otherwise finds the new Chris@16: // enclosing interval: either [a, c] or [c, b] and sets Chris@16: // d and fd to the point that has just been removed from Chris@16: // the interval. In other words d is the third best guess Chris@16: // to the root. Chris@16: // Chris@16: BOOST_MATH_STD_USING // For ADL of std math functions Chris@16: T tol = tools::epsilon() * 2; Chris@16: // Chris@16: // If the interval [a,b] is very small, or if c is too close Chris@16: // to one end of the interval then we need to adjust the Chris@16: // location of c accordingly: Chris@16: // Chris@16: if((b - a) < 2 * tol * a) Chris@16: { Chris@16: c = a + (b - a) / 2; Chris@16: } Chris@16: else if(c <= a + fabs(a) * tol) Chris@16: { Chris@16: c = a + fabs(a) * tol; Chris@16: } Chris@16: else if(c >= b - fabs(b) * tol) Chris@16: { Chris@16: c = b - fabs(a) * tol; Chris@16: } Chris@16: // Chris@16: // OK, lets invoke f(c): Chris@16: // Chris@16: T fc = f(c); Chris@16: // Chris@16: // if we have a zero then we have an exact solution to the root: Chris@16: // Chris@16: if(fc == 0) Chris@16: { Chris@16: a = c; Chris@16: fa = 0; Chris@16: d = 0; Chris@16: fd = 0; Chris@16: return; Chris@16: } Chris@16: // Chris@16: // Non-zero fc, update the interval: Chris@16: // Chris@16: if(boost::math::sign(fa) * boost::math::sign(fc) < 0) Chris@16: { Chris@16: d = b; Chris@16: fd = fb; Chris@16: b = c; Chris@16: fb = fc; Chris@16: } Chris@16: else Chris@16: { Chris@16: d = a; Chris@16: fd = fa; Chris@16: a = c; Chris@16: fa= fc; Chris@16: } Chris@16: } Chris@16: Chris@16: template Chris@16: inline T safe_div(T num, T denom, T r) Chris@16: { Chris@16: // Chris@16: // return num / denom without overflow, Chris@16: // return r if overflow would occur. Chris@16: // Chris@16: BOOST_MATH_STD_USING // For ADL of std math functions Chris@16: Chris@16: if(fabs(denom) < 1) Chris@16: { Chris@16: if(fabs(denom * tools::max_value()) <= fabs(num)) Chris@16: return r; Chris@16: } Chris@16: return num / denom; Chris@16: } Chris@16: Chris@16: template Chris@16: inline T secant_interpolate(const T& a, const T& b, const T& fa, const T& fb) Chris@16: { Chris@16: // Chris@16: // Performs standard secant interpolation of [a,b] given Chris@16: // function evaluations f(a) and f(b). Performs a bisection Chris@16: // if secant interpolation would leave us very close to either Chris@16: // a or b. Rationale: we only call this function when at least Chris@16: // one other form of interpolation has already failed, so we know Chris@16: // that the function is unlikely to be smooth with a root very Chris@16: // close to a or b. Chris@16: // Chris@16: BOOST_MATH_STD_USING // For ADL of std math functions Chris@16: Chris@16: T tol = tools::epsilon() * 5; Chris@16: T c = a - (fa / (fb - fa)) * (b - a); Chris@16: if((c <= a + fabs(a) * tol) || (c >= b - fabs(b) * tol)) Chris@16: return (a + b) / 2; Chris@16: return c; Chris@16: } Chris@16: Chris@16: template Chris@16: T quadratic_interpolate(const T& a, const T& b, T const& d, Chris@16: const T& fa, const T& fb, T const& fd, Chris@16: unsigned count) Chris@16: { Chris@16: // Chris@16: // Performs quadratic interpolation to determine the next point, Chris@16: // takes count Newton steps to find the location of the Chris@16: // quadratic polynomial. Chris@16: // Chris@16: // Point d must lie outside of the interval [a,b], it is the third Chris@16: // best approximation to the root, after a and b. Chris@16: // Chris@16: // Note: this does not guarentee to find a root Chris@16: // inside [a, b], so we fall back to a secant step should Chris@16: // the result be out of range. Chris@16: // Chris@16: // Start by obtaining the coefficients of the quadratic polynomial: Chris@16: // Chris@16: T B = safe_div(T(fb - fa), T(b - a), tools::max_value()); Chris@16: T A = safe_div(T(fd - fb), T(d - b), tools::max_value()); Chris@16: A = safe_div(T(A - B), T(d - a), T(0)); Chris@16: Chris@16: if(A == 0) Chris@16: { Chris@16: // failure to determine coefficients, try a secant step: Chris@16: return secant_interpolate(a, b, fa, fb); Chris@16: } Chris@16: // Chris@16: // Determine the starting point of the Newton steps: Chris@16: // Chris@16: T c; Chris@16: if(boost::math::sign(A) * boost::math::sign(fa) > 0) Chris@16: { Chris@16: c = a; Chris@16: } Chris@16: else Chris@16: { Chris@16: c = b; Chris@16: } Chris@16: // Chris@16: // Take the Newton steps: Chris@16: // Chris@16: for(unsigned i = 1; i <= count; ++i) Chris@16: { Chris@16: //c -= safe_div(B * c, (B + A * (2 * c - a - b)), 1 + c - a); Chris@16: c -= safe_div(T(fa+(B+A*(c-b))*(c-a)), T(B + A * (2 * c - a - b)), T(1 + c - a)); Chris@16: } Chris@16: if((c <= a) || (c >= b)) Chris@16: { Chris@16: // Oops, failure, try a secant step: Chris@16: c = secant_interpolate(a, b, fa, fb); Chris@16: } Chris@16: return c; Chris@16: } Chris@16: Chris@16: template Chris@16: T cubic_interpolate(const T& a, const T& b, const T& d, Chris@16: const T& e, const T& fa, const T& fb, Chris@16: const T& fd, const T& fe) Chris@16: { Chris@16: // Chris@16: // Uses inverse cubic interpolation of f(x) at points Chris@16: // [a,b,d,e] to obtain an approximate root of f(x). Chris@16: // Points d and e lie outside the interval [a,b] Chris@16: // and are the third and forth best approximations Chris@16: // to the root that we have found so far. Chris@16: // Chris@16: // Note: this does not guarentee to find a root Chris@16: // inside [a, b], so we fall back to quadratic Chris@16: // interpolation in case of an erroneous result. Chris@16: // Chris@16: BOOST_MATH_INSTRUMENT_CODE(" a = " << a << " b = " << b Chris@16: << " d = " << d << " e = " << e << " fa = " << fa << " fb = " << fb Chris@16: << " fd = " << fd << " fe = " << fe); Chris@16: T q11 = (d - e) * fd / (fe - fd); Chris@16: T q21 = (b - d) * fb / (fd - fb); Chris@16: T q31 = (a - b) * fa / (fb - fa); Chris@16: T d21 = (b - d) * fd / (fd - fb); Chris@16: T d31 = (a - b) * fb / (fb - fa); Chris@16: BOOST_MATH_INSTRUMENT_CODE( Chris@16: "q11 = " << q11 << " q21 = " << q21 << " q31 = " << q31 Chris@16: << " d21 = " << d21 << " d31 = " << d31); Chris@16: T q22 = (d21 - q11) * fb / (fe - fb); Chris@16: T q32 = (d31 - q21) * fa / (fd - fa); Chris@16: T d32 = (d31 - q21) * fd / (fd - fa); Chris@16: T q33 = (d32 - q22) * fa / (fe - fa); Chris@16: T c = q31 + q32 + q33 + a; Chris@16: BOOST_MATH_INSTRUMENT_CODE( Chris@16: "q22 = " << q22 << " q32 = " << q32 << " d32 = " << d32 Chris@16: << " q33 = " << q33 << " c = " << c); Chris@16: Chris@16: if((c <= a) || (c >= b)) Chris@16: { Chris@16: // Out of bounds step, fall back to quadratic interpolation: Chris@16: c = quadratic_interpolate(a, b, d, fa, fb, fd, 3); Chris@16: BOOST_MATH_INSTRUMENT_CODE( Chris@16: "Out of bounds interpolation, falling back to quadratic interpolation. c = " << c); Chris@16: } Chris@16: Chris@16: return c; Chris@16: } Chris@16: Chris@16: } // namespace detail Chris@16: Chris@16: template Chris@16: std::pair toms748_solve(F f, const T& ax, const T& bx, const T& fax, const T& fbx, Tol tol, boost::uintmax_t& max_iter, const Policy& pol) Chris@16: { Chris@16: // Chris@16: // Main entry point and logic for Toms Algorithm 748 Chris@16: // root finder. Chris@16: // Chris@16: BOOST_MATH_STD_USING // For ADL of std math functions Chris@16: Chris@16: static const char* function = "boost::math::tools::toms748_solve<%1%>"; Chris@16: Chris@16: boost::uintmax_t count = max_iter; Chris@16: T a, b, fa, fb, c, u, fu, a0, b0, d, fd, e, fe; Chris@16: static const T mu = 0.5f; Chris@16: Chris@16: // initialise a, b and fa, fb: Chris@16: a = ax; Chris@16: b = bx; Chris@16: if(a >= b) Chris@101: return boost::math::detail::pair_from_single(policies::raise_domain_error( Chris@16: function, Chris@101: "Parameters a and b out of order: a=%1%", a, pol)); Chris@16: fa = fax; Chris@16: fb = fbx; Chris@16: Chris@16: if(tol(a, b) || (fa == 0) || (fb == 0)) Chris@16: { Chris@16: max_iter = 0; Chris@16: if(fa == 0) Chris@16: b = a; Chris@16: else if(fb == 0) Chris@16: a = b; Chris@16: return std::make_pair(a, b); Chris@16: } Chris@16: Chris@16: if(boost::math::sign(fa) * boost::math::sign(fb) > 0) Chris@101: return boost::math::detail::pair_from_single(policies::raise_domain_error( Chris@16: function, Chris@101: "Parameters a and b do not bracket the root: a=%1%", a, pol)); Chris@16: // dummy value for fd, e and fe: Chris@16: fe = e = fd = 1e5F; Chris@16: Chris@16: if(fa != 0) Chris@16: { Chris@16: // Chris@16: // On the first step we take a secant step: Chris@16: // Chris@16: c = detail::secant_interpolate(a, b, fa, fb); Chris@16: detail::bracket(f, a, b, c, fa, fb, d, fd); Chris@16: --count; Chris@16: BOOST_MATH_INSTRUMENT_CODE(" a = " << a << " b = " << b); Chris@16: Chris@16: if(count && (fa != 0) && !tol(a, b)) Chris@16: { Chris@16: // Chris@16: // On the second step we take a quadratic interpolation: Chris@16: // Chris@16: c = detail::quadratic_interpolate(a, b, d, fa, fb, fd, 2); Chris@16: e = d; Chris@16: fe = fd; Chris@16: detail::bracket(f, a, b, c, fa, fb, d, fd); Chris@16: --count; Chris@16: BOOST_MATH_INSTRUMENT_CODE(" a = " << a << " b = " << b); Chris@16: } Chris@16: } Chris@16: Chris@16: while(count && (fa != 0) && !tol(a, b)) Chris@16: { Chris@16: // save our brackets: Chris@16: a0 = a; Chris@16: b0 = b; Chris@16: // Chris@16: // Starting with the third step taken Chris@16: // we can use either quadratic or cubic interpolation. Chris@16: // Cubic interpolation requires that all four function values Chris@16: // fa, fb, fd, and fe are distinct, should that not be the case Chris@16: // then variable prof will get set to true, and we'll end up Chris@16: // taking a quadratic step instead. Chris@16: // Chris@16: T min_diff = tools::min_value() * 32; Chris@16: bool prof = (fabs(fa - fb) < min_diff) || (fabs(fa - fd) < min_diff) || (fabs(fa - fe) < min_diff) || (fabs(fb - fd) < min_diff) || (fabs(fb - fe) < min_diff) || (fabs(fd - fe) < min_diff); Chris@16: if(prof) Chris@16: { Chris@16: c = detail::quadratic_interpolate(a, b, d, fa, fb, fd, 2); Chris@16: BOOST_MATH_INSTRUMENT_CODE("Can't take cubic step!!!!"); Chris@16: } Chris@16: else Chris@16: { Chris@16: c = detail::cubic_interpolate(a, b, d, e, fa, fb, fd, fe); Chris@16: } Chris@16: // Chris@16: // re-bracket, and check for termination: Chris@16: // Chris@16: e = d; Chris@16: fe = fd; Chris@16: detail::bracket(f, a, b, c, fa, fb, d, fd); Chris@16: if((0 == --count) || (fa == 0) || tol(a, b)) Chris@16: break; Chris@16: BOOST_MATH_INSTRUMENT_CODE(" a = " << a << " b = " << b); Chris@16: // Chris@16: // Now another interpolated step: Chris@16: // Chris@16: prof = (fabs(fa - fb) < min_diff) || (fabs(fa - fd) < min_diff) || (fabs(fa - fe) < min_diff) || (fabs(fb - fd) < min_diff) || (fabs(fb - fe) < min_diff) || (fabs(fd - fe) < min_diff); Chris@16: if(prof) Chris@16: { Chris@16: c = detail::quadratic_interpolate(a, b, d, fa, fb, fd, 3); Chris@16: BOOST_MATH_INSTRUMENT_CODE("Can't take cubic step!!!!"); Chris@16: } Chris@16: else Chris@16: { Chris@16: c = detail::cubic_interpolate(a, b, d, e, fa, fb, fd, fe); Chris@16: } Chris@16: // Chris@16: // Bracket again, and check termination condition, update e: Chris@16: // Chris@16: detail::bracket(f, a, b, c, fa, fb, d, fd); Chris@16: if((0 == --count) || (fa == 0) || tol(a, b)) Chris@16: break; Chris@16: BOOST_MATH_INSTRUMENT_CODE(" a = " << a << " b = " << b); Chris@16: // Chris@16: // Now we take a double-length secant step: Chris@16: // Chris@16: if(fabs(fa) < fabs(fb)) Chris@16: { Chris@16: u = a; Chris@16: fu = fa; Chris@16: } Chris@16: else Chris@16: { Chris@16: u = b; Chris@16: fu = fb; Chris@16: } Chris@16: c = u - 2 * (fu / (fb - fa)) * (b - a); Chris@16: if(fabs(c - u) > (b - a) / 2) Chris@16: { Chris@16: c = a + (b - a) / 2; Chris@16: } Chris@16: // Chris@16: // Bracket again, and check termination condition: Chris@16: // Chris@16: e = d; Chris@16: fe = fd; Chris@16: detail::bracket(f, a, b, c, fa, fb, d, fd); Chris@16: BOOST_MATH_INSTRUMENT_CODE(" a = " << a << " b = " << b); Chris@16: BOOST_MATH_INSTRUMENT_CODE(" tol = " << T((fabs(a) - fabs(b)) / fabs(a))); Chris@16: if((0 == --count) || (fa == 0) || tol(a, b)) Chris@16: break; Chris@16: // Chris@16: // And finally... check to see if an additional bisection step is Chris@16: // to be taken, we do this if we're not converging fast enough: Chris@16: // Chris@16: if((b - a) < mu * (b0 - a0)) Chris@16: continue; Chris@16: // Chris@16: // bracket again on a bisection: Chris@16: // Chris@16: e = d; Chris@16: fe = fd; Chris@16: detail::bracket(f, a, b, T(a + (b - a) / 2), fa, fb, d, fd); Chris@16: --count; Chris@16: BOOST_MATH_INSTRUMENT_CODE("Not converging: Taking a bisection!!!!"); Chris@16: BOOST_MATH_INSTRUMENT_CODE(" a = " << a << " b = " << b); Chris@16: } // while loop Chris@16: Chris@16: max_iter -= count; Chris@16: if(fa == 0) Chris@16: { Chris@16: b = a; Chris@16: } Chris@16: else if(fb == 0) Chris@16: { Chris@16: a = b; Chris@16: } Chris@101: BOOST_MATH_LOG_COUNT(max_iter) Chris@16: return std::make_pair(a, b); Chris@16: } Chris@16: Chris@16: template Chris@16: inline std::pair toms748_solve(F f, const T& ax, const T& bx, const T& fax, const T& fbx, Tol tol, boost::uintmax_t& max_iter) Chris@16: { Chris@16: return toms748_solve(f, ax, bx, fax, fbx, tol, max_iter, policies::policy<>()); Chris@16: } Chris@16: Chris@16: template Chris@16: inline std::pair toms748_solve(F f, const T& ax, const T& bx, Tol tol, boost::uintmax_t& max_iter, const Policy& pol) Chris@16: { Chris@16: max_iter -= 2; Chris@16: std::pair r = toms748_solve(f, ax, bx, f(ax), f(bx), tol, max_iter, pol); Chris@16: max_iter += 2; Chris@16: return r; Chris@16: } Chris@16: Chris@16: template Chris@16: inline std::pair toms748_solve(F f, const T& ax, const T& bx, Tol tol, boost::uintmax_t& max_iter) Chris@16: { Chris@16: return toms748_solve(f, ax, bx, tol, max_iter, policies::policy<>()); Chris@16: } Chris@16: Chris@16: template Chris@16: std::pair bracket_and_solve_root(F f, const T& guess, T factor, bool rising, Tol tol, boost::uintmax_t& max_iter, const Policy& pol) Chris@16: { Chris@16: BOOST_MATH_STD_USING Chris@16: static const char* function = "boost::math::tools::bracket_and_solve_root<%1%>"; Chris@16: // Chris@16: // Set up inital brackets: Chris@16: // Chris@16: T a = guess; Chris@16: T b = a; Chris@16: T fa = f(a); Chris@16: T fb = fa; Chris@16: // Chris@16: // Set up invocation count: Chris@16: // Chris@16: boost::uintmax_t count = max_iter - 1; Chris@16: Chris@101: int step = 32; Chris@101: Chris@16: if((fa < 0) == (guess < 0 ? !rising : rising)) Chris@16: { Chris@16: // Chris@16: // Zero is to the right of b, so walk upwards Chris@16: // until we find it: Chris@16: // Chris@16: while((boost::math::sign)(fb) == (boost::math::sign)(fa)) Chris@16: { Chris@16: if(count == 0) Chris@101: return boost::math::detail::pair_from_single(policies::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", b, pol)); Chris@16: // Chris@101: // Heuristic: normally it's best not to increase the step sizes as we'll just end up Chris@101: // with a really wide range to search for the root. However, if the initial guess was *really* Chris@101: // bad then we need to speed up the search otherwise we'll take forever if we're orders of Chris@101: // magnitude out. This happens most often if the guess is a small value (say 1) and the result Chris@101: // we're looking for is close to std::numeric_limits::min(). Chris@16: // Chris@101: if((max_iter - count) % step == 0) Chris@101: { Chris@16: factor *= 2; Chris@101: if(step > 1) step /= 2; Chris@101: } Chris@16: // Chris@16: // Now go ahead and move our guess by "factor": Chris@16: // Chris@16: a = b; Chris@16: fa = fb; Chris@16: b *= factor; Chris@16: fb = f(b); Chris@16: --count; Chris@16: BOOST_MATH_INSTRUMENT_CODE("a = " << a << " b = " << b << " fa = " << fa << " fb = " << fb << " count = " << count); Chris@16: } Chris@16: } Chris@16: else Chris@16: { Chris@16: // Chris@16: // Zero is to the left of a, so walk downwards Chris@16: // until we find it: Chris@16: // Chris@16: while((boost::math::sign)(fb) == (boost::math::sign)(fa)) Chris@16: { Chris@16: if(fabs(a) < tools::min_value()) Chris@16: { Chris@16: // Escape route just in case the answer is zero! Chris@16: max_iter -= count; Chris@16: max_iter += 1; Chris@16: return a > 0 ? std::make_pair(T(0), T(a)) : std::make_pair(T(a), T(0)); Chris@16: } Chris@16: if(count == 0) Chris@101: return boost::math::detail::pair_from_single(policies::raise_evaluation_error(function, "Unable to bracket root, last nearest value was %1%", a, pol)); Chris@16: // Chris@101: // Heuristic: normally it's best not to increase the step sizes as we'll just end up Chris@101: // with a really wide range to search for the root. However, if the initial guess was *really* Chris@101: // bad then we need to speed up the search otherwise we'll take forever if we're orders of Chris@101: // magnitude out. This happens most often if the guess is a small value (say 1) and the result Chris@101: // we're looking for is close to std::numeric_limits::min(). Chris@16: // Chris@101: if((max_iter - count) % step == 0) Chris@101: { Chris@16: factor *= 2; Chris@101: if(step > 1) step /= 2; Chris@101: } Chris@16: // Chris@16: // Now go ahead and move are guess by "factor": Chris@16: // Chris@16: b = a; Chris@16: fb = fa; Chris@16: a /= factor; Chris@16: fa = f(a); Chris@16: --count; Chris@16: BOOST_MATH_INSTRUMENT_CODE("a = " << a << " b = " << b << " fa = " << fa << " fb = " << fb << " count = " << count); Chris@16: } Chris@16: } Chris@16: max_iter -= count; Chris@16: max_iter += 1; Chris@16: std::pair r = toms748_solve( Chris@16: f, Chris@16: (a < 0 ? b : a), Chris@16: (a < 0 ? a : b), Chris@16: (a < 0 ? fb : fa), Chris@16: (a < 0 ? fa : fb), Chris@16: tol, Chris@16: count, Chris@16: pol); Chris@16: max_iter += count; Chris@16: BOOST_MATH_INSTRUMENT_CODE("max_iter = " << max_iter << " count = " << count); Chris@101: BOOST_MATH_LOG_COUNT(max_iter) Chris@16: return r; Chris@16: } Chris@16: Chris@16: template Chris@16: inline std::pair bracket_and_solve_root(F f, const T& guess, const T& factor, bool rising, Tol tol, boost::uintmax_t& max_iter) Chris@16: { Chris@16: return bracket_and_solve_root(f, guess, factor, rising, tol, max_iter, policies::policy<>()); Chris@16: } Chris@16: Chris@16: } // namespace tools Chris@16: } // namespace math Chris@16: } // namespace boost Chris@16: Chris@16: Chris@16: #endif // BOOST_MATH_TOOLS_SOLVE_ROOT_HPP Chris@16: