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

Class for adaptive quadrature integration in multi-dimensions using rectangular regions.

Algorithm from A.C. Genz, A.A. Malik, An adaptive algorithm for numerical integration over an N-dimensional rectangular region, J. Comput. Appl. Math. 6 (1980) 295-302.

Converted/adapted by R.Brun to C++ from Fortran CERNLIB routine RADMUL (D120) The new code features many changes compared to the Fortran version.

Control parameters are:

  • \( minpts \): Minimum number of function evaluations requested. Must not exceed maxpts. if minpts < 1 minpts is set to \( 2^n +2n(n+1) +1 \) where n is the function dimension
  • \( maxpts \): Maximum number of function evaluations to be allowed. \( maxpts >= 2^n +2n(n+1) +1 \) if \( maxpts<minpts \), \( maxpts \) is set to \( 10minpts \)
  • \( epstol \), \( epsrel \) : Specified relative and absolute accuracy.

The integral will stop if the relative error is less than relative tolerance OR the absolute error is less than the absolute tolerance

The class computes in addition to the integral of the function in the desired interval:

  • an estimation of the relative accuracy of the result.
  • number of function evaluations performed.
  • status code: 0. Normal exit. . At least minpts and at most maxpts calls to the function were performed.
    1. maxpts is too small for the specified accuracy eps. The result and relerr contain the values obtainable for the specified value of maxpts.
    2. size is too small for the specified number MAXPTS of function evaluations.
    3. n<2 or n>15

Method:

An integration rule of degree seven is used together with a certain strategy of subdivision. For a more detailed description of the method see References.

Notes:

1..Multi-dimensional integration is time-consuming. For each rectangular subregion, the routine requires function evaluations. Careful programming of the integrand might result in substantial saving of time. 2..Numerical integration usually works best for smooth functions. Some analysis or suitable transformations of the integral prior to numerical work may contribute to numerical efficiency.

References:

  1. A.C. Genz and A.A. Malik, Remarks on algorithm 006: An adaptive algorithm for numerical integration over an N-dimensional rectangular region, J. Comput. Appl. Math. 6 (1980) 295-302.
  2. A. van Doren and L. de Ridder, An adaptive algorithm for numerical integration over an n-dimensional cube, J.Comput. Appl. Math. 2 (1976) 207-217.

Definition at line 84 of file AdaptiveIntegratorMultiDim.h.

Public Member Functions

 AdaptiveIntegratorMultiDim (const IMultiGenFunction &f, double absTol=0.0, double relTol=1E-9, unsigned int maxcall=100000, unsigned int size=0)
 Construct with a reference to the integrand function and given optionally tolerance (absolute and relative), maximum number of function evaluation (maxpts) and size of the working array.
 
 AdaptiveIntegratorMultiDim (double absTol=0.0, double relTol=1E-9, unsigned int maxpts=100000, unsigned int size=0)
 Construct given optionally tolerance (absolute and relative), maximum number of function evaluation (maxpts) and size of the working array.
 
 ~AdaptiveIntegratorMultiDim () override
 destructor (no operations)
 
double Error () const override
 return integration error
 
double Integral (const double *xmin, const double *xmax) override
 evaluate the integral with the previously given function between xmin[] and xmax[]
 
double Integral (const IMultiGenFunction &f, const double *xmin, const double *xmax)
 evaluate the integral passing a new function
 
int NEval () const override
 return number of function evaluations in calculating the integral
 
ROOT::Math::IntegratorMultiDimOptions Options () const override
 get the option used for the integration
 
double RelError () const
 return relative error
 
double Result () const override
 return result of integration
 
void SetAbsTolerance (double absTol) override
 set absolute tolerance
 
void SetFunction (const IMultiGenFunction &f) override
 set the integration function (must implement multi-dim function interface: IBaseFunctionMultiDim)
 
void SetMaxPts (unsigned int n)
 set max points
 
void SetMinPts (unsigned int n)
 set min points
 
void SetOptions (const ROOT::Math::IntegratorMultiDimOptions &opt) override
 set the options
 
void SetRelTolerance (double relTol) override
 set relative tolerance
 
void SetSize (unsigned int size)
 set workspace size
 
int Status () const override
 return status of integration
 
- Public Member Functions inherited from ROOT::Math::VirtualIntegratorMultiDim
 ~VirtualIntegratorMultiDim () override
 destructor: no operation
 
virtual ROOT::Math::IntegrationMultiDim::Type Type () const
 return type of integrator
 
- Public Member Functions inherited from ROOT::Math::VirtualIntegrator
virtual ~VirtualIntegrator ()
 destructor: no operation
 

Protected Member Functions

double DoIntegral (const double *xmin, const double *xmax, bool absVal=false)
 

Private Attributes

double fAbsTol
 absolute tolerance
 
unsigned int fDim
 dimensionality of integrand
 
double fError
 integration error
 
const IMultiGenFunctionfFun
 
unsigned int fMaxPts
 maximum number of function evaluation requested
 
unsigned int fMinPts
 minimum number of function evaluation requested
 
int fNEval
 number of function evaluation
 
double fRelError
 Relative error.
 
double fRelTol
 relative tolerance
 
double fResult
 last integration result
 
unsigned int fSize
 max size of working array (explode with dimension)
 
int fStatus
 status of algorithm (error if not zero)
 

#include <Math/AdaptiveIntegratorMultiDim.h>

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

Constructor & Destructor Documentation

◆ AdaptiveIntegratorMultiDim() [1/2]

ROOT::Math::AdaptiveIntegratorMultiDim::AdaptiveIntegratorMultiDim ( double  absTol = 0.0,
double  relTol = 1E-9,
unsigned int  maxpts = 100000,
unsigned int  size = 0 
)
explicit

Construct given optionally tolerance (absolute and relative), maximum number of function evaluation (maxpts) and size of the working array.

The integration will stop when the absolute error is less than the absolute tolerance OR when the relative error is less than the relative tolerance. The absolute tolerance by default is not used (it is equal to zero). The size of working array represents the number of sub-division used for calculating the integral. Higher the dimension, larger sizes are required for getting the same accuracy. The size must be larger than \( (2n + 3) (1 + maxpts/(2^n + 2n(n + 1) + 1))/2) \). For smaller value passed, the minimum allowed will be used

Definition at line 17 of file AdaptiveIntegratorMultiDim.cxx.

◆ AdaptiveIntegratorMultiDim() [2/2]

ROOT::Math::AdaptiveIntegratorMultiDim::AdaptiveIntegratorMultiDim ( const IMultiGenFunction f,
double  absTol = 0.0,
double  relTol = 1E-9,
unsigned int  maxcall = 100000,
unsigned int  size = 0 
)
explicit

Construct with a reference to the integrand function and given optionally tolerance (absolute and relative), maximum number of function evaluation (maxpts) and size of the working array.

Definition at line 37 of file AdaptiveIntegratorMultiDim.cxx.

◆ ~AdaptiveIntegratorMultiDim()

ROOT::Math::AdaptiveIntegratorMultiDim::~AdaptiveIntegratorMultiDim ( )
inlineoverride

destructor (no operations)

Definition at line 113 of file AdaptiveIntegratorMultiDim.h.

Member Function Documentation

◆ DoIntegral()

double ROOT::Math::AdaptiveIntegratorMultiDim::DoIntegral ( const double xmin,
const double xmax,
bool  absVal = false 
)
protected

Definition at line 76 of file AdaptiveIntegratorMultiDim.cxx.

◆ Error()

double ROOT::Math::AdaptiveIntegratorMultiDim::Error ( ) const
inlineoverridevirtual

return integration error

Implements ROOT::Math::VirtualIntegrator.

Definition at line 134 of file AdaptiveIntegratorMultiDim.h.

◆ Integral() [1/2]

double ROOT::Math::AdaptiveIntegratorMultiDim::Integral ( const double xmin,
const double xmax 
)
inlineoverridevirtual

evaluate the integral with the previously given function between xmin[] and xmax[]

Implements ROOT::Math::VirtualIntegratorMultiDim.

Definition at line 119 of file AdaptiveIntegratorMultiDim.h.

◆ Integral() [2/2]

double ROOT::Math::AdaptiveIntegratorMultiDim::Integral ( const IMultiGenFunction f,
const double xmin,
const double xmax 
)

evaluate the integral passing a new function

Definition at line 382 of file AdaptiveIntegratorMultiDim.cxx.

◆ NEval()

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

return number of function evaluations in calculating the integral

Reimplemented from ROOT::Math::VirtualIntegrator.

Definition at line 152 of file AdaptiveIntegratorMultiDim.h.

◆ Options()

ROOT::Math::IntegratorMultiDimOptions ROOT::Math::AdaptiveIntegratorMultiDim::Options ( ) const
overridevirtual

get the option used for the integration

Implements ROOT::Math::VirtualIntegratorMultiDim.

Definition at line 390 of file AdaptiveIntegratorMultiDim.cxx.

◆ RelError()

double ROOT::Math::AdaptiveIntegratorMultiDim::RelError ( ) const
inline

return relative error

Definition at line 137 of file AdaptiveIntegratorMultiDim.h.

◆ Result()

double ROOT::Math::AdaptiveIntegratorMultiDim::Result ( ) const
inlineoverridevirtual

return result of integration

Implements ROOT::Math::VirtualIntegrator.

Definition at line 131 of file AdaptiveIntegratorMultiDim.h.

◆ SetAbsTolerance()

void ROOT::Math::AdaptiveIntegratorMultiDim::SetAbsTolerance ( double  absTol)
overridevirtual

set absolute tolerance

Implements ROOT::Math::VirtualIntegrator.

Definition at line 73 of file AdaptiveIntegratorMultiDim.cxx.

◆ SetFunction()

void ROOT::Math::AdaptiveIntegratorMultiDim::SetFunction ( const IMultiGenFunction f)
overridevirtual

set the integration function (must implement multi-dim function interface: IBaseFunctionMultiDim)

Implements ROOT::Math::VirtualIntegratorMultiDim.

Definition at line 63 of file AdaptiveIntegratorMultiDim.cxx.

◆ SetMaxPts()

void ROOT::Math::AdaptiveIntegratorMultiDim::SetMaxPts ( unsigned int  n)
inline

set max points

Definition at line 167 of file AdaptiveIntegratorMultiDim.h.

◆ SetMinPts()

void ROOT::Math::AdaptiveIntegratorMultiDim::SetMinPts ( unsigned int  n)
inline

set min points

Definition at line 164 of file AdaptiveIntegratorMultiDim.h.

◆ SetOptions()

void ROOT::Math::AdaptiveIntegratorMultiDim::SetOptions ( const ROOT::Math::IntegratorMultiDimOptions opt)
overridevirtual

set the options

Reimplemented from ROOT::Math::VirtualIntegratorMultiDim.

Definition at line 401 of file AdaptiveIntegratorMultiDim.cxx.

◆ SetRelTolerance()

void ROOT::Math::AdaptiveIntegratorMultiDim::SetRelTolerance ( double  relTol)
overridevirtual

set relative tolerance

Implements ROOT::Math::VirtualIntegrator.

Definition at line 70 of file AdaptiveIntegratorMultiDim.cxx.

◆ SetSize()

void ROOT::Math::AdaptiveIntegratorMultiDim::SetSize ( unsigned int  size)
inline

set workspace size

Definition at line 161 of file AdaptiveIntegratorMultiDim.h.

◆ Status()

int ROOT::Math::AdaptiveIntegratorMultiDim::Status ( ) const
inlineoverridevirtual

return status of integration

  • status = 0 successful integration
  • status = 1 MAXPTS is too small for the specified accuracy EPS. The result contain the values obtainable for the specified value of MAXPTS.
  • status = 2 size is too small for the specified number MAXPTS of function evaluations.
  • status = 3 wrong dimension , N<2 or N > 15. Returned result and error are zero

Implements ROOT::Math::VirtualIntegrator.

Definition at line 149 of file AdaptiveIntegratorMultiDim.h.

Member Data Documentation

◆ fAbsTol

double ROOT::Math::AdaptiveIntegratorMultiDim::fAbsTol
private

absolute tolerance

Definition at line 186 of file AdaptiveIntegratorMultiDim.h.

◆ fDim

unsigned int ROOT::Math::AdaptiveIntegratorMultiDim::fDim
private

dimensionality of integrand

Definition at line 182 of file AdaptiveIntegratorMultiDim.h.

◆ fError

double ROOT::Math::AdaptiveIntegratorMultiDim::fError
private

integration error

Definition at line 190 of file AdaptiveIntegratorMultiDim.h.

◆ fFun

const IMultiGenFunction* ROOT::Math::AdaptiveIntegratorMultiDim::fFun
private

Definition at line 195 of file AdaptiveIntegratorMultiDim.h.

◆ fMaxPts

unsigned int ROOT::Math::AdaptiveIntegratorMultiDim::fMaxPts
private

maximum number of function evaluation requested

Definition at line 184 of file AdaptiveIntegratorMultiDim.h.

◆ fMinPts

unsigned int ROOT::Math::AdaptiveIntegratorMultiDim::fMinPts
private

minimum number of function evaluation requested

Definition at line 183 of file AdaptiveIntegratorMultiDim.h.

◆ fNEval

int ROOT::Math::AdaptiveIntegratorMultiDim::fNEval
private

number of function evaluation

Definition at line 192 of file AdaptiveIntegratorMultiDim.h.

◆ fRelError

double ROOT::Math::AdaptiveIntegratorMultiDim::fRelError
private

Relative error.

Definition at line 191 of file AdaptiveIntegratorMultiDim.h.

◆ fRelTol

double ROOT::Math::AdaptiveIntegratorMultiDim::fRelTol
private

relative tolerance

Definition at line 187 of file AdaptiveIntegratorMultiDim.h.

◆ fResult

double ROOT::Math::AdaptiveIntegratorMultiDim::fResult
private

last integration result

Definition at line 189 of file AdaptiveIntegratorMultiDim.h.

◆ fSize

unsigned int ROOT::Math::AdaptiveIntegratorMultiDim::fSize
private

max size of working array (explode with dimension)

Definition at line 185 of file AdaptiveIntegratorMultiDim.h.

◆ fStatus

int ROOT::Math::AdaptiveIntegratorMultiDim::fStatus
private

status of algorithm (error if not zero)

Definition at line 193 of file AdaptiveIntegratorMultiDim.h.

Libraries for ROOT::Math::AdaptiveIntegratorMultiDim:

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