Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT::Math::IntegratorOneDim Class Reference

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
 
VirtualIntegratorOneDimGetIntegrator ()
 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

VirtualIntegratorOneDimCreateIntegrator (IntegrationOneDim::Type type, double absTol, double relTol, unsigned int size, int rule)
 

Private Member Functions

 IntegratorOneDim (const IntegratorOneDim &)
 
IntegratorOneDimoperator= (const IntegratorOneDim &)
 

Private Attributes

IGenFunctionfFunc
 
VirtualIntegratorOneDimfIntegrator
 

#include <Math/Integrator.h>

Member Typedef Documentation

◆ Type

Constructor & Destructor Documentation

◆ IntegratorOneDim() [1/4]

ROOT::Math::IntegratorOneDim::IntegratorOneDim ( IntegrationOneDim::Type  type = IntegrationOneDim::kDEFAULT,
double  absTol = -1,
double  relTol = -1,
unsigned int  size = 0,
unsigned int  rule = 0 
)
inlineexplicit

Constructor of one dimensional Integrator, default type is adaptive.

Parameters
typeintegration type (adaptive, non-adaptive, etc..)
absToldesired absolute Error
relToldesired relative Error
sizemaximum number of sub-intervals
ruleGauss-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.

◆ IntegratorOneDim() [2/4]

ROOT::Math::IntegratorOneDim::IntegratorOneDim ( const IGenFunction f,
IntegrationOneDim::Type  type = IntegrationOneDim::kDEFAULT,
double  absTol = -1,
double  relTol = -1,
unsigned int  size = 0,
int  rule = 0 
)
inlineexplicit

Constructor of one dimensional Integrator passing a function interface.

Parameters
fintegration function (1D interface). It is copied inside
typeintegration type (adaptive, non-adaptive, etc..)
absToldesired absolute tolerance. The algorithm will stop when either the absolute OR the relative tolerance are satisfied.
relToldesired relative tolerance
sizemaximum number of sub-intervals
ruleGauss-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.

◆ IntegratorOneDim() [3/4]

template<class Function >
ROOT::Math::IntegratorOneDim::IntegratorOneDim ( Function f,
IntegrationOneDim::Type  type = IntegrationOneDim::kDEFAULT,
double  absTol = -1,
double  relTol = -1,
unsigned int  size = 0,
int  rule = 0 
)
inlineexplicit

Template Constructor of one dimensional Integrator passing a generic function object.

Parameters
fintegration function (any C++ callable object implementing operator()(double x)
typeintegration type (adaptive, non-adaptive, etc..)
absToldesired absolute tolerance. The algorithm will stop when either the absolute OR the relative tolerance are satisfied.
relToldesired relative tolerance
sizemaximum number of sub-intervals
ruleGauss-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.

◆ ~IntegratorOneDim()

virtual ROOT::Math::IntegratorOneDim::~IntegratorOneDim ( )
inlinevirtual

destructor (will delete contained pointers)

Definition at line 173 of file Integrator.h.

◆ IntegratorOneDim() [4/4]

ROOT::Math::IntegratorOneDim::IntegratorOneDim ( const IntegratorOneDim )
inlineprivate

Definition at line 181 of file Integrator.h.

Member Function Documentation

◆ CreateIntegrator()

VirtualIntegratorOneDim * ROOT::Math::IntegratorOneDim::CreateIntegrator ( IntegrationOneDim::Type  type,
double  absTol,
double  relTol,
unsigned int  size,
int  rule 
)
protected

Definition at line 114 of file Integrator.cxx.

◆ Error()

double ROOT::Math::IntegratorOneDim::Error ( ) const
inline

return the estimate of the absolute Error of the last Integral calculation

Definition at line 416 of file Integrator.h.

◆ GetIntegrator()

VirtualIntegratorOneDim * ROOT::Math::IntegratorOneDim::GetIntegrator ( )
inline

return a pointer to integrator object

Definition at line 446 of file Integrator.h.

◆ GetName()

std::string ROOT::Math::IntegratorOneDim::GetName ( IntegrationOneDim::Type  type)
static

static function to get a string from the enumeration

Definition at line 66 of file Integrator.cxx.

◆ GetType()

IntegrationOneDim::Type ROOT::Math::IntegratorOneDim::GetType ( const char *  name)
static

static function to get the enumeration from a string

Definition at line 53 of file Integrator.cxx.

◆ Integral() [1/8]

double ROOT::Math::IntegratorOneDim::Integral ( )
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.

◆ Integral() [2/8]

double ROOT::Math::IntegratorOneDim::Integral ( const IGenFunction f)
inline

evaluate the Integral of a function f over the infinite interval (-inf,+inf)

Parameters
fintegration 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)
fintegration function. The function type must implement the mathlib::IGenFunction interface

