Solver1D Class Template Reference#include <ql/solver1d.hpp>
Inheritance diagram for Solver1D:
[legend]List of all members.
Detailed Description
template<class Impl>
class QuantLib::Solver1D< Impl >
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: class Foo : public Solver1D<Foo> {
public:
...
template <class F>
double solveImpl(const F& f, double accuracy) const {
...
}
};
Before calling solveImpl , the base class will set its protected data members so that:
xMin_ and xMax_ form a valid bracket;fxMin_ and fxMax_ contain the values of the function in xMin_ and xMax_ ;root_ is a valid initial guess. The implementation of solveImpl can safely assume all of the above.
- Todo:
- a) Clean up the interface so that it is clear whether the accuracy is specified for x or f(x). b) Add target value (now the target value is 0.0)
|
Public Member Functions |
|
template<class F> double | solve (const F &f, double accuracy, double guess, double step) const |
template<class F> double | solve (const F &f, double accuracy, double guess, double xMin, double xMax) const |
void | setMaxEvaluations (Size evaluations) |
void | setLowerBound (double lowerBound) |
| sets the lower bound for the function domain
|
void | setUpperBound (double upperBound) |
| sets the upper bound for the function domain
|
Protected Attributes |
double | root_ |
double | xMin_ |
double | xMax_ |
double | fxMin_ |
double | fxMax_ |
Size | maxEvaluations_ |
Size | evaluationNumber_ |
Member Function Documentation
double solve |
( |
const F & |
f, |
|
|
double |
accuracy, |
|
|
double |
guess, |
|
|
double |
step |
|
) |
const |
|
double solve |
( |
const F & |
f, |
|
|
double |
accuracy, |
|
|
double |
guess, |
|
|
double |
xMin, |
|
|
double |
xMax |
|
) |
const |
|
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. |
|