24#ifndef quantlib_solver1d_brent_h
25#define quantlib_solver1d_brent_h
41 Real xAccuracy)
const {
50 Real froot, p,
q,
r,
s, xAcc1, xMid;
68 if ((froot > 0.0 &&
fxMax_ > 0.0) ||
69 (froot < 0.0 &&
fxMax_ < 0.0)) {
76 if (std::fabs(
fxMax_) < std::fabs(froot)) {
87 if (std::fabs(xMid) <= xAcc1 || (
close(froot, 0.0))) {
92 if (std::fabs(e) >= xAcc1 &&
93 std::fabs(
fxMin_) > std::fabs(froot)) {
104 q=(
q-1.0)*(
r-1.0)*(
s-1.0);
108 min1=3.0*xMid*
q-std::fabs(xAcc1*
q);
110 if (2.0*p < (min1 < min2 ? min1 : min2)) {
124 if (std::fabs(
d) > xAcc1)
131 QL_FAIL(
"maximum number of function evaluations ("
136 return b >= 0.0 ?
Real(std::fabs(a)) :
Real(-std::fabs(a));
Real sign(Real a, Real b) const
Real solveImpl(const F &f, Real xAccuracy) const
Base class for 1-D solvers.
#define QL_FAIL(message)
throw an error (possibly with file and line information)
ext::function< Real(Real)> b
bool close(const Quantity &m1, const Quantity &m2, Size n)
ext::shared_ptr< YieldTermStructure > q
ext::shared_ptr< YieldTermStructure > r
Abstract 1-D solver class.