User Class to find the Root of one dimensional functions.
The GSL Methods are implemented in MathMore and they are loaded automatically via the plug-in manager
The possible types of Root-finding algorithms are:
This class does not cupport copying
Definition at line 73 of file RootFinder.h.
Public Types | |
enum | EType { kBRENT , kGSL_BISECTION , kGSL_FALSE_POS , kGSL_BRENT , kGSL_NEWTON , kGSL_SECANT , kGSL_STEFFENSON } |
Public Member Functions | |
RootFinder (RootFinder::EType type=RootFinder::kBRENT) | |
Construct a Root-Finder algorithm. | |
virtual | ~RootFinder () |
int | Iterate () |
Perform a single iteration and return the Status. | |
int | Iterations () const |
Return the number of iteration performed to find the Root. | |
const char * | Name () const |
Return the current and latest estimate of the lower value of the Root-finding interval (for bracketing algorithms) | |
double | Root () const |
Return the current and latest estimate of the Root. | |
bool | SetFunction (const IGenFunction &f, double xlow, double xup) |
Provide to the solver the function and the initial search interval [xlow, xup] for algorithms not using derivatives (bracketing algorithms) The templated function f must be of a type implementing the operator() method, double operator() ( double x ) Returns non zero if interval is not valid (i.e. | |
bool | SetFunction (const IGradFunction &f, double xstart) |
Provide to the solver the function and an initial estimate of the root, for algorithms using derivatives. | |
bool | SetMethod (RootFinder::EType type=RootFinder::kBRENT) |
template<class Function , class Derivative > | |
bool | Solve (Function &f, Derivative &d, double start, int maxIter=100, double absTol=1E-8, double relTol=1E-10) |
Solve f(x) = 0 , given a derivative d . | |
template<class Function > | |
bool | Solve (Function &f, double min, double max, int maxIter=100, double absTol=1E-8, double relTol=1E-10) |
Solve f(x) = 0 numerically. | |
bool | Solve (int maxIter=100, double absTol=1E-8, double relTol=1E-10) |
Compute the roots iterating until the estimate of the Root is within the required tolerance returning the iteration Status. | |
int | Status () const |
Return the status of the last estimate of the Root = 0 OK, not zero failure. | |
Private Member Functions | |
RootFinder (const RootFinder &) | |
RootFinder & | operator= (const RootFinder &rhs) |
Private Attributes | |
IRootFinderMethod * | fSolver |
#include <Math/RootFinder.h>
Enumerator | |
---|---|
kBRENT | |
kGSL_BISECTION | |
kGSL_FALSE_POS | |
kGSL_BRENT | |
kGSL_NEWTON | |
kGSL_SECANT | |
kGSL_STEFFENSON |
Definition at line 77 of file RootFinder.h.
ROOT::Math::RootFinder::RootFinder | ( | RootFinder::EType | type = RootFinder::kBRENT | ) |
Construct a Root-Finder algorithm.
Definition at line 40 of file RootFinder.cxx.
|
virtual |
Definition at line 142 of file RootFinder.cxx.
|
inlineprivate |
Definition at line 90 of file RootFinder.h.
|
inline |
Perform a single iteration and return the Status.
Definition at line 153 of file RootFinder.h.
|
inline |
Return the number of iteration performed to find the Root.
Definition at line 146 of file RootFinder.h.
|
inline |
Return the current and latest estimate of the lower value of the Root-finding interval (for bracketing algorithms)
Return the current and latest estimate of the upper value of the Root-finding interval (for bracketing algorithms) Get Name of the Root-finding solver algorithm
Definition at line 190 of file RootFinder.h.
|
inlineprivate |
Definition at line 91 of file RootFinder.h.
|
inline |
Return the current and latest estimate of the Root.
Definition at line 160 of file RootFinder.h.
|
inline |
Provide to the solver the function and the initial search interval [xlow, xup] for algorithms not using derivatives (bracketing algorithms) The templated function f must be of a type implementing the operator() method, double operator() ( double x ) Returns non zero if interval is not valid (i.e.
does not contains a root)
Definition at line 109 of file RootFinder.h.
|
inline |
Provide to the solver the function and an initial estimate of the root, for algorithms using derivatives.
The templated function f must be of a type implementing the operator() and the Gradient() methods. double operator() ( double x ) Returns non zero if starting point is not valid
Definition at line 123 of file RootFinder.h.
bool ROOT::Math::RootFinder::SetMethod | ( | RootFinder::EType | type = RootFinder::kBRENT | ) |
Definition at line 47 of file RootFinder.cxx.
bool ROOT::Math::RootFinder::Solve | ( | Function & | f, |
Derivative & | d, | ||
double | start, | ||
int | maxIter = 100 , |
||
double | absTol = 1E-8 , |
||
double | relTol = 1E-10 |
||
) |
Solve f(x) = 0
, given a derivative d
.
f | Function whose root should be found. |
d | Derivative of the function. |
start | Starting point for iteration. |
maxIter | Maximum number of iterations, passed to Solve(int,double,double) |
absTol | Absolute tolerance, as in Solve(int,double,double) |
relTol | Relative tolerance, passed to Solve(int,double,double) |
Definition at line 224 of file RootFinder.h.
bool ROOT::Math::RootFinder::Solve | ( | Function & | f, |
double | min, | ||
double | max, | ||
int | maxIter = 100 , |
||
double | absTol = 1E-8 , |
||
double | relTol = 1E-10 |
||
) |
Solve f(x) = 0
numerically.
f | Function whose root should be found. |
min | Minimum allowed value of x . |
max | Maximum allowed value of x . |
maxIter | Maximum number of iterations, passed to Solve(int,double,double) |
absTol | Absolute tolerance, as in Solve(int,double,double) |
relTol | Relative tolerance, passed to Solve(int,double,double) |
Definition at line 245 of file RootFinder.h.
|
inline |
Compute the roots iterating until the estimate of the Root is within the required tolerance returning the iteration Status.
Definition at line 139 of file RootFinder.h.
|
inline |
Return the status of the last estimate of the Root = 0 OK, not zero failure.
Definition at line 168 of file RootFinder.h.
|
private |
Definition at line 200 of file RootFinder.h.