24#ifndef quantlib_solver1d_hpp
25#define quantlib_solver1d_hpp
36 #define MAX_FUNCTION_EVALUATIONS 100
90 "accuracy (" << accuracy <<
") must be positive");
94 const Real growthFactor = 1.6;
122 return this->
impl().solveImpl(f, accuracy);
130 }
else if (flipflop == -1) {
135 }
else if (flipflop == 1) {
144 <<
" function evaluations (last bracket attempt: "
170 "accuracy (" << accuracy <<
") must be positive");
178 "invalid range: xMin_ (" <<
xMin_
179 <<
") >= xMax_ (" <<
xMax_ <<
")");
182 <<
") < enforced low bound (" <<
lowerBound_ <<
")");
185 <<
") > enforced hi bound (" <<
upperBound_ <<
")");
198 "root not bracketed: f["
204 "guess (" << guess <<
") < xMin_ (" <<
xMin_ <<
")");
206 "guess (" << guess <<
") > xMax_ (" <<
xMax_ <<
")");
210 return this->
impl().solveImpl(f, accuracy);
239 maxEvaluations_ = evaluations;
244 lowerBound_ = lowerBound;
245 lowerBoundEnforced_ =
true;
250 upperBound_ = upperBound;
251 upperBoundEnforced_ =
true;
256 if (lowerBoundEnforced_ && x < lowerBound_)
258 if (upperBoundEnforced_ && x > upperBound_)
Support for the curiously recurring template pattern.
Base class for 1-D solvers.
Real enforceBounds_(Real x) const
void setMaxEvaluations(Size evaluations)
void setLowerBound(Real lowerBound)
sets the lower bound for the function domain
Real solve(const F &f, Real accuracy, Real guess, Real step) const
void setUpperBound(Real upperBound)
sets the upper bound for the function domain
Real solve(const F &f, Real accuracy, Real guess, Real xMin, Real xMax) const
floating-point comparisons
Curiously recurring template pattern.
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
bool close(const Quantity &m1, const Quantity &m2, Size n)
#define MAX_FUNCTION_EVALUATIONS