Definition at line 258 of file Integrator.h.

◆ Integral() [3/8]

double ROOT::Math::IntegratorOneDim::Integral ( const IGenFunction f,
const std::vector< double > &  pts 
)
inline

evaluate the Integral of a function f with known singular points over the defined Integral (a,b)

Parameters
fintegration function. The function type must implement the mathlib::IGenFunction interface
ptsvector 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.

◆ Integral() [4/8]

double ROOT::Math::IntegratorOneDim::Integral ( const IGenFunction f,
double  a,
double  b 
)
inline

evaluate the Integral of a function f over the defined interval (a,b)

Parameters
fintegration function. The function type must implement the mathlib::IGenFunction interface
alower value of the integration interval
bupper value of the integration interval

Definition at line 241 of file Integrator.h.

◆ Integral() [5/8]

double ROOT::Math::IntegratorOneDim::Integral ( const std::vector< double > &  pts)
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.

Parameters
ptsvector 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.

◆ Integral() [6/8]

double ROOT::Math::IntegratorOneDim::Integral ( double  a,
double  b 
)
inline

evaluate the Integral over the defined interval (a,b) using the function previously set with Integrator::SetFunction method

Parameters
alower value of the integration interval
bupper value of the integration interval

Definition at line 355 of file Integrator.h.

◆ Integral() [7/8]

template<class Function >
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)

Parameters
fintegration function. The function type must be a C++ callable object implementing operator()(double x)
ptsvector 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.

◆ Integral() [8/8]

template<class Function >
double ROOT::Math::IntegratorOneDim::Integral ( Function f,
double  a,
double  b 
)

evaluate the Integral of a function f over the defined interval (a,b)

Parameters
fintegration function. The function type must be a C++ callable object implementing operator()(double x)
alower value of the integration interval
bupper value of the integration interval

Definition at line 500 of file Integrator.h.

◆ IntegralCauchy() [1/3]

double ROOT::Math::IntegratorOneDim::IntegralCauchy ( const IGenFunction f,
double  a,
double  b,
double  c 
)
inline

evaluate the Cauchy principal value of the integral of a function f over the defined interval (a,b) with a singularity at c

Parameters
fintegration function. The function type must implement the mathlib::IGenFunction interface
alower value of the integration interval
bupper value of the integration interval
cposition of singularity

Definition at line 340 of file Integrator.h.

◆ IntegralCauchy() [2/3]

double ROOT::Math::IntegratorOneDim::IntegralCauchy ( double  a,
double  b,
double  c 
)
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 404 of file Integrator.h.

◆ IntegralCauchy() [3/3]

template<class Function >
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

Parameters
fintegration function. The function type must be a C++ callable object implementing operator()(double x)
alower value of the integration interval
bupper value of the integration interval
cposition of singularity

Definition at line 537 of file Integrator.h.

◆ IntegralLow() [1/2]

double ROOT::Math::IntegratorOneDim::IntegralLow ( const IGenFunction f,
double  b 
)
inline

evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b)

Parameters
fintegration function. The function type must be a C++ callable object implementing operator()(double x)
bupper value of the integration interval evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b)
fintegration function. The function type must implement the mathlib::IGenFunction interface
bupper value of the integration interval

Definition at line 296 of file Integrator.h.

◆ IntegralLow() [2/2]

double ROOT::Math::IntegratorOneDim::IntegralLow ( double  b)
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.

