#include <zeroin.h>


Public Member Functions | |
| ZeroIn () | |
| void | setLowerBound (const Abscissa &ax) |
| Set the lower bound of the range that will be searched for a solution. | |
| Abscissa | getLowerBound () const |
| void | setUpperBound (const Abscissa &bx) |
| Set the upper bound of the range that will be searched for a solution. | |
| Abscissa | getUpperBound () const |
| void | setTolerance (const Abscissa &tol) |
| set tolerance of the solution | |
| void | setMethod (Ordinate(Subject::*method)(const Abscissa &)) |
| void | visit (Subject *subject) |
| ZeroIn visit method. | |
| bool | isSolved (void) const |
| bool | isSolved (const Ordinate &error) |
| Abscissa | getSolution (void) const |
| Ordinate | getError (void) const |
| ZeroIn< Subject, Ordinate, Abscissa >::ZeroIn | ( | ) | [inline] |
| void ZeroIn< Subject, Ordinate, Abscissa >::setLowerBound | ( | const Abscissa & | ax | ) | [inline] |
Set the lower bound of the range that will be searched for a solution.
Referenced by Region3::set_pT(), SolverBase< Units, OtherProp, Units, 0, OtherPropAlt, 0 >::solve(), SatCurve< Ordinate, Abscissa, OrdinateAlt, AbscissaAlt >::solve(), and B23Curve< Ordinate, Abscissa, OrdinateAlternative, AbscissaAlternative >::solve().
| Abscissa ZeroIn< Subject, Ordinate, Abscissa >::getLowerBound | ( | ) | const [inline] |
| void ZeroIn< Subject, Ordinate, Abscissa >::setUpperBound | ( | const Abscissa & | bx | ) | [inline] |
Set the upper bound of the range that will be searched for a solution.
Referenced by Region3::set_pT(), SolverBase< Units, OtherProp, Units, 0, OtherPropAlt, 0 >::solve(), SatCurve< Ordinate, Abscissa, OrdinateAlt, AbscissaAlt >::solve(), and B23Curve< Ordinate, Abscissa, OrdinateAlternative, AbscissaAlternative >::solve().
| Abscissa ZeroIn< Subject, Ordinate, Abscissa >::getUpperBound | ( | ) | const [inline] |
| void ZeroIn< Subject, Ordinate, Abscissa >::setTolerance | ( | const Abscissa & | tol | ) | [inline] |
| void ZeroIn< Subject, Ordinate, Abscissa >::setMethod | ( | Ordinate(Subject::*)(const Abscissa &) | method | ) | [inline] |
| void ZeroIn< Subject, Ordinate, Abscissa >::visit | ( | Subject * | subject | ) | [inline] |
ZeroIn visit method.
This is a visitor pattern implementation of the Brent ZEROIN routine adapted from the C math library version.
USAGE
function ZEROIN - obtain a function zero within the given range
Input double zeroin(ax,bx,f,tol) double ax; Root will be sought for within a range [ax,bx] double bx;
double (*f)(double x); Name of the function whose zero will be sought for
double tol; Acceptable tolerance for the root value. May be specified as 0.0 to cause the program to find the root as accurate as possible
Output Zeroin returns an estimate for the root with accuracy 4*EPSILON*abs(x) + tol
Algorithm
G.Forsythe, M.Malcolm, C.Moler, Computer methods for mathematical computations. M., Mir, 1980, p.180 of the Russian edition
The function makes use of the bissection procedure combined with the linear or quadric inverse interpolation.
At every step program operates on three abscissae - a, b, and c.
b - the last and the best approximation to the root a - the last but one approximation c - the last but one or even earlier approximation than a that 1) |f(b)| <= |f(c)| 2) f(b) and f(c) have opposite signs, i.e. b and c confine the root
< Distance from the last but one to the last approximation
< Actual tolerance
< Interpolation step is calculated in the form p/q; division
< operations is delayed until the last moment
< Step at this iteration
References DBL_EPSILON, and fabs().
Referenced by Region3::set_pT(), SolverBase< Units, OtherProp, Units, 0, OtherPropAlt, 0 >::solve(), SatCurve< Ordinate, Abscissa, OrdinateAlt, AbscissaAlt >::solve(), and B23Curve< Ordinate, Abscissa, OrdinateAlternative, AbscissaAlternative >::solve().
| bool ZeroIn< Subject, Ordinate, Abscissa >::isSolved | ( | void | ) | const [inline] |
| bool ZeroIn< Subject, Ordinate, Abscissa >::isSolved | ( | const Ordinate & | error | ) | [inline] |
References fabs().
| Abscissa ZeroIn< Subject, Ordinate, Abscissa >::getSolution | ( | void | ) | const [inline] |
| Ordinate ZeroIn< Subject, Ordinate, Abscissa >::getError | ( | void | ) | const [inline] |
1.5.6