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 "HybridSJ": modified Powell's hybrid method as implemented in HYBRJ in MINPACK ROOT::Math::GSLMultiRootFinder::kHybridJ
with name "HybridJ": unscaled version of the previous algorithm ROOT::Math::GSLMultiRootFinder::kNewton
with name "Newton": Newton method ROOT::Math::GSLMultiRootFinder::kGNewton
with name "GNewton": modified Newton method The algorithms without derivatives (see also the GSL documentation ) are the followings:
ROOT::Math::GSLMultiRootFinder::kHybridS
with name "HybridS": same as HybridSJ but using finate difference approximation for the derivatives ROOT::Math::GSLMultiRootFinder::kHybrid
with name "Hybrid": unscaled version of the previous algorithm ROOT::Math::GSLMultiRootFinder::kDNewton
with name "DNewton": discrete Newton algorithm ROOT::Math::GSLMultiRootFinder::kBroyden
with name "Broyden": 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 (const char *name=nullptr) | |
GSLMultiRootFinder (EDerivType type) | |
create a multi-root finder based on an algorithm requiring function derivative | |
GSLMultiRootFinder (EType type) | |
create a multi-root finder based on an algorithm not requiring function derivative | |
virtual | ~GSLMultiRootFinder () |
destructor | |
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 | |
void | Clear () |
clear list of functions | |
unsigned int | Dim () const |
return the number of sunctions set in the class. | |
const double * | Dx () const |
return the last step size | |
const double * | FVal () const |
return the function values f(X) solving the system i.e. | |
int | Iterations () const |
Return number of iterations. | |
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. | |
int | PrintLevel () const |
return the print level | |
void | PrintState (std::ostream &os=std::cout) |
print iteration state | |
template<class FuncIterator > | |
bool | SetFunctionList (FuncIterator begin, FuncIterator end) |
void | SetPrintLevel (int level) |
void | SetType (const char *name) |
set the type using a string | |
void | SetType (EDerivType type) |
set the type of algorithm using derivatives | |
void | SetType (EType type) |
set the type for an algorithm without derivatives | |
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... | |
int | Status () const |
Return the status of last root finding. | |
const double * | X () const |
return the root X values solving the system | |
Static Public Member Functions | |
static void | SetDefaultMaxIterations (int maxiter) |
set maximum number of iterations | |
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 | |
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 = nullptr | ) |
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 194 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 204 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.
Definition at line 219 of file GSLMultiRootFinder.cxx.
|
inline |
Return number of iterations.
Definition at line 229 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 250 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 247 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.
|
inline |
set the type of algorithm using derivatives
Definition at line 154 of file GSLMultiRootFinder.h.
|
inline |
set the type for an algorithm without derivatives
Definition at line 149 of file GSLMultiRootFinder.h.
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 234 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 288 of file GSLMultiRootFinder.h.
|
private |
Definition at line 277 of file GSLMultiRootFinder.h.
|
private |
Definition at line 279 of file GSLMultiRootFinder.h.
|
private |
Definition at line 287 of file GSLMultiRootFinder.h.
|
private |
Definition at line 278 of file GSLMultiRootFinder.h.
|
private |
Definition at line 284 of file GSLMultiRootFinder.h.
|
private |
Definition at line 285 of file GSLMultiRootFinder.h.