ROOT 6.12/07 Reference Guide |
Class for finding the root of a one dimensional function using the Brent algorithm.
It will use the Brent Method for finding function roots in a given interval. First, a grid search is used to bracket the root value with the a step size = (xmax-xmin)/npx. The step size can be controlled via the SetNpx() function. A default value of npx = 100 is used. The default value con be changed using the static method SetDefaultNpx. If the function is unimodal or if its extrema are far apart, setting the fNpx to a small value speeds the algorithm up many times. Then, Brent's method is applied on the bracketed interval. It will use the Brent Method for finding function roots in a given interval. If the Brent method fails to converge the bracketing is repeted on the latest best estimate of the interval. The procedure is repeted with a maximum value (default =10) which can be set for all BrentRootFinder classes with the method SetDefaultNSearch
This class is implemented from TF1::GetX() method.
Definition at line 62 of file BrentRootFinder.h.
Public Member Functions | |
BrentRootFinder () | |
Default Constructor. More... | |
virtual | ~BrentRootFinder () |
Default Destructor. More... | |
int | Iterations () const |
Return number of iteration used to find minimum. More... | |
const char * | Name () const |
Return name of root finder algorithm ("BrentRootFinder"). More... | |
double | Root () const |
Returns root value. More... | |
bool | SetFunction (const ROOT::Math::IGenFunction &f, double xlow, double xup) |
Sets the function for the rest of the algorithms. More... | |
void | SetLogScan (bool on) |
Set a log grid scan (default is equidistant bins) will work only if xlow > 0. More... | |
void | SetNpx (int npx) |
Set the number of point used to bracket root using a grid. More... | |
bool | Solve (int maxIter=100, double absTol=1E-8, double relTol=1E-10) |
Returns the X value corresponding to the function value fy for (xmin<x<xmax). More... | |
int | Status () const |
Returns status of last estimate. More... | |
Public Member Functions inherited from ROOT::Math::IRootFinderMethod | |
IRootFinderMethod () | |
Default Constructor. More... | |
virtual | ~IRootFinderMethod () |
Default Destructor. More... | |
virtual int | Iterate () |
This method is implemented only by the GSLRootFinder and GSLRootFinderDeriv classes and will return an error if it's not one of them. More... | |
virtual bool | SetFunction (const ROOT::Math::IGradFunction &, double) |
Sets the function for algorithms using derivatives. More... | |
Static Public Member Functions | |
static void | SetDefaultNpx (int npx) |
set number of default Npx used at construction time (when SetNpx is not called) Default value is 100 More... | |
static void | SetDefaultNSearch (int n) |
set number of times the bracketing search in combination with is done to find a good interval Default value is 10 More... | |
Private Attributes | |
const IGenFunction * | fFunction |
bool | fLogScan |
int | fNIter |
int | fNpx |
double | fRoot |
int | fStatus |
double | fXMax |
double | fXMin |
#include <Math/BrentRootFinder.h>
ROOT::Math::BrentRootFinder::BrentRootFinder | ( | ) |
Default Constructor.
Definition at line 25 of file BrentRootFinder.cxx.
|
inlinevirtual |
Default Destructor.
Definition at line 71 of file BrentRootFinder.h.
|
inlinevirtual |
Return number of iteration used to find minimum.
Reimplemented from ROOT::Math::IRootFinderMethod.
Definition at line 115 of file BrentRootFinder.h.
|
virtual |
Return name of root finder algorithm ("BrentRootFinder").
Implements ROOT::Math::IRootFinderMethod.
Definition at line 59 of file BrentRootFinder.cxx.
|
inlinevirtual |
Returns root value.
Need to call first Solve().
Implements ROOT::Math::IRootFinderMethod.
Definition at line 109 of file BrentRootFinder.h.
|
static |
set number of default Npx used at construction time (when SetNpx is not called) Default value is 100
Definition at line 34 of file BrentRootFinder.cxx.
|
static |
set number of times the bracketing search in combination with is done to find a good interval Default value is 10
Definition at line 36 of file BrentRootFinder.cxx.
|
virtual |
Sets the function for the rest of the algorithms.
The parameters set the interval where the root has to be calculated.
Reimplemented from ROOT::Math::IRootFinderMethod.
Definition at line 39 of file BrentRootFinder.cxx.
|
inline |
Set a log grid scan (default is equidistant bins) will work only if xlow > 0.
Definition at line 106 of file BrentRootFinder.h.
|
inline |
Set the number of point used to bracket root using a grid.
Definition at line 100 of file BrentRootFinder.h.
|
virtual |
Returns the X value corresponding to the function value fy for (xmin<x<xmax).
Method: First, the grid search is used to bracket the maximum with the step size = (xmax-xmin)/fNpx. This way, the step size can be controlled via the SetNpx() function. If the function is unimodal or if its extrema are far apart, setting the fNpx to a small value speeds the algorithm up many times. Then, Brent's method is applied on the bracketed interval.
@param maxIter maximum number of iterations. @param absTol desired absolute error in the minimum position. @param absTol desired relative error in the minimum position.
Implements ROOT::Math::IRootFinderMethod.
Definition at line 63 of file BrentRootFinder.cxx.
|
inlinevirtual |
Returns status of last estimate.
If = 0 is OK
Implements ROOT::Math::IRootFinderMethod.
Definition at line 112 of file BrentRootFinder.h.
|
private |
Definition at line 135 of file BrentRootFinder.h.
|
private |
Definition at line 136 of file BrentRootFinder.h.
|
private |
Definition at line 137 of file BrentRootFinder.h.
|
private |
Definition at line 138 of file BrentRootFinder.h.
|
private |
Definition at line 142 of file BrentRootFinder.h.
|
private |
Definition at line 139 of file BrentRootFinder.h.
|
private |
Definition at line 141 of file BrentRootFinder.h.
|
private |
Definition at line 140 of file BrentRootFinder.h.