ROOT
6.07/01
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 102 of file Integrator.h.
Public Types | |
typedef IntegrationOneDim::Type | Type |
Public Member Functions | |
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... | |
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... | |
virtual | ~IntegratorOneDim () |
destructor (will delete contained pointers) More... | |
template<class Function > | |
void | SetFunction (Function &f) |
method to set the a generic integration function 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 > | |
double | Integral (Function &f, double a, double b) |
evaluate the Integral of a function f over the defined interval (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 IGenFunction &f) |
evaluate the Integral of a function f over the infinite interval (-inf,+inf) More... | |
double | IntegralUp (const IGenFunction &f, double a) |
evaluate the Integral of a function f over the semi-infinite interval (a,+inf) 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... | |
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... | |
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... | |
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 | 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 | Integral (double a, double b) |
evaluate the Integral over the defined interval (a,b) using the function previously set with Integrator::SetFunction method More... | |
double | Integral () |
evaluate the Integral over the infinite interval (-inf,+inf) using the function previously set with Integrator::SetFunction method. 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... | |
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 | operator() (double x) |
define operator() for IntegralLow 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 | 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... | |
double | Result () const |
return the Result of the last Integral calculation More... | |
double | Error () const |
return the estimate of the absolute Error of the last Integral calculation More... | |
int | Status () const |
return the Error Status of the last Integral calculation More... | |
int | NEval () const |
return number of function evaluations in calculating the integral (if integrator do not implement this function returns -1) More... | |
void | SetRelTolerance (double relTolerance) |
set the desired relative Error More... | |
void | SetAbsTolerance (double absTolerance) |
set the desired absolute Error More... | |
VirtualIntegratorOneDim * | GetIntegrator () |
return a pointer to integrator object More... | |
void | SetOptions (const ROOT::Math::IntegratorOneDimOptions &opt) |
set the options More... | |
ROOT::Math::IntegratorOneDimOptions | Options () const |
retrieve the options More... | |
std::string | Name () const |
return name of integrator More... | |
Static Public Member Functions | |
static IntegrationOneDim::Type | GetType (const char *name) |
static function to get the enumeration from a string More... | |
static std::string | GetName (IntegrationOneDim::Type) |
static function to get a string from the enumeration 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 | |
VirtualIntegratorOneDim * | fIntegrator |
IGenFunction * | fFunc |
#include <Math/Integrator.h>
Definition at line 106 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 127 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 146 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 169 of file Integrator.h.
|
inlinevirtual |
destructor (will delete contained pointers)
Definition at line 177 of file Integrator.h.
|
inlineprivate |
Definition at line 185 of file Integrator.h.
|
protected |
Definition at line 115 of file Integrator.cxx.
Referenced by IntegratorOneDim().
|
inline |
return the estimate of the absolute Error of the last Integral calculation
Definition at line 420 of file Integrator.h.
Referenced by TF1::IntegralOneDim(), and testIntegration().
|
inline |
return a pointer to integrator object
Definition at line 450 of file Integrator.h.
|
static |
static function to get a string from the enumeration
Definition at line 67 of file Integrator.cxx.
Referenced by CreateIntegrator(), ROOT::Math::IntegratorOneDimOptions::DefaultIntegrator(), TF1::IntegralOneDim(), and ROOT::Math::IntegratorOneDimOptions::Integrator().
|
static |
static function to get the enumeration from a string
Definition at line 54 of file Integrator.cxx.
Referenced by GetName(), ROOT::Math::IntegratorOneDimOptions::SetDefaultIntegrator(), and ROOT::Math::IntegratorOneDimOptions::SetIntegrator().
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 506 of file Integrator.h.
Referenced by TUnuranContDist::Cdf(), TKDE::ComputeKernelIntegral(), TKDE::ComputeKernelL2Norm(), TKDE::ComputeKernelMu(), TKDE::ComputeKernelSigma2(), TF1Convolution::EvalNumConv(), TF1::IntegralOneDim(), Integration(), testAnalyticalIntegrals(), testIntegPerf(), testIntegration(), and testIntegration1D().
|
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 245 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 262 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 536 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 320 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 359 of file Integrator.h.
|
inline |
evaluate the Integral over the infinite interval (-inf,+inf) using the function previously set with Integrator::SetFunction method.
Definition at line 368 of file Integrator.h.
Referenced by Integral().
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 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 543 of file Integrator.h.
Referenced by IntegralCauchy().
|
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 344 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 408 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 300 of file Integrator.h.
Referenced by TF1Convolution::EvalNumConv(), TF1::IntegralOneDim(), and operator()().
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 384 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 282 of file Integrator.h.
Referenced by TF1Convolution::EvalNumConv(), and TF1::IntegralOneDim().
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 376 of file Integrator.h.
|
inline |
return name of integrator
Definition at line 463 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 431 of file Integrator.h.
define operator() for IntegralLow
Definition at line 390 of file Integrator.h.
|
inlineprivate |
Definition at line 186 of file Integrator.h.
|
inline |
|
inline |
return the Result of the last Integral calculation
Definition at line 415 of file Integrator.h.
set the desired absolute Error
Definition at line 445 of file Integrator.h.
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 499 of file Integrator.h.
Referenced by TKDE::ComputeKernelIntegral(), TKDE::ComputeKernelL2Norm(), TKDE::ComputeKernelMu(), TKDE::ComputeKernelSigma2(), Integral(), IntegralCauchy(), IntegralLow(), IntegralUp(), IntegratorOneDim(), SetFunction(), testAnalyticalIntegrals(), testIntegPerf(), testIntegration(), and testIntegration1D().
|
inline |
set one dimensional function for 1D integration
Definition at line 206 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 101 of file Integrator.cxx.
|
inline |
set the options
Definition at line 455 of file Integrator.h.
set the desired relative Error
Definition at line 439 of file Integrator.h.
|
inline |
return the Error Status of the last Integral calculation
Definition at line 425 of file Integrator.h.
Referenced by TF1::IntegralOneDim().
|
private |
Definition at line 479 of file Integrator.h.
Referenced by SetFunction(), and ~IntegratorOneDim().
|
private |
Definition at line 478 of file Integrator.h.
Referenced by Error(), GetIntegrator(), Integral(), IntegralCauchy(), IntegralLow(), IntegralUp(), IntegratorOneDim(), Name(), NEval(), Options(), Result(), SetAbsTolerance(), SetFunction(), SetOptions(), SetRelTolerance(), Status(), and ~IntegratorOneDim().