Parameters
bupper value of the integration interval

Definition at line 380 of file Integrator.h.

◆ IntegralUp() [1/2]

double ROOT::Math::IntegratorOneDim::IntegralUp ( const IGenFunction f,
double  a 
)
inline

evaluate the Integral of a function f over the semi-infinite interval (a,+inf)

Parameters
fintegration function. The function type must be a C++ callable object implementing operator()(double x)
alower value of the integration interval evaluate the Integral of a function f over the semi-infinite interval (a,+inf)
fintegration function. The function type must implement the mathlib::IGenFunction interface
alower value of the integration interval

Definition at line 278 of file Integrator.h.

◆ IntegralUp() [2/2]

double ROOT::Math::IntegratorOneDim::IntegralUp ( double  a)
inline

evaluate the Integral of a function f over the semi-infinite interval (a,+inf) using the function previously set with Integrator::SetFunction method.

Parameters
alower value of the integration interval

Definition at line 372 of file Integrator.h.

◆ Name()

std::string ROOT::Math::IntegratorOneDim::Name ( ) const
inline

return name of integrator

Definition at line 459 of file Integrator.h.

◆ NEval()

int ROOT::Math::IntegratorOneDim::NEval ( ) const
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.

◆ operator()()

double ROOT::Math::IntegratorOneDim::operator() ( double  x)
inline

define operator() for IntegralLow

Definition at line 386 of file Integrator.h.

◆ operator=()

IntegratorOneDim & ROOT::Math::IntegratorOneDim::operator= ( const IntegratorOneDim )
inlineprivate

Definition at line 182 of file Integrator.h.

◆ Options()

ROOT::Math::IntegratorOneDimOptions ROOT::Math::IntegratorOneDim::Options ( ) const
inline

retrieve the options

Definition at line 456 of file Integrator.h.

◆ Result()

double ROOT::Math::IntegratorOneDim::Result ( ) const
inline

return the Result of the last Integral calculation

Definition at line 411 of file Integrator.h.

◆ SetAbsTolerance()

void ROOT::Math::IntegratorOneDim::SetAbsTolerance ( double  absTolerance)
inline

set the desired absolute Error

Definition at line 441 of file Integrator.h.

◆ SetFunction() [1/3]

void ROOT::Math::IntegratorOneDim::SetFunction ( const IGenFunction f,
bool  copy = false 
)
inline

set one dimensional function for 1D integration

Definition at line 202 of file Integrator.h.

◆ SetFunction() [2/3]

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

Parameters
fintegration function
icoordindex of coordinate on which the integration is performed
xarray of the passed variables values. In case of dim=1 a 0 can be passed

Definition at line 100 of file Integrator.cxx.

◆ SetFunction() [3/3]

template<class Function >
void ROOT::Math::IntegratorOneDim::SetFunction ( Function f)
inline

method to set the a generic integration function

Parameters
fintegration function. The function type must implement the assigment operator, double operator() ( double x )

Definition at line 493 of file Integrator.h.

◆ SetOptions()

void ROOT::Math::IntegratorOneDim::SetOptions ( const ROOT::Math::IntegratorOneDimOptions opt)
inline

set the options

Definition at line 451 of file Integrator.h.

◆ SetRelTolerance()

void ROOT::Math::IntegratorOneDim::SetRelTolerance ( double  relTolerance)
inline

set the desired relative Error

Definition at line 435 of file Integrator.h.

◆ Status()

int ROOT::Math::IntegratorOneDim::Status ( ) const
inline

return the Error Status of the last Integral calculation

Definition at line 421 of file Integrator.h.

Member Data Documentation

◆ fFunc

IGenFunction* ROOT::Math::IntegratorOneDim::fFunc
private

Definition at line 475 of file Integrator.h.

◆ fIntegrator

VirtualIntegratorOneDim* ROOT::Math::IntegratorOneDim::fIntegrator
private

Definition at line 474 of file Integrator.h.

Libraries for ROOT::Math::IntegratorOneDim:

The documentation for this class was generated from the following files: