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 98 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. | |
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. | |
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. | |
virtual | ~IntegratorOneDim () |
destructor (will delete contained pointers) | |
double | Error () const |
return the estimate of the absolute Error of the last Integral calculation | |
VirtualIntegratorOneDim * | GetIntegrator () |
return a pointer to integrator object | |
double | Integral () |
evaluate the Integral over the infinite interval (-inf,+inf) using the function previously set with Integrator::SetFunction method. | |
double | Integral (const IGenFunction &f) |
evaluate the Integral of a function f over the infinite interval (-inf,+inf) | |
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) | |
double | Integral (const IGenFunction &f, double a, double b) |
evaluate the Integral of a function f over the defined interval (a,b) | |
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. | |
double | Integral (double a, double b) |
evaluate the Integral over the defined interval (a,b) using the function previously set with Integrator::SetFunction method | |
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) | |
template<class Function > | |
double | Integral (Function &f, double a, double b) |
evaluate the Integral of a function f over the defined interval (a,b) | |
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 | |
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 | |
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 | |
double | IntegralLow (const IGenFunction &f, double b) |
evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b) | |
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. | |
double | IntegralUp (const IGenFunction &f, double a) |
evaluate the Integral of a function f over the semi-infinite interval (a,+inf) | |
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. | |
std::string | Name () const |
return name of integrator | |
int | NEval () const |
return number of function evaluations in calculating the integral (if integrator do not implement this function returns -1) | |
double | operator() (double x) |
define operator() for IntegralLow | |
ROOT::Math::IntegratorOneDimOptions | Options () const |
retrieve the options | |
double | Result () const |
return the Result of the last Integral calculation | |
void | SetAbsTolerance (double absTolerance) |
set the desired absolute Error | |
void | SetFunction (const IGenFunction &f, bool copy=false) |
set one dimensional function for 1D integration | |
void | SetFunction (const IMultiGenFunction &f, unsigned int icoord, const double *x) |
Set integration function from a multi-dim function type. | |
template<class Function > | |
void | SetFunction (Function &f) |
method to set the a generic integration function | |
void | SetOptions (const ROOT::Math::IntegratorOneDimOptions &opt) |
set the options | |
void | SetRelTolerance (double relTolerance) |
set the desired relative Error | |
int | Status () const |
return the Error Status of the last Integral calculation | |
Static Public Member Functions | |
static std::string | GetName (IntegrationOneDim::Type) |
static function to get a string from the enumeration | |
static IntegrationOneDim::Type | GetType (const char *name) |
static function to get the enumeration from a string | |
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 102 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 123 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 142 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 165 of file Integrator.h.
|
inlinevirtual |
destructor (will delete contained pointers)
Definition at line 173 of file Integrator.h.
|
inlineprivate |
Definition at line 181 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 416 of file Integrator.h.
|
inline |
return a pointer to integrator object
Definition at line 446 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 364 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 258 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 316 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 241 of file Integrator.h.
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 396 of file Integrator.h.
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 355 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 530 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 500 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 340 of file Integrator.h.
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 404 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 537 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 296 of file Integrator.h.
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 380 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 278 of file Integrator.h.
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 372 of file Integrator.h.
|
inline |
return name of integrator
Definition at line 459 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 427 of file Integrator.h.
define operator() for IntegralLow
Definition at line 386 of file Integrator.h.
|
inlineprivate |
Definition at line 182 of file Integrator.h.
|
inline |
retrieve the options
Definition at line 456 of file Integrator.h.
|
inline |
return the Result of the last Integral calculation
Definition at line 411 of file Integrator.h.
set the desired absolute Error
Definition at line 441 of file Integrator.h.
|
inline |
set one dimensional function for 1D integration
Definition at line 202 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 493 of file Integrator.h.
|
inline |
set the options
Definition at line 451 of file Integrator.h.
set the desired relative Error
Definition at line 435 of file Integrator.h.
|
inline |
return the Error Status of the last Integral calculation
Definition at line 421 of file Integrator.h.
|
private |
Definition at line 475 of file Integrator.h.
|
private |
Definition at line 474 of file Integrator.h.