|
QuantLib: a free/open-source library for quantitative finance
Reference manual - version 1.40
|
Base class for 1-D solvers. More...
#include <ql/math/solver1d.hpp>
Modifiers | |
| Real | root_ |
| Real | xMin_ |
| Real | xMax_ |
| Real | fxMin_ |
| Real | fxMax_ |
| Size | maxEvaluations_ = 100 |
| Size | evaluationNumber_ |
| template<class F> | |
| Real | solve (const F &f, Real accuracy, Real guess, Real step) const |
| template<class F> | |
| Real | solve (const F &f, Real accuracy, Real guess, Real xMin, Real xMax) const |
| void | setMaxEvaluations (Size evaluations) |
| void | setLowerBound (Real lowerBound) |
| sets the lower bound for the function domain | |
| void | setUpperBound (Real upperBound) |
| sets the upper bound for the function domain | |
Additional Inherited Members | |
| Protected Member Functions inherited from CuriouslyRecurringTemplate< Impl > | |
| Impl & | impl () |
| const Impl & | impl () const |
Base class for 1-D solvers.
The implementation of this class uses the so-called "Barton-Nackman trick", also known as "the curiously recurring template pattern". Concrete solvers will be declared as:
Before calling solveImpl, the base class will set its protected data members so that:
| Real solve | ( | const F & | f, |
| Real | accuracy, | ||
| Real | guess, | ||
| Real | step ) const |
This method returns the zero of the function \( f \), determined with the given accuracy \( \epsilon \); depending on the particular solver, this might mean that the returned \( x \) is such that \( |f(x)| < \epsilon \), or that \( |x-\xi| < \epsilon \) where \( \xi \) is the real zero.
This method contains a bracketing routine to which an initial guess must be supplied as well as a step used to scan the range of the possible bracketing values.
| Real solve | ( | const F & | f, |
| Real | accuracy, | ||
| Real | guess, | ||
| Real | xMin, | ||
| Real | xMax ) const |
This method returns the zero of the function \( f \), determined with the given accuracy \( \epsilon \); depending on the particular solver, this might mean that the returned \( x \) is such that \( |f(x)| < \epsilon \), or that \( |x-\xi| < \epsilon \) where \( \xi \) is the real zero.
An initial guess must be supplied, as well as two values \( x_\mathrm{min} \) and \( x_\mathrm{max} \) which must bracket the zero (i.e., either \( f(x_\mathrm{min}) \leq 0 \leq f(x_\mathrm{max}) \), or \(f(x_\mathrm{max}) \leq 0 \leq f(x_\mathrm{min}) \) must be true).
| void setMaxEvaluations | ( | Size | evaluations | ) |
This method sets the maximum number of function evaluations for the bracketing routine. An error is thrown if a bracket is not found after this number of evaluations.