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

User class for performing function integration.

It will use the Gauss Method for function integration in a given interval. This class is implemented from TF1::Integral().

Definition at line 40 of file GaussIntegrator.h.

Public Member Functions

 GaussIntegrator (double absTol=-1, double relTol=-1)
 Default Constructor.
 
 ~GaussIntegrator () override
 Destructor.
 
void AbsValue (bool flag)
 Static function: set the fgAbsValue flag.
 
double Error () const override
 Return the estimate of the absolute Error of the last Integral calculation.
 
double Integral () override
 Returns Integral of function on an infinite interval.
 
double Integral (const std::vector< double > &pts) override
 This method is not implemented.
 
double Integral (double a, double b) override
 Returns Integral of function between a and b.
 
double IntegralCauchy (double a, double b, double c) override
 This method is not implemented.
 
double IntegralLow (double b) override
 Returns Integral of function on a lower semi-infinite interval.
 
double IntegralUp (double a) override
 Returns Integral of function on an upper semi-infinite interval.
 
ROOT::Math::IntegratorOneDimOptions Options () const override
 get the option used for the integration
 
double Result () const override
 Returns the result of the last Integral calculation.
 
void SetAbsTolerance (double eps) override
 This method is not implemented.
 
void SetFunction (const IGenFunction &) override
 Set integration function (flag control if function must be copied inside).
 
