User class for performing function integration.
It will use the Gauss-Legendre Method for function integration in a given interval. This class is implemented from TF1::Integral().
Definition at line 37 of file GaussLegendreIntegrator.h.
Public Member Functions | |
| GaussLegendreIntegrator (int num=10, double eps=1e-12) | |
| Basic constructor of GaussLegendreIntegrator. | |
| ~GaussLegendreIntegrator () override | |
| Default 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. | |
| int | GetNumberPoints () const |
| void | GetWeightVectors (double *x, double *w) const |
| Returns the arrays x and w containing the abscissa and weight of the Gauss-Legendre n-point quadrature formula. | |
| 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. | |
| int | NEval () const override |
| return number of function evaluations in calculating the integral This is equivalent to the number of points | |
| 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) override |
| This method is not implemented. | |
| void | SetFunction (const IGenFunction &) override |
| Set integration function (flag control if function must be copied inside). | |
| void | SetNumberPoints (int num) |
| Set the number of points used in the calculation of the integral. | |
| 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) override |
| Set the desired relative Error. | |
| int | Status () const override |
| return the status of the last integration - 0 in case of success | |
| virtual ROOT::Math::IntegrationOneDim::Type | Type () const |
| return type of integrator | |
Protected Attributes | |
| double | fEpsAbs |
| Absolute error. | |
| double | fEpsRel |
| Relative error. | |
| const IGenFunction * | fFunction |
| Pointer to function used. | |
| double | fLastError |
| Error from the last estimation. | |
| double | fLastResult |
| Result from the last estimation. | |
| int | fNum |
| Number of points used in the estimation of the integral. | |
| bool | fUsedOnce |
| Bool value to check if the function was at least called once. | |
| double * | fW |
| Weights of the points used. | |
| double * | fX |
| Abscisa of the points used. | |
Static Protected Attributes | |
| static bool | fgAbsValue = false |
| AbsValue used for the calculation of the integral. | |
Private Member Functions | |
| void | CalcGaussLegendreSamplingPoints () |
| Type: unsafe but fast interface filling the arrays x and w (static method). | |
| double | DoIntegral (double a, double b, const IGenFunction *func) override |
| Integration surrogate method. | |
#include <Math/GaussLegendreIntegrator.h>
Basic constructor of GaussLegendreIntegrator.
@param num Number of desired points to calculate the integration. @param eps Desired relative error.
Definition at line 23 of file GaussLegendreIntegrator.cxx.
|
override |
Default Destructor.
Definition at line 34 of file GaussLegendreIntegrator.cxx.
|
inherited |
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.
|
private |
Type: unsafe but fast interface filling the arrays x and w (static method).
Given the number of sampling points this routine fills the arrays x and w of length num, containing the abscissa and weight of the Gauss-Legendre n-point quadrature formula.
Gauss-Legendre: W(x)=1 -1<x<1 (j+1)P_{j+1} = (2j+1)xP_j-jP_{j-1}
num is the number of sampling points (>0) x and w are arrays of size num eps is the relative precision
If num<=0 or eps<=0 no action is done.
Reference: Numerical Recipes in C, Second Edition
Definition at line 98 of file GaussLegendreIntegrator.cxx.
|
overrideprivatevirtual |
Integration surrogate method.
Return integral of passed function in interval [a,b] Reimplement method of GaussIntegrator using CalcGaussLegendreSamplingPoints
Reimplemented from ROOT::Math::GaussIntegrator.
Definition at line 60 of file GaussLegendreIntegrator.cxx.
|
overridevirtualinherited |
Return the estimate of the absolute Error of the last Integral calculation.
Implements ROOT::Math::VirtualIntegrator.
Definition at line 176 of file GaussIntegrator.cxx.
|
inline |
Definition at line 68 of file GaussLegendreIntegrator.h.
Returns the arrays x and w containing the abscissa and weight of the Gauss-Legendre n-point quadrature formula.
Gauss-Legendre: W(x)=1 -1<x<1 (j+1)P_{j+1} = (2j+1)xP_j-jP_{j-1}
Definition at line 51 of file GaussLegendreIntegrator.cxx.
|
overridevirtualinherited |
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.
|
overridevirtualinherited |
This method is not implemented.
Implements ROOT::Math::VirtualIntegratorOneDim.
Definition at line 190 of file GaussIntegrator.cxx.
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.
|
overridevirtualinherited |
This method is not implemented.
Implements ROOT::Math::VirtualIntegratorOneDim.
Definition at line 197 of file GaussIntegrator.cxx.
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.
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.
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.
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.
|
inlineoverridevirtual |
return number of function evaluations in calculating the integral This is equivalent to the number of points
Reimplemented from ROOT::Math::VirtualIntegrator.
Definition at line 74 of file GaussLegendreIntegrator.h.
|
overridevirtual |
get the option used for the integration
Reimplemented from ROOT::Math::GaussIntegrator.
Definition at line 157 of file GaussLegendreIntegrator.cxx.
|
overridevirtualinherited |
Returns the result of the last Integral calculation.
Implements ROOT::Math::VirtualIntegrator.
Definition at line 166 of file GaussIntegrator.cxx.
|
overridevirtual |
This method is not implemented.
Reimplemented from ROOT::Math::GaussIntegrator.
Definition at line 93 of file GaussLegendreIntegrator.cxx.
|
overridevirtualinherited |
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.
| void ROOT::Math::GaussLegendreIntegrator::SetNumberPoints | ( | int | num | ) |
Set the number of points used in the calculation of the integral.
Definition at line 43 of file GaussLegendreIntegrator.cxx.
|
overridevirtual |
set the options (should be re-implemented by derived classes -if more options than tolerance exist
Reimplemented from ROOT::Math::GaussIntegrator.
Definition at line 167 of file GaussLegendreIntegrator.cxx.
|
overridevirtual |
Set the desired relative Error.
Reimplemented from ROOT::Math::GaussIntegrator.
Definition at line 86 of file GaussLegendreIntegrator.cxx.
|
overridevirtualinherited |
return the status of the last integration - 0 in case of success
Implements ROOT::Math::VirtualIntegrator.
Definition at line 179 of file GaussIntegrator.cxx.
|
inlinevirtualinherited |
return type of integrator
Definition at line 134 of file VirtualIntegrator.h.
|
protectedinherited |
Absolute error.
Definition at line 223 of file GaussIntegrator.h.
|
protectedinherited |
Relative error.
Definition at line 222 of file GaussIntegrator.h.
|
protectedinherited |
Pointer to function used.
Definition at line 227 of file GaussIntegrator.h.
|
staticprotectedinherited |
AbsValue used for the calculation of the integral.
Definition at line 221 of file GaussIntegrator.h.
|
protectedinherited |
Error from the last estimation.
Definition at line 226 of file GaussIntegrator.h.
|
protectedinherited |
Result from the last estimation.
Definition at line 225 of file GaussIntegrator.h.
|
protected |
Number of points used in the estimation of the integral.
Definition at line 113 of file GaussLegendreIntegrator.h.
|
protectedinherited |
Bool value to check if the function was at least called once.
Definition at line 224 of file GaussIntegrator.h.
|
protected |
Weights of the points used.
Definition at line 115 of file GaussLegendreIntegrator.h.
|
protected |
Abscisa of the points used.
Definition at line 114 of file GaussLegendreIntegrator.h.