ROOT 6.12/07 Reference Guide |
Class for Multidimensional root finding algorithms bassed on GSL.
This class is used to solve a non-linear system of equations:
f1(x1,....xn) = 0 f2(x1,....xn) = 0 .................. fn(x1,....xn) = 0
See the GSL online manual for information on the GSL MultiRoot finding algorithms
The available GSL algorithms require the derivatives of the supplied functions or not (they are computed internally by GSL). In the first case the user needs to provide a list of multidimensional functions implementing the gradient interface (ROOT::Math::IMultiGradFunction) while in the second case it is enough to supply a list of functions impelmenting the ROOT::Math::IMultiGenFunction interface. The available algorithms requiring derivatives (see also the GSL documentation ) are the followings:
ROOT::Math::GSLMultiRootFinder::kHybridSJ
with name <it>"HybridSJ"</it>: modified Powell's hybrid method as implemented in HYBRJ in MINPACK ROOT::Math::GSLMultiRootFinder::kHybridJ
with name <it>"HybridJ"</it>: unscaled version of the previous algorithm ROOT::Math::GSLMultiRootFinder::kNewton
with name <it>"Newton"</it>: Newton method ROOT::Math::GSLMultiRootFinder::kGNewton
with name <it>"GNewton"</it>: modified Newton method The algorithms without derivatives (see also the GSL documentation ) are the followings:
ROOT::Math::GSLMultiRootFinder::kHybridS
with name <it>"HybridS"</it>: same as HybridSJ but using finate difference approximation for the derivatives ROOT::Math::GSLMultiRootFinder::kHybrid
with name <it>"Hybrid"</it>: unscaled version of the previous algorithm ROOT::Math::GSLMultiRootFinder::kDNewton
with name <it>"DNewton"</it>: discrete Newton algorithm ROOT::Math::GSLMultiRootFinder::kBroyden
with name <it>"Broyden"</it>: Broyden algorithm Definition at line 95 of file GSLMultiRootFinder.h.
Public Types | |
enum | EDerivType { kHybridSJ, kHybridJ, kNewton, kGNewton } |
enumeration specifying the types of GSL multi root finders requiring the derivatives More... | |
enum | EType { kHybridS, kHybrid, kDNewton, kBroyden } |
enumeration specifying the types of GSL multi root finders which do not require the derivatives More... | |
Public Member Functions | |
GSLMultiRootFinder (EType type) | |
create a multi-root finder based on an algorithm not requiring function derivative More... | |
GSLMultiRootFinder (EDerivType type) | |
create a multi-root finder based on an algorithm requiring function derivative More... | |
GSLMultiRootFinder (const char *name=0) | |
virtual | ~GSLMultiRootFinder () |
destructor More... | |
int | AddFunction (const ROOT::Math::IMultiGenFunction &func) |
template<class Function > | |
int | AddFunction (Function &f, int ndim) |
same method as before but using any function implementing the operator(), so can be wrapped in a IMultiGenFunction interface More... | |
void | Clear () |
clear list of functions More... | |
unsigned int | Dim () const |
return the number of sunctions set in the class. More... | |
const double * | Dx () const |
return the last step size More... | |
const double * | FVal () const |
return the function values f(X) solving the system i.e. More... | |
int | Iterations () const |
Return number of iterations. More... | |
const char * | Name () const |
Return the algorithm name used for solving Note the name is available only after having called solved Otherwise an empyty string is returned. More... | |
int | PrintLevel () const |
return the print level More... | |
void | PrintState (std::ostream &os=std::cout) |
print iteration state More... | |
template<class FuncIterator > | |
bool | SetFunctionList (FuncIterator begin, FuncIterator end) |
void | SetPrintLevel (int level) |
void | SetType (EType type) |
set the type for an algorithm without derivatives More... | |
void | SetType (EDerivType type) |
set the type of algorithm using derivatives More... | |
void | SetType (const char *name) |
set the type using a string More... | |
bool | Solve (const double *x, int maxIter=0, double absTol=0, double relTol=0) |
Find the root starting from the point X; Use the number of iteration and tolerance if given otherwise use default parameter values which can be defined by the static method SetDefault... More... | |
int | Status () const |
Return the status of last root finding. More... | |
const double * | X () const |
return the root X values solving the system More... | |
Static Public Member Functions | |
static void | SetDefaultMaxIterations (int maxiter) |
set maximum number of iterations More... | |
static void | SetDefaultTolerance (double abstol, double reltol=0) |
set tolerance (absolute and relative) relative tolerance is only use to verify the convergence do it is a minor parameter More... | |
Protected Member Functions | |
void | ClearFunctions () |
std::pair< bool, int > | GetType (const char *name) |
Private Member Functions | |
GSLMultiRootFinder (const GSLMultiRootFinder &) | |
GSLMultiRootFinder & | operator= (const GSLMultiRootFinder &) |
Private Attributes | |
std::vector< ROOT::Math::IMultiGenFunction * > | fFunctions |
int | fIter |
int | fPrintLevel |
GSLMultiRootBaseSolver * | fSolver |
int | fStatus |
int | fType |
bool | fUseDerivAlgo |
#include <Math/GSLMultiRootFinder.h>
enumeration specifying the types of GSL multi root finders requiring the derivatives
Enumerator | |
---|---|
kHybridSJ | |
kHybridJ | |
kNewton | |
kGNewton |
Definition at line 104 of file GSLMultiRootFinder.h.
enumeration specifying the types of GSL multi root finders which do not require the derivatives
Enumerator | |
---|---|
kHybridS | |
kHybrid | |
kDNewton | |
kBroyden |
Definition at line 115 of file GSLMultiRootFinder.h.
ROOT::Math::GSLMultiRootFinder::GSLMultiRootFinder | ( | EType | type | ) |
create a multi-root finder based on an algorithm not requiring function derivative
Definition at line 67 of file GSLMultiRootFinder.cxx.
ROOT::Math::GSLMultiRootFinder::GSLMultiRootFinder | ( | EDerivType | type | ) |
create a multi-root finder based on an algorithm requiring function derivative
Definition at line 76 of file GSLMultiRootFinder.cxx.
ROOT::Math::GSLMultiRootFinder::GSLMultiRootFinder | ( | const char * | name = 0 | ) |
Definition at line 85 of file GSLMultiRootFinder.cxx.
|
virtual |
destructor
Definition at line 95 of file GSLMultiRootFinder.cxx.
|
private |
Definition at line 102 of file GSLMultiRootFinder.cxx.
int ROOT::Math::GSLMultiRootFinder::AddFunction | ( | const ROOT::Math::IMultiGenFunction & | func | ) |
Definition at line 122 of file GSLMultiRootFinder.cxx.
|
inline |
same method as before but using any function implementing the operator(), so can be wrapped in a IMultiGenFunction interface
Definition at line 192 of file GSLMultiRootFinder.h.
void ROOT::Math::GSLMultiRootFinder::Clear | ( | ) |
clear list of functions
Definition at line 139 of file GSLMultiRootFinder.cxx.
|
protected |
Definition at line 130 of file GSLMultiRootFinder.cxx.
|
inline |
return the number of sunctions set in the class.
The number must be equal to the dimension of the functions
Definition at line 202 of file GSLMultiRootFinder.h.
const double * ROOT::Math::GSLMultiRootFinder::Dx | ( | ) | const |
return the last step size
Definition at line 151 of file GSLMultiRootFinder.cxx.
const double * ROOT::Math::GSLMultiRootFinder::FVal | ( | ) | const |
return the function values f(X) solving the system i.e.
they must be close to zero at the solution
Definition at line 155 of file GSLMultiRootFinder.cxx.
|
protected |
Definition at line 219 of file GSLMultiRootFinder.cxx.
|
inline |
Return number of iterations.
Definition at line 227 of file GSLMultiRootFinder.h.
const char * ROOT::Math::GSLMultiRootFinder::Name | ( | ) | const |
Return the algorithm name used for solving Note the name is available only after having called solved Otherwise an empyty string is returned.
Definition at line 159 of file GSLMultiRootFinder.cxx.
|
private |
Definition at line 106 of file GSLMultiRootFinder.cxx.
|
inline |
return the print level
Definition at line 248 of file GSLMultiRootFinder.h.
void ROOT::Math::GSLMultiRootFinder::PrintState | ( | std::ostream & | os = std::cout | ) |
print iteration state
Definition at line 333 of file GSLMultiRootFinder.cxx.
|
static |
set maximum number of iterations
Definition at line 62 of file GSLMultiRootFinder.cxx.
|
static |
set tolerance (absolute and relative) relative tolerance is only use to verify the convergence do it is a minor parameter
Definition at line 57 of file GSLMultiRootFinder.cxx.
|
inline |
Definition at line 171 of file GSLMultiRootFinder.h.
|
inline |
Definition at line 245 of file GSLMultiRootFinder.h.
set the type for an algorithm without derivatives
Definition at line 149 of file GSLMultiRootFinder.h.
|
inline |
set the type of algorithm using derivatives
Definition at line 154 of file GSLMultiRootFinder.h.
void ROOT::Math::GSLMultiRootFinder::SetType | ( | const char * | name | ) |
set the type using a string
Definition at line 114 of file GSLMultiRootFinder.cxx.
bool ROOT::Math::GSLMultiRootFinder::Solve | ( | const double * | x, |
int | maxIter = 0 , |
||
double | absTol = 0 , |
||
double | relTol = 0 |
||
) |
Find the root starting from the point X; Use the number of iteration and tolerance if given otherwise use default parameter values which can be defined by the static method SetDefault...
Definition at line 236 of file GSLMultiRootFinder.cxx.
|
inline |
Return the status of last root finding.
Definition at line 232 of file GSLMultiRootFinder.h.
const double * ROOT::Math::GSLMultiRootFinder::X | ( | ) | const |
return the root X values solving the system
Definition at line 147 of file GSLMultiRootFinder.cxx.
|
private |
Definition at line 286 of file GSLMultiRootFinder.h.
|
private |
Definition at line 275 of file GSLMultiRootFinder.h.
|
private |
Definition at line 277 of file GSLMultiRootFinder.h.
|
private |
Definition at line 285 of file GSLMultiRootFinder.h.
|
private |
Definition at line 276 of file GSLMultiRootFinder.h.
|
private |
Definition at line 282 of file GSLMultiRootFinder.h.
|
private |
Definition at line 283 of file GSLMultiRootFinder.h.