 ROOT   Reference Guide
Searching...
No Matches
ROOT::Math::GSLIntegrator Class Reference

Class for performing numerical integration of a function in one dimension.

It uses the numerical integration algorithms of 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 90 of file GSLIntegrator.h.

## Public Member Functions

GSLIntegrator (const char *type, int rule, double absTol, double relTol, size_t size)
constructor of GSL Integrator.

GSLIntegrator (const Integration::Type type, const Integration::GKRule rule, double absTol=1.E-9, double relTol=1E-6, size_t size=1000)
generic constructor for GSL Integrator

GSLIntegrator (const Integration::Type type, double absTol=1.E-9, double relTol=1E-6, size_t size=1000)
constructor of GSL Integrator.

GSLIntegrator (double absTol=1.E-9, double relTol=1E-6, size_t size=1000)
Default constructor of GSL Integrator for Adaptive Singular integration.

~GSLIntegrator () override

double Error () const override
return the estimate of the absolute Error of the last Integral calculation

IntegrationOneDim::Type GetType () const
get type name

const char * GetTypeName () const
return the name

double Integral () override
evaluate the Integral over the infinite interval (-inf,+inf) using the function previously set with GSLIntegrator::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) override
evaluate the Integral over the defined interval (a,b) using the function previously set with GSLIntegrator::SetFunction method.

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

double Integral (GSLFuncPointer f, void *p)
evaluate the Integral of a function f over the infinite interval (-inf,+inf) passing a free function pointer

double Integral (GSLFuncPointer f, void *p, const std::vector< double > &pts)
evaluate the Integral of a function f with knows singular points over the over a defined interval passing a free function pointer

double Integral (GSLFuncPointer f, void *p, double a, double b)
signature for function pointers used by GSL

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) override
evaluate the Cauchy principal value of the integral of a previously defined 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) override
evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b) using the function previously set with GSLIntegrator::SetFunction method.

double IntegralLow (GSLFuncPointer f, void *p, double b)
evaluate the Integral of a function f over the over the semi-infinite interval (-inf,b) passing a free function pointer

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) override
evaluate the Integral of a function f over the semi-infinite interval (a,+inf) using the function previously set with GSLIntegrator::SetFunction method.

double IntegralUp (GSLFuncPointer f, void *p, double a)
evaluate the Integral of a function f over the semi-infinite interval (a,+inf) passing a free function pointer

int NEval () const override
return number of function evaluations in calculating the integral

ROOT::Math::IntegratorOneDimOptions Options () const override
get the option used for the integration

double Result () const override
return the Result of the last Integral calculation

void SetAbsTolerance (double absTolerance) override
set the desired absolute Error

void SetFunction (const IGenFunction &f) override
method to set the a generic integration function

void SetFunction (GSLFuncPointer f, void *p=nullptr)
Set function from a GSL pointer function type.

void SetIntegrationRule (Integration::GKRule)
set the integration rule (Gauss-Kronrod rule).

void SetOptions (const ROOT::Math::IntegratorOneDimOptions &opt) override
set the options

void SetRelTolerance (double relTolerance) override
set the desired relative Error

int Status () const override
return the Error Status of the last Integral calculation Public Member Functions inherited from ROOT::Math::VirtualIntegratorOneDim
~VirtualIntegratorOneDim () override
destructor: no operation

virtual ROOT::Math::IntegrationOneDim::Type Type () const
return type of integrator Public Member Functions inherited from ROOT::Math::VirtualIntegrator
virtual ~VirtualIntegrator ()
destructor: no operation

## Protected Member Functions

bool CheckFunction ()

## Private Member Functions

GSLIntegrator (const GSLIntegrator &)

GSLIntegratoroperator= (const GSLIntegrator &)

## Private Attributes

double fAbsTol

double fError

GSLFunctionWrapperfFunction

size_t fMaxIntervals

int fNEval

double fRelTol

double fResult

Integration::GKRule fRule

size_t fSize

int fStatus

Integration::Type fType

GSLIntegrationWorkspacefWorkspace

#include <Math/GSLIntegrator.h>

Inheritance diagram for ROOT::Math::GSLIntegrator:
[legend]

## ◆ GSLIntegrator() [1/5]

 ROOT::Math::GSLIntegrator::GSLIntegrator ( double absTol = 1.E-9, double relTol = 1E-6, size_t size = 1000 )

