Logo ROOT   6.13/01
Reference Guide
List of all members | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ROOT::Math::BrentRootFinder Class Reference

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 IGenFunctionfFunction
 
bool fLogScan
 
int fNIter
 
int fNpx
 
double fRoot
 
int fStatus
 
double fXMax
 
double fXMin
 

#include <Math/BrentRootFinder.h>

Inheritance diagram for ROOT::Math::BrentRootFinder:
[legend]

Constructor & Destructor Documentation

◆ BrentRootFinder()

ROOT::Math::BrentRootFinder::BrentRootFinder ( )

Default Constructor.

Definition at line 25 of file BrentRootFinder.cxx.

◆ ~BrentRootFinder()

virtual ROOT::Math::BrentRootFinder::~BrentRootFinder ( )
inlinevirtual

Default Destructor.

Definition at line 71 of file BrentRootFinder.h.

Member Function Documentation

◆ Iterations()

int ROOT::Math::BrentRootFinder::Iterations ( ) const
inlinevirtual

Return number of iteration used to find minimum.

Reimplemented from ROOT::Math::IRootFinderMethod.

Definition at line 115 of file BrentRootFinder.h.

◆ Name()

const char * ROOT::Math::BrentRootFinder::Name ( ) const
virtual

Return name of root finder algorithm ("BrentRootFinder").

Implements ROOT::Math::IRootFinderMethod.

Definition at line 59 of file BrentRootFinder.cxx.

◆ Root()

double ROOT::Math::BrentRootFinder::Root ( ) const
inlinevirtual

Returns root value.

Need to call first Solve().

Implements ROOT::Math::IRootFinderMethod.

Definition at line 109 of file BrentRootFinder.h.

◆ SetDefaultNpx()

void ROOT::Math::BrentRootFinder::SetDefaultNpx ( int  npx)
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.

◆ SetDefaultNSearch()

void ROOT::Math::BrentRootFinder::SetDefaultNSearch ( int  n)
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.

◆ SetFunction()

bool ROOT::Math::BrentRootFinder::SetFunction ( const ROOT::Math::IGenFunction ,
double  ,
double   
)
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.

◆ SetLogScan()

void ROOT::Math::BrentRootFinder::SetLogScan ( bool  on)
inline

Set a log grid scan (default is equidistant bins) will work only if xlow > 0.

Definition at line 106 of file BrentRootFinder.h.

◆ SetNpx()

void ROOT::Math::BrentRootFinder::SetNpx ( int  npx)
inline

Set the number of point used to bracket root using a grid.

Definition at line 100 of file BrentRootFinder.h.

◆ Solve()

bool ROOT::Math::BrentRootFinder::Solve ( int  maxIter = 100,
double  absTol = 1E-8,
double  relTol = 1E-10 
)
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.

◆ Status()

int ROOT::Math::BrentRootFinder::Status ( ) const
inlinevirtual

Returns status of last estimate.

If = 0 is OK

Implements ROOT::Math::IRootFinderMethod.

Definition at line 112 of file BrentRootFinder.h.

Member Data Documentation

◆ fFunction

const IGenFunction* ROOT::Math::BrentRootFinder::fFunction
private

Definition at line 135 of file BrentRootFinder.h.

◆ fLogScan

bool ROOT::Math::BrentRootFinder::fLogScan
private

Definition at line 136 of file BrentRootFinder.h.

◆ fNIter

int ROOT::Math::BrentRootFinder::fNIter
private

Definition at line 137 of file BrentRootFinder.h.

◆ fNpx

int ROOT::Math::BrentRootFinder::fNpx
private

Definition at line 138 of file BrentRootFinder.h.

◆ fRoot

double ROOT::Math::BrentRootFinder::fRoot
private

Definition at line 142 of file BrentRootFinder.h.

◆ fStatus

int ROOT::Math::BrentRootFinder::fStatus
private

Definition at line 139 of file BrentRootFinder.h.

◆ fXMax

double ROOT::Math::BrentRootFinder::fXMax
private

Definition at line 141 of file BrentRootFinder.h.

◆ fXMin

double ROOT::Math::BrentRootFinder::fXMin
private

Definition at line 140 of file BrentRootFinder.h.

Libraries for ROOT::Math::BrentRootFinder:
[legend]

The documentation for this class was generated from the following files: