ROOT   6.21/01 Reference Guide
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 39 of file GaussIntegrator.h.

## Public Member Functions

GaussIntegrator (double absTol=-1, double relTol=-1)
Default Constructor. More...

virtual ~GaussIntegrator ()
Destructor. More...

void AbsValue (bool flag)
Static function: set the fgAbsValue flag. More...

double Error () const
Return the estimate of the absolute Error of the last Integral calculation. More...

double Integral (double a, double b)

Returns Integral of function between a and b. More...

double Integral ()
Returns Integral of function on an infinite interval. More...

double Integral (const std::vector< double > &pts)
This method is not implemented. More...

double IntegralCauchy (double a, double b, double c)
This method is not implemented. More...

double IntegralLow (double b)
Returns Integral of function on a lower semi-infinite interval. More...

double IntegralUp (double a)
Returns Integral of function on an upper semi-infinite interval. More...

virtual ROOT::Math::IntegratorOneDimOptions Options () const
get the option used for the integration More...

double Result () const
Returns the result of the last Integral calculation. More...

virtual void SetAbsTolerance (double eps)
This method is not implemented. More...

void SetFunction (const IGenFunction &)
Set integration function (flag control if function must be copied inside). More...

virtual void SetOptions (const ROOT::Math::IntegratorOneDimOptions &opt)
set the options (should be re-implemented by derived classes -if more options than tolerance exist More...

virtual void SetRelTolerance (double eps)
Set the desired relative Error. More...

int Status () const
return the status of the last integration - 0 in case of success More...

Public Member Functions inherited from ROOT::Math::VirtualIntegratorOneDim
virtual ~VirtualIntegratorOneDim ()
destructor: no operation More...

virtual ROOT::Math::IntegrationOneDim::Type Type () const

Public Member Functions inherited from ROOT::Math::VirtualIntegrator
virtual ~VirtualIntegrator ()

virtual int NEval () const
return number of function evaluations in calculating the integral (if integrator do not implement this function returns -1) More...

## Protected Attributes

double fEpsAbs

double fEpsRel

const IGenFunctionfFunction

double fLastError

double fLastResult

bool fUsedOnce

## Static Protected Attributes

static bool fgAbsValue = false

## Private Member Functions

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

#include <Math/GaussIntegrator.h>

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

## ◆ ~GaussIntegrator()

 ROOT::Math::GaussIntegrator::~GaussIntegrator ( )
virtual

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.

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

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 ( double a, double b )
virtual

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.

## ◆ Integral() [2/3]

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

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() [3/3]

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

This method is not implemented.

Implements ROOT::Math::VirtualIntegratorOneDim.

Definition at line 190 of file GaussIntegrator.cxx.

## ◆ IntegralCauchy()

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

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 )
virtual

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 )
virtual

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
virtual

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
virtual

Returns the result of the last Integral calculation.

Implements ROOT::Math::VirtualIntegrator.

Definition at line 166 of file GaussIntegrator.cxx.

## ◆ SetAbsTolerance()

 virtual void ROOT::Math::GaussIntegrator::SetAbsTolerance ( double eps )
inlinevirtual

This method is not implemented.

Implements ROOT::Math::VirtualIntegrator.

Reimplemented in ROOT::Math::GaussLegendreIntegrator.

Definition at line 67 of file GaussIntegrator.h.

## ◆ SetFunction()

 void ROOT::Math::GaussIntegrator::SetFunction ( const IGenFunction & function )
virtual

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 )
virtual

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

 virtual void ROOT::Math::GaussIntegrator::SetRelTolerance ( double eps )
inlinevirtual

Set the desired relative Error.

Implements ROOT::Math::VirtualIntegrator.

Reimplemented in ROOT::Math::GaussLegendreIntegrator.

Definition at line 64 of file GaussIntegrator.h.

## ◆ Status()

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

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

Implements ROOT::Math::VirtualIntegrator.

Definition at line 179 of file GaussIntegrator.cxx.

## ◆ fEpsAbs

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

Definition at line 222 of file GaussIntegrator.h.

## ◆ fEpsRel

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

Definition at line 221 of file GaussIntegrator.h.

## ◆ fFunction

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

Definition at line 226 of file GaussIntegrator.h.

## ◆ fgAbsValue

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

Definition at line 220 of file GaussIntegrator.h.

## ◆ fLastError

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

Definition at line 225 of file GaussIntegrator.h.

## ◆ fLastResult

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

Definition at line 224 of file GaussIntegrator.h.

## ◆ fUsedOnce

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

Definition at line 223 of file GaussIntegrator.h.

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

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