Default constructor of GSL Integrator for Adaptive Singular integration.

Parameters
 absTol desired absolute Error relTol desired relative Error size maximum number of sub-intervals

Definition at line 77 of file GSLIntegrator.cxx.

## ◆ GSLIntegrator() [2/5]

 ROOT::Math::GSLIntegrator::GSLIntegrator ( const Integration::Type type, double absTol = 1.E-9, double relTol = 1E-6, size_t size = 1000 )

constructor of GSL Integrator.

In the case of Adaptive integration the Gauss-Krond rule of 31 points is used

Parameters
 type type of integration. The possible types are defined in the Integration::Type enumeration absTol desired absolute Error relTol desired relative Error size maximum number of sub-intervals

Definition at line 95 of file GSLIntegrator.cxx.

## ◆ GSLIntegrator() [3/5]

 ROOT::Math::GSLIntegrator::GSLIntegrator ( const Integration::Type type, const Integration::GKRule rule, double absTol = 1.E-9, double relTol = 1E-6, size_t size = 1000 )

generic constructor for GSL Integrator

Parameters
 type type of integration. The possible types are defined in the Integration::Type enumeration rule Gauss-Kronrod rule. It is used only for ADAPTIVE::Integration types. The possible rules are defined in the Integration::GKRule enumeration absTol desired absolute Error relTol desired relative Error size maximum number of sub-intervals

Definition at line 56 of file GSLIntegrator.cxx.

## ◆ GSLIntegrator() [4/5]

 ROOT::Math::GSLIntegrator::GSLIntegrator ( const char * type, int rule, double absTol, double relTol, size_t size )

constructor of GSL Integrator.

In the case of Adaptive integration the Gauss-Krond rule of 31 points is used This is used by the plug-in manager (need a char * instead of enumerations)

Parameters
 type type of integration. The possible types are defined in the Integration::Type enumeration rule Gauss-Kronrod rule (from 1 to 6) absTol desired absolute Error relTol desired relative Error size maximum number of sub-intervals

Definition at line 114 of file GSLIntegrator.cxx.

## ◆ ~GSLIntegrator()

 ROOT::Math::GSLIntegrator::~GSLIntegrator ( )
override

Definition at line 151 of file GSLIntegrator.cxx.

## ◆ GSLIntegrator() [5/5]

 ROOT::Math::GSLIntegrator::GSLIntegrator ( const GSLIntegrator & )
private

Definition at line 158 of file GSLIntegrator.cxx.

## ◆ CheckFunction()

 bool ROOT::Math::GSLIntegrator::CheckFunction ( )
protected

Definition at line 408 of file GSLIntegrator.cxx.

## ◆ Error()

 double ROOT::Math::GSLIntegrator::Error ( ) const
overridevirtual

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

Implements ROOT::Math::VirtualIntegrator.

Definition at line 390 of file GSLIntegrator.cxx.

## ◆ GetType()

 IntegrationOneDim::Type ROOT::Math::GSLIntegrator::GetType ( ) const
inline

get type name

Definition at line 362 of file GSLIntegrator.h.

## ◆ GetTypeName()

 const char * ROOT::Math::GSLIntegrator::GetTypeName ( ) const

return the name

Definition at line 459 of file GSLIntegrator.cxx.

## ◆ Integral() [1/9]

 double ROOT::Math::GSLIntegrator::Integral ( )
overridevirtual

evaluate the Integral over the infinite interval (-inf,+inf) using the function previously set with GSLIntegrator::SetFunction method.

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 274 of file GSLIntegrator.cxx.

## ◆ Integral() [2/9]

 double ROOT::Math::GSLIntegrator::Integral ( const IGenFunction & f )

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

Parameters
 f integration function. The function type must implement the mathlib::IGenFunction interface

Definition at line 329 of file GSLIntegrator.cxx.

## ◆ Integral() [3/9]

 double ROOT::Math::GSLIntegrator::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)

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 347 of file GSLIntegrator.cxx.

## ◆ Integral() [4/9]

 double ROOT::Math::GSLIntegrator::Integral ( const IGenFunction & 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 implement the mathlib::IGenFunction interface a lower value of the integration interval b upper value of the integration interval

Definition at line 323 of file GSLIntegrator.cxx.

## ◆ Integral() [5/9]

 double ROOT::Math::GSLIntegrator::Integral ( const std::vector< double > & pts )
overridevirtual

evaluate the Integral over the defined interval (a,b) using the function previously set with GSLIntegrator::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.

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 252 of file GSLIntegrator.cxx.

## ◆ Integral() [6/9]

 double ROOT::Math::GSLIntegrator::Integral ( double a, double b )
overridevirtual

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

Parameters
 a lower value of the integration interval b upper value of the integration interval

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 190 of file GSLIntegrator.cxx.

## ◆ Integral() [7/9]

 double ROOT::Math::GSLIntegrator::Integral ( GSLFuncPointer f, void * p )

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

Definition at line 362 of file GSLIntegrator.cxx.

## ◆ Integral() [8/9]

 double ROOT::Math::GSLIntegrator::Integral ( GSLFuncPointer f, void * p, const std::vector< double > & pts )

evaluate the Integral of a function f with knows singular points over the over a defined interval passing a free function pointer

Definition at line 380 of file GSLIntegrator.cxx.

## ◆ Integral() [9/9]

 double ROOT::Math::GSLIntegrator::Integral ( GSLFuncPointer f, void * p, double a, double b )

signature for function pointers used by GSL

evaluate the Integral of of a function f over the defined interval (a,b) passing a free function pointer The integration function must be a free function and have a signature consistent with GSL functions:

double my_function ( double x, void * p ) { ...... }

This method is the most efficient since no internal adapter to GSL function is created.

Parameters
 f pointer to the integration function p pointer to the Parameters of the function a lower value of the integration interval b upper value of the integration interval

Definition at line 356 of file GSLIntegrator.cxx.

## ◆ IntegralCauchy() [1/2]

 double ROOT::Math::GSLIntegrator::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

Parameters
 f integration function. The function type must implement the mathlib::IGenFunction interface a lower interval value b lower interval value c singular value of f

Definition at line 241 of file GSLIntegrator.cxx.

## ◆ IntegralCauchy() [2/2]

 double ROOT::Math::GSLIntegrator::IntegralCauchy ( double a, double b, double c )
overridevirtual

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

Parameters
 a lower interval value b lower interval value c singular value of f

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 230 of file GSLIntegrator.cxx.

## ◆ IntegralLow() [1/3]

 double ROOT::Math::GSLIntegrator::IntegralLow ( const IGenFunction & f, double b )

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

Parameters
 f integration function. The function type must implement the mathlib::IGenFunction interface b upper value of the integration interval

Definition at line 341 of file GSLIntegrator.cxx.

## ◆ IntegralLow() [2/3]

 double ROOT::Math::GSLIntegrator::IntegralLow ( double b )
overridevirtual

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

Parameters
 b upper value of the integration interval

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 306 of file GSLIntegrator.cxx.

## ◆ IntegralLow() [3/3]

 double ROOT::Math::GSLIntegrator::IntegralLow ( GSLFuncPointer f, void * p, double b )

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

Definition at line 374 of file GSLIntegrator.cxx.

## ◆ IntegralUp() [1/3]

 double ROOT::Math::GSLIntegrator::IntegralUp ( const IGenFunction & f, double a )

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

Parameters
 f integration function. The function type must implement the mathlib::IGenFunction interface a lower value of the integration interval

Definition at line 335 of file GSLIntegrator.cxx.

## ◆ IntegralUp() [2/3]

 double ROOT::Math::GSLIntegrator::IntegralUp ( double a )
overridevirtual

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

Parameters
 a lower value of the integration interval

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 290 of file GSLIntegrator.cxx.

## ◆ IntegralUp() [3/3]

 double ROOT::Math::GSLIntegrator::IntegralUp ( GSLFuncPointer f, void * p, double a )

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

Definition at line 368 of file GSLIntegrator.cxx.

## ◆ NEval()

 int ROOT::Math::GSLIntegrator::NEval ( ) const
inlineoverridevirtual

return number of function evaluations in calculating the integral

Reimplemented from ROOT::Math::VirtualIntegrator.

Definition at line 333 of file GSLIntegrator.h.

## ◆ operator=()

 GSLIntegrator & ROOT::Math::GSLIntegrator::operator= ( const GSLIntegrator & rhs )
private

Definition at line 164 of file GSLIntegrator.cxx.

## ◆ Options()

 ROOT::Math::IntegratorOneDimOptions ROOT::Math::GSLIntegrator::Options ( ) const
overridevirtual

get the option used for the integration

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 442 of file GSLIntegrator.cxx.

## ◆ Result()

 double ROOT::Math::GSLIntegrator::Result ( ) const
overridevirtual

return the Result of the last Integral calculation

Implements ROOT::Math::VirtualIntegrator.

Definition at line 388 of file GSLIntegrator.cxx.

## ◆ SetAbsTolerance()

 void ROOT::Math::GSLIntegrator::SetAbsTolerance ( double absTolerance )
overridevirtual

set the desired absolute Error

Implements ROOT::Math::VirtualIntegrator.

Definition at line 399 of file GSLIntegrator.cxx.

## ◆ SetFunction() [1/2]

 void ROOT::Math::GSLIntegrator::SetFunction ( const IGenFunction & f )
overridevirtual

method to set the a generic integration function

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

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 182 of file GSLIntegrator.cxx.

## ◆ SetFunction() [2/2]

 void ROOT::Math::GSLIntegrator::SetFunction ( GSLFuncPointer f, void * p = nullptr )

Set function from a GSL pointer function type.

Definition at line 175 of file GSLIntegrator.cxx.

## ◆ SetIntegrationRule()

 void ROOT::Math::GSLIntegrator::SetIntegrationRule ( Integration::GKRule rule )

set the integration rule (Gauss-Kronrod rule).

The possible rules are defined in the Integration::GKRule enumeration. The integration rule can be modified only for ADAPTIVE type integrations

Definition at line 406 of file GSLIntegrator.cxx.

## ◆ SetOptions()

 void ROOT::Math::GSLIntegrator::SetOptions ( const ROOT::Math::IntegratorOneDimOptions & opt )
overridevirtual

set the options

Reimplemented from ROOT::Math::VirtualIntegratorOneDim.

Definition at line 416 of file GSLIntegrator.cxx.

## ◆ SetRelTolerance()

 void ROOT::Math::GSLIntegrator::SetRelTolerance ( double relTolerance )
overridevirtual

set the desired relative Error

Implements ROOT::Math::VirtualIntegrator.

Definition at line 403 of file GSLIntegrator.cxx.

## ◆ Status()

 int ROOT::Math::GSLIntegrator::Status ( ) const
overridevirtual

return the Error Status of the last Integral calculation

Implements ROOT::Math::VirtualIntegrator.

Definition at line 392 of file GSLIntegrator.cxx.

## ◆ fAbsTol

 double ROOT::Math::GSLIntegrator::fAbsTol
private

Definition at line 380 of file GSLIntegrator.h.

## ◆ fError

 double ROOT::Math::GSLIntegrator::fError
private

Definition at line 388 of file GSLIntegrator.h.

## ◆ fFunction

 GSLFunctionWrapper* ROOT::Math::GSLIntegrator::fFunction
private

Definition at line 394 of file GSLIntegrator.h.

## ◆ fMaxIntervals

 size_t ROOT::Math::GSLIntegrator::fMaxIntervals
private

Definition at line 383 of file GSLIntegrator.h.

## ◆ fNEval

 int ROOT::Math::GSLIntegrator::fNEval
private

Definition at line 390 of file GSLIntegrator.h.

## ◆ fRelTol

 double ROOT::Math::GSLIntegrator::fRelTol
private

Definition at line 381 of file GSLIntegrator.h.

## ◆ fResult

 double ROOT::Math::GSLIntegrator::fResult
private

Definition at line 387 of file GSLIntegrator.h.

## ◆ fRule

 Integration::GKRule ROOT::Math::GSLIntegrator::fRule
private

Definition at line 379 of file GSLIntegrator.h.

## ◆ fSize

 size_t ROOT::Math::GSLIntegrator::fSize
private

Definition at line 382 of file GSLIntegrator.h.

## ◆ fStatus

 int ROOT::Math::GSLIntegrator::fStatus
private

Definition at line 389 of file GSLIntegrator.h.

## ◆ fType

 Integration::Type ROOT::Math::GSLIntegrator::fType
private

Definition at line 378 of file GSLIntegrator.h.

## ◆ fWorkspace

 GSLIntegrationWorkspace* ROOT::Math::GSLIntegrator::fWorkspace
private

Definition at line 395 of file GSLIntegrator.h.

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

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