 ROOT   Reference Guide 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 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...

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

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>

## ◆ Type

Definition at line 98 of file Integrator.h.

## ◆ 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
 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.

## ◆ 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
 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.

## ◆ 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
 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.

## ◆ ~IntegratorOneDim()

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

destructor (will delete contained pointers)

Definition at line 169 of file Integrator.h.

## ◆ IntegratorOneDim() [4/4]

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

Definition at line 177 of file Integrator.h.

## ◆ 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 412 of file Integrator.h.

## ◆ GetIntegrator()

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

return a pointer to integrator object

Definition at line 442 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 360 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
 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.

## ◆ 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
 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.

## ◆ 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
 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.

## ◆ 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
 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.

## ◆ 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
 a lower value of the integration interval b upper value of the integration interval

Definition at line 351 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
 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.

## ◆ 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
 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.

## ◆ 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
 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.

## ◆ 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 400 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
 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.

## ◆ 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
 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.

## ◆ 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
 b upper value of the integration interval

Definition at line 376 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
 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.

## ◆ 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
 a lower value of the integration interval

Definition at line 368 of file Integrator.h.

## ◆ Name()

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

return name of integrator

Definition at line 455 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 423 of file Integrator.h.

## ◆ operator()()

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

define operator() for IntegralLow

Definition at line 382 of file Integrator.h.

## ◆ operator=()

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

Definition at line 178 of file Integrator.h.

## ◆ Options()

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

retrieve the options

Definition at line 452 of file Integrator.h.

## ◆ Result()

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

return the Result of the last Integral calculation

Definition at line 407 of file Integrator.h.

## ◆ SetAbsTolerance()

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

set the desired absolute Error

Definition at line 437 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 198 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
 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.

## ◆ SetFunction() [3/3]

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

method to set the a generic integration function

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

Definition at line 489 of file Integrator.h.

## ◆ SetOptions()

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

set the options

Definition at line 447 of file Integrator.h.

## ◆ SetRelTolerance()

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

set the desired relative Error

Definition at line 431 of file Integrator.h.

## ◆ Status()

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

return the Error Status of the last Integral calculation

Definition at line 417 of file Integrator.h.

## ◆ fFunc

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

Definition at line 471 of file Integrator.h.

## ◆ fIntegrator

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

Definition at line 470 of file Integrator.h.

Libraries for ROOT::Math::IntegratorOneDim: [legend]

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