void SetOptions (const ROOT::Math::IntegratorOneDimOptions &opt) override
 set the options (should be re-implemented by derived classes -if more options than tolerance exist
 
void SetRelTolerance (double eps) override
 Set the desired relative Error.
 
int Status () const override
 return the status of the last integration - 0 in case of success
 
- 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
 
virtual int NEval () const
 return number of function evaluations in calculating the integral (if integrator do not implement this function returns -1)
 

Protected Attributes

double fEpsAbs
 Absolute error.
 
double fEpsRel
 Relative error.
 
const IGenFunctionfFunction
 Pointer to function used.
 
double fLastError
 Error from the last estimation.
 
double fLastResult
 Result from the last estimation.
 
bool fUsedOnce
 Bool value to check if the function was at least called once.
 

Static Protected Attributes

static bool fgAbsValue = false
 AbsValue used for the calculation of the integral.
 

Private Member Functions

virtual double DoIntegral (double a, double b, const IGenFunction *func)
 Integration surrogate method.
 

#include <Math/GaussIntegrator.h>

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

Constructor & Destructor Documentation

◆ ~GaussIntegrator()

ROOT::Math::GaussIntegrator::~GaussIntegrator ( )
override

Destructor.

Definition at line 44 of file GaussIntegrator.cxx.

◆ GaussIntegrator()

ROOT::Math::GaussIntegrator::GaussIntegrator ( double  absTol = -1,
double  relTol = -1 
)

Default Constructor.

If the tolerance are not given, use default values specified in ROOT::Math::IntegratorOneDimOptions

Definition at line 25 of file GaussIntegrator.cxx.

Member Function Documentation

◆ AbsValue()

void ROOT::Math::GaussIntegrator::AbsValue ( bool  flag)

Static function: set the fgAbsValue flag.

By default TF1::Integral uses the original function value to compute the integral However, TF1::Moment, CentralMoment require to compute the integral using the absolute value of the function.

Definition at line 49 of file GaussIntegrator.cxx.

◆ DoIntegral()

double ROOT::Math::GaussIntegrator::DoIntegral ( double  a,
double  b,
const IGenFunction func 
)
privatevirtual

Integration surrogate method.

Return integral of passed function in interval [a,b] Derived class (like GaussLegendreIntegrator) can re-implement this method to modify to use an improved algorithm

Reimplemented in ROOT::Math::GaussLegendreIntegrator.

Definition at line 71 of file GaussIntegrator.cxx.

◆ Error()

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

Return the estimate of the absolute Error of the last Integral calculation.

Implements ROOT::Math::VirtualIntegrator.

Definition at line 176 of file GaussIntegrator.cxx.

◆ Integral() [1/3]

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

Returns Integral of function on an infinite interval.

This function computes, to an attempted specified accuracy, the value of the integral:

\[ I = \int^{\infty}_{-\infty} f(x)dx \]

Usage: In any arithmetic expression, this function has the approximate value of the integral I.

The integral is mapped onto [0,1] using a transformation then integral computation is surrogated to DoIntegral.

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 56 of file GaussIntegrator.cxx.

◆ Integral() [2/3]

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

This method is not implemented.

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 190 of file GaussIntegrator.cxx.

◆ Integral() [3/3]

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

Returns Integral of function between a and b.

Based on original CERNLIB routine DGAUSS by Sigfried Kolbig converted to C++ by Rene Brun

This function computes, to an attempted specified accuracy, the value of the integral.

Method: For any interval [a,b] we define g8(a,b) and g16(a,b) to be the 8-point and 16-point Gaussian quadrature approximations to

\[ I = \int^{b}_{a} f(x)dx \]

and define

\[ r(a,b) = \frac{\left|g_{16}(a,b)-g_{8}(a,b)\right|}{1+\left|g_{16}(a,b)\right|} \]

Then,

\[ G = \sum_{i=1}^{k}g_{16}(x_{i-1},x_{i}) \]

where, starting with \(x_{0} = A\) and finishing with \(x_{k} = B\), the subdivision points \(x_{i}(i=1,2,...)\) are given by

\[ x_{i} = x_{i-1} + \lambda(B-x_{i-1}) \]

\(\lambda\) is equal to the first member of the sequence 1,1/2,1/4,... for which \(r(x_{i-1}, x_{i}) < EPS\). If, at any stage in the process of subdivision, the ratio

\[ q = \left|\frac{x_{i}-x_{i-1}}{B-A}\right| \]

is so small that 1+0.005q is indistinguishable from 1 to machine accuracy, an error exit occurs with the function value set equal to zero.

Accuracy: The user provides absolute and relative error bounds (epsrel and epsabs) and the algorithm will stop when the estimated error is less than the epsabs OR is less than |I| * epsrel. Unless there is severe cancellation of positive and negative values of f(x) over the interval [A,B], the relative error may be considered as specifying a bound on the relative error of I in the case |I|>1, and a bound on the absolute error in the case |I|<1. More precisely, if k is the number of sub-intervals contributing to the approximation (see Method), and if

\[ I_{abs} = \int^{B}_{A} \left|f(x)\right|dx \]

then the relation

\[ \frac{\left|G-I\right|}{I_{abs}+k} < EPS \]

will nearly always be true, provided the routine terminates without printing an error message. For functions f having no singularities in the closed interval [A,B] the accuracy will usually be much higher than this.

Error handling: The requested accuracy cannot be obtained (see Method). The function value is set equal to zero.

Note 1: Values of the function f(x) at the interval end-points A and B are not required. The subprogram may therefore be used when these values are undefined

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 52 of file GaussIntegrator.cxx.

◆ IntegralCauchy()

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

This method is not implemented.

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 197 of file GaussIntegrator.cxx.

◆ IntegralLow()

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

Returns Integral of function on a lower semi-infinite interval.

This function computes, to an attempted specified accuracy, the value of the integral:

\[ I = \int^{B}_{-\infty} f(x)dx \]

Usage: In any arithmetic expression, this function has the approximate value of the integral I.

  • B: upper end-point of integration interval.

The integral is mapped onto [0,1] using a transformation then integral computation is surrogated to DoIntegral.

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 66 of file GaussIntegrator.cxx.

◆ IntegralUp()

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

Returns Integral of function on an upper semi-infinite interval.

This function computes, to an attempted specified accuracy, the value of the integral:

\[ I = \int^{\infty}_{A} f(x)dx \]

Usage: In any arithmetic expression, this function has the approximate value of the integral I.

  • A: lower end-point of integration interval.

The integral is mapped onto [0,1] using a transformation then integral computation is surrogated to DoIntegral.

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 61 of file GaussIntegrator.cxx.

◆ Options()

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

get the option used for the integration

Implements ROOT::Math::VirtualIntegratorOneDim.

Reimplemented in ROOT::Math::GaussLegendreIntegrator.

Definition at line 210 of file GaussIntegrator.cxx.

◆ Result()

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

Returns the result of the last Integral calculation.

Implements ROOT::Math::VirtualIntegrator.

Definition at line 166 of file GaussIntegrator.cxx.

◆ SetAbsTolerance()

void ROOT::Math::GaussIntegrator::SetAbsTolerance ( double  eps)
inlineoverridevirtual

This method is not implemented.

Implements ROOT::Math::VirtualIntegrator.

Reimplemented in ROOT::Math::GaussLegendreIntegrator.

Definition at line 68 of file GaussIntegrator.h.

◆ SetFunction()

void ROOT::Math::GaussIntegrator::SetFunction ( const IGenFunction function)
overridevirtual

Set integration function (flag control if function must be copied inside).

@param f Function to be used in the calculations.

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 182 of file GaussIntegrator.cxx.

◆ SetOptions()

void ROOT::Math::GaussIntegrator::SetOptions ( const ROOT::Math::IntegratorOneDimOptions opt)
overridevirtual

set the options (should be re-implemented by derived classes -if more options than tolerance exist

Reimplemented from ROOT::Math::VirtualIntegratorOneDim.

Reimplemented in ROOT::Math::GaussLegendreIntegrator.

Definition at line 204 of file GaussIntegrator.cxx.

◆ SetRelTolerance()

void ROOT::Math::GaussIntegrator::SetRelTolerance ( double  eps)
inlineoverridevirtual

Set the desired relative Error.

Implements ROOT::Math::VirtualIntegrator.

Reimplemented in ROOT::Math::GaussLegendreIntegrator.

Definition at line 65 of file GaussIntegrator.h.

◆ Status()

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

return the status of the last integration - 0 in case of success

Implements ROOT::Math::VirtualIntegrator.

Definition at line 179 of file GaussIntegrator.cxx.

Member Data Documentation

◆ fEpsAbs

double ROOT::Math::GaussIntegrator::fEpsAbs
protected

Absolute error.

Definition at line 223 of file GaussIntegrator.h.

◆ fEpsRel

double ROOT::Math::GaussIntegrator::fEpsRel
protected

Relative error.

Definition at line 222 of file GaussIntegrator.h.

◆ fFunction

const IGenFunction* ROOT::Math::GaussIntegrator::fFunction
protected

Pointer to function used.

Definition at line 227 of file GaussIntegrator.h.

◆ fgAbsValue

bool ROOT::Math::GaussIntegrator::fgAbsValue = false
staticprotected

AbsValue used for the calculation of the integral.

Definition at line 221 of file GaussIntegrator.h.

◆ fLastError

double ROOT::Math::GaussIntegrator::fLastError
protected

Error from the last estimation.

Definition at line 226 of file GaussIntegrator.h.

◆ fLastResult

double ROOT::Math::GaussIntegrator::fLastResult
protected

Result from the last estimation.

Definition at line 225 of file GaussIntegrator.h.

◆ fUsedOnce

bool ROOT::Math::GaussIntegrator::fUsedOnce
protected

Bool value to check if the function was at least called once.

Definition at line 224 of file GaussIntegrator.h.

Libraries for ROOT::Math::GaussIntegrator:

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