ROOT 6.18/05 Reference Guide |
User Class for performing numerical integration of a function in one dimension.
It uses the plug-in manager to load advanced numerical integration algorithms from GSL, which reimplements the algorithms used in the QUADPACK, a numerical integration package written in Fortran.
Various types of adaptive and non-adaptive integration are supported. These include integration over infinite and semi-infinite ranges and singular integrals.
The integration type is selected using the Integration::type enumeration in the class constructor. The default type is adaptive integration with singularity (ADAPTIVESINGULAR or QAGS in the QUADPACK convention) applying a Gauss-Kronrod 21-point integration rule. In the case of ADAPTIVE type, the integration rule can also be specified via the Integration::GKRule. The default rule is 31 points.
In the case of integration over infinite and semi-infinite ranges, the type used is always ADAPTIVESINGULAR applying a transformation from the original interval into (0,1).
The ADAPTIVESINGULAR type is the most sophicticated type. When performances are important, it is then recommened to use the NONADAPTIVE type in case of smooth functions or ADAPTIVE with a lower Gauss-Kronrod rule.
For detailed description on GSL integration algorithms see the GSL Manual.
Definition at line 94 of file Integrator.h.
Public Types | |
typedef IntegrationOneDim::Type | Type |
Public Member Functions | |
IntegratorOneDim (const IGenFunction &f, IntegrationOneDim::Type type=IntegrationOneDim::kDEFAULT, double absTol=-1, double relTol=-1, unsigned int size=0, int rule=0) | |
Constructor of one dimensional Integrator passing a function interface. More... | |
template<class Function > | |
IntegratorOneDim (Function &f, IntegrationOneDim::Type type=IntegrationOneDim::kDEFAULT, double absTol=-1, double relTol=-1, unsigned int size=0, int rule=0) | |
Template Constructor of one dimensional Integrator passing a generic function object. More... | |
IntegratorOneDim (IntegrationOneDim::Type type=IntegrationOneDim::kDEFAULT, double absTol=-1, double relTol=-1, unsigned int size=0, unsigned int rule=0) | |
Constructor of one dimensional Integrator, default type is adaptive. More... | |
virtual | ~IntegratorOneDim () |
destructor (will delete contained pointers) More... | |
double | Error () const |
return the estimate of the absolute Error of the last Integral calculation More... | |
VirtualIntegratorOneDim * | GetIntegrator () |
return a pointer to integrator object More... | |
double | Integral () |
evaluate the Integral over the infinite interval (-inf,+inf) using the function previously set with Integrator::SetFunction method. More... | |
double | Integral (const IGenFunction &f) |
evaluate the Integral of a function f over the infinite interval (-inf,+inf) More... | |
double | Integral (const IGenFunction &f, const std::vector< double > &pts) |
evaluate the Integral of a function f with known singular points over the defined Integral (a,b) More... | |
double | Integral (const IGenFunction &f, double a, double b) |
evaluate the Integral of a function f over the defined interval (a,b) More... | |
double | Integral (const std::vector< double > &pts) |
evaluate the Integral over the defined interval (a,b) using the function previously set with Integrator::SetFunction method. More... | |
double | Integral (double a, double b) |
evaluate the Integral over the defined interval (a,b) using the function previously set with Integrator::SetFunction method More... | |
template<class Function > | |
double | Integral (Function &f, const std::vector< double > &pts) |
evaluate the Integral of a function f with known singular points over the defined Integral (a,b) More... | |
template<class Function > | |
double | Integral (Function &f, double a, double b) |
evaluate the Integral of a function f over the defined interval (a,b) More... | |
double | IntegralCauchy (const IGenFunction &f, double a, double b, double c) |
evaluate the Cauchy principal value of the integral of a function f over the defined interval (a,b) with a singularity at c More... | |
double | IntegralCauchy (double a, double b, double c) |
evaluate the Cauchy principal value of the integral of a function f over the defined interval (a,b) with a singularity at c More... | |
template<class Function > | |
double | IntegralCauchy (Function &f, double a, double b, double c) |
evaluate the Cauchy principal value of the integral of a function f over the defined interval (a,b) with a singularity at c More... | |
double | IntegralLow (const IGenFunction &f, double b) |
evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b) More... | |
double | IntegralLow (double b) |
evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b) using the function previously set with Integrator::SetFunction method. More... | |
double | IntegralUp (const IGenFunction &f, double a) |
evaluate the Integral of a function f over the semi-infinite interval (a,+inf) More... | |
double | IntegralUp (double a) |
evaluate the Integral of a function f over the semi-infinite interval (a,+inf) using the function previously set with Integrator::SetFunction method. More... | |
std::string | Name () const |
return name of integrator More... | |
int | NEval () const |
return number of function evaluations in calculating the integral (if integrator do not implement this function returns -1) More... | |
double | operator() (double x) |
define operator() for IntegralLow More... | |
ROOT::Math::IntegratorOneDimOptions | Options () const |
retrieve the options More... | |
double | Result () const |
return the Result of the last Integral calculation More... | |
void | SetAbsTolerance (double absTolerance) |
set the desired absolute Error More... | |
void | SetFunction (const IGenFunction &f, bool copy=false) |
set one dimensional function for 1D integration More... | |
void | SetFunction (const IMultiGenFunction &f, unsigned int icoord, const double *x) |
Set integration function from a multi-dim function type. More... | |
template<class Function > | |
void | SetFunction (Function &f) |
method to set the a generic integration function More... | |
void | SetOptions (const ROOT::Math::IntegratorOneDimOptions &opt) |
set the options More... | |
void | SetRelTolerance (double relTolerance) |
set the desired relative Error More... | |
int | Status () const |
return the Error Status of the last Integral calculation More... | |
Static Public Member Functions | |
static std::string | GetName (IntegrationOneDim::Type) |
static function to get a string from the enumeration More... | |
static IntegrationOneDim::Type | GetType (const char *name) |
static function to get the enumeration from a string More... | |
Protected Member Functions | |
VirtualIntegratorOneDim * | CreateIntegrator (IntegrationOneDim::Type type, double absTol, double relTol, unsigned int size, int rule) |
Private Member Functions | |
IntegratorOneDim (const IntegratorOneDim &) | |
IntegratorOneDim & | operator= (const IntegratorOneDim &) |
Private Attributes | |
IGenFunction * | fFunc |
VirtualIntegratorOneDim * | fIntegrator |
#include <Math/Integrator.h>
Definition at line 98 of file Integrator.h.
|
inlineexplicit |
Constructor of one dimensional Integrator, default type is adaptive.
type | integration type (adaptive, non-adaptive, etc..) |
absTol | desired absolute Error |
relTol | desired relative Error |
size | maximum number of sub-intervals |
rule | Gauss-Kronrod integration rule (only for GSL kADAPTIVE type) |
Possible type values are : kGAUSS (simple Gauss method), kADAPTIVE (from GSL), kADAPTIVESINGULAR (from GSL), kNONADAPTIVE (from GSL) Possible rule values are kGAUS15 (rule = 1), kGAUS21( rule = 2), kGAUS31(rule =3), kGAUS41 (rule=4), kGAUS51 (rule =5), kGAUS61(rule =6) lower rules are indicated for singular functions while higher for smooth functions to get better accuracies
NOTE: When the default values are passed, the values used are taken from the default defined in ROOT::Math::IntegratorOneDimOptions
Definition at line 119 of file Integrator.h.
|
inlineexplicit |
Constructor of one dimensional Integrator passing a function interface.
f | integration function (1D interface). It is copied inside |
type | integration type (adaptive, non-adaptive, etc..) |
absTol | desired absolute tolerance. The algorithm will stop when either the absolute OR the relative tolerance are satisfied. |
relTol | desired relative tolerance |
size | maximum number of sub-intervals |
rule | Gauss-Kronrod integration rule (only for GSL ADAPTIVE type) |
NOTE: When no values are passed, the values used are taken from the default defined in ROOT::Math::IntegratorOneDimOptions
Definition at line 138 of file Integrator.h.
|
inlineexplicit |
Template Constructor of one dimensional Integrator passing a generic function object.
f | integration function (any C++ callable object implementing operator()(double x) |
type | integration type (adaptive, non-adaptive, etc..) |
absTol | desired absolute tolerance. The algorithm will stop when either the absolute OR the relative tolerance are satisfied. |
relTol | desired relative tolerance |
size | maximum number of sub-intervals |
rule | Gauss-Kronrod integration rule (only for GSL ADAPTIVE type) |
NOTE: When no values are passed, the values used are taken from the default defined in ROOT::Math::IntegratorOneDimOptions
Definition at line 161 of file Integrator.h.
|
inlinevirtual |
destructor (will delete contained pointers)
Definition at line 169 of file Integrator.h.
|
inlineprivate |
Definition at line 177 of file Integrator.h.
|
protected |
Definition at line 114 of file Integrator.cxx.
|
inline |
return the estimate of the absolute Error of the last Integral calculation
Definition at line 412 of file Integrator.h.
|
inline |
return a pointer to integrator object
Definition at line 442 of file Integrator.h.
|
static |
static function to get a string from the enumeration
Definition at line 66 of file Integrator.cxx.
|
static |
static function to get the enumeration from a string
Definition at line 53 of file Integrator.cxx.
|
inline |
evaluate the Integral over the infinite interval (-inf,+inf) using the function previously set with Integrator::SetFunction method.
Definition at line 360 of file Integrator.h.
|
inline |
evaluate the Integral of a function f over the infinite interval (-inf,+inf)
f | integration function. The function type must be a C++ callable object implementing operator()(double x) evaluate the Integral of a function f over the infinite interval (-inf,+inf) |
f | integration function. The function type must implement the mathlib::IGenFunction interface |
Definition at line 254 of file Integrator.h.
|
inline |
evaluate the Integral of a function f with known singular points over the defined Integral (a,b)
f | integration function. The function type must implement the mathlib::IGenFunction interface |
pts | vector containing both the function singular points and the lower/upper edges of the interval. The vector must have as first element the lower edge of the integration Integral ( a) and last element the upper value. |
Definition at line 312 of file Integrator.h.
|
inline |
evaluate the Integral of a function f over the defined interval (a,b)
f | integration function. The function type must implement the mathlib::IGenFunction interface |
a | lower value of the integration interval |
b | upper value of the integration interval |
Definition at line 237 of file Integrator.h.
|
inline |
evaluate the Integral over the defined interval (a,b) using the function previously set with Integrator::SetFunction method.
The function has known singular points.
pts | vector containing both the function singular points and the lower/upper edges of the interval. The vector must have as first element the lower edge of the integration Integral ( a) and last element the upper value. |
Definition at line 392 of file Integrator.h.
|
inline |
evaluate the Integral over the defined interval (a,b) using the function previously set with Integrator::SetFunction method
a | lower value of the integration interval |
b | upper value of the integration interval |
Definition at line 351 of file Integrator.h.
double ROOT::Math::IntegratorOneDim::Integral | ( | Function & | f, |
const std::vector< double > & | pts | ||
) |
evaluate the Integral of a function f with known singular points over the defined Integral (a,b)
f | integration function. The function type must be a C++ callable object implementing operator()(double x) |
pts | vector containing both the function singular points and the lower/upper edges of the interval. The vector must have as first element the lower edge of the integration Integral ( a) and last element the upper value. |
Definition at line 526 of file Integrator.h.
double ROOT::Math::IntegratorOneDim::Integral | ( | Function & | f, |
double | a, | ||
double | b | ||
) |
evaluate the Integral of a function f over the defined interval (a,b)
f | integration function. The function type must be a C++ callable object implementing operator()(double x) |
a | lower value of the integration interval |
b | upper value of the integration interval |
Definition at line 496 of file Integrator.h.
|
inline |
evaluate the Cauchy principal value of the integral of a function f over the defined interval (a,b) with a singularity at c
f | integration function. The function type must implement the mathlib::IGenFunction interface |
a | lower value of the integration interval |
b | upper value of the integration interval |
c | position of singularity |
Definition at line 336 of file Integrator.h.
|
inline |
evaluate the Cauchy principal value of the integral of a function f over the defined interval (a,b) with a singularity at c
Definition at line 400 of file Integrator.h.
double ROOT::Math::IntegratorOneDim::IntegralCauchy | ( | Function & | f, |
double | a, | ||
double | b, | ||
double | c | ||
) |
evaluate the Cauchy principal value of the integral of a function f over the defined interval (a,b) with a singularity at c
f | integration function. The function type must be a C++ callable object implementing operator()(double x) |
a | lower value of the integration interval |
b | upper value of the integration interval |
c | position of singularity |
Definition at line 533 of file Integrator.h.
|
inline |
evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b)
f | integration function. The function type must be a C++ callable object implementing operator()(double x) |
b | upper value of the integration interval evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b) |
f | integration function. The function type must implement the mathlib::IGenFunction interface |
b | upper value of the integration interval |
Definition at line 292 of file Integrator.h.
|
inline |
evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b) using the function previously set with Integrator::SetFunction method.
b | upper value of the integration interval |
Definition at line 376 of file Integrator.h.
|
inline |
evaluate the Integral of a function f over the semi-infinite interval (a,+inf)
f | integration function. The function type must be a C++ callable object implementing operator()(double x) |
a | lower value of the integration interval evaluate the Integral of a function f over the semi-infinite interval (a,+inf) |
f | integration function. The function type must implement the mathlib::IGenFunction interface |
a | lower value of the integration interval |
Definition at line 274 of file Integrator.h.
|
inline |
evaluate the Integral of a function f over the semi-infinite interval (a,+inf) using the function previously set with Integrator::SetFunction method.
a | lower value of the integration interval |
Definition at line 368 of file Integrator.h.
|
inline |
return name of integrator
Definition at line 455 of file Integrator.h.
|
inline |
return number of function evaluations in calculating the integral (if integrator do not implement this function returns -1)
Definition at line 423 of file Integrator.h.
|
inline |
define operator() for IntegralLow
Definition at line 382 of file Integrator.h.
|
inlineprivate |
Definition at line 178 of file Integrator.h.
|
inline |
retrieve the options
Definition at line 452 of file Integrator.h.
|
inline |
return the Result of the last Integral calculation
Definition at line 407 of file Integrator.h.
|
inline |
set the desired absolute Error
Definition at line 437 of file Integrator.h.
|
inline |
set one dimensional function for 1D integration
Definition at line 198 of file Integrator.h.
void ROOT::Math::IntegratorOneDim::SetFunction | ( | const IMultiGenFunction & | f, |
unsigned int | icoord, | ||
const double * | x | ||
) |
Set integration function from a multi-dim function type.
Can be used in case of having 1D function implementing the generic interface
f | integration function |
icoord | index of coordinate on which the integration is performed |
x | array of the passed variables values. In case of dim=1 a 0 can be passed |
Definition at line 100 of file Integrator.cxx.
method to set the a generic integration function
f | integration function. The function type must implement the assigment operator, double operator() ( double x ) |
Definition at line 489 of file Integrator.h.
|
inline |
set the options
Definition at line 447 of file Integrator.h.
|
inline |
set the desired relative Error
Definition at line 431 of file Integrator.h.
|
inline |
return the Error Status of the last Integral calculation
Definition at line 417 of file Integrator.h.
|
private |
Definition at line 471 of file Integrator.h.
|
private |
Definition at line 470 of file Integrator.h.