APFEL 4.8.0
A PDF evolution library in C++
Loading...
Searching...
No Matches
List of all members
apfel::Integrator Class Reference

The Integrator class performs unidimensional numerical integrations using the Guassian quadrature. More...

#include <integrator.h>

Public Types

Enumerator for the currently available integration

methods.

enum  IntegrationMethod : int { GAUSS_LEGENDRE , GAUSS_KRONROD }
 

Constructors

List of constructors.

std::function< double(double const &)> cons _func )
 The integrand function.
 
IntegrationMethod const _method
 The integration method.
 
 Integrator (std::function< double(double const &)> const &func, IntegrationMethod const &method=GAUSS_KRONROD)
 The Integrator constructor.
 
double integrate (double const &xmin, double const &xmax, double const &eps) const
 Function that integrates the integrand with a given relative accuracy using the method defined in the constructor.
 
double integrate (double const &xmin, double const &xmax, std::vector< double > const &FixPts, double const &eps) const
 Function that integrates the integrand with a given relative accuracy using a set of fixed point on the integration range.
 
double integrate (std::vector< double > const &FixPts, double const &eps) const
 Function that integrates the integrand with a given relative accuracy using a set of fixed point on the integration range. In this case, the vector also contains the lower and upper bounds.
 
double integrate (double const &xmin, double const &xmax, int const &n=1) const
 Function that integrates the integrand with a given relative accuracy using the method defined in the constructor.
 
double integrate (double const &xmin, double const &xmax, std::vector< double > const &FixPts, int const &n=1) const
 Function that integrates the integrand with a given relative accuracy using a set of fixed point on the integration range.
 
double integrate (std::vector< double > const &FixPts, int const &n=1) const
 Function that integrates the integrand with a given relative accuracy using a set of fixed point on the integration range. In this case, the vector also contains the lower and upper bounds.
 
double integrand (double const &x) const
 Function for the integrand.
 
IntegrationMethod Method () const
 Function that returns the integration method.
 
std::pair< double, double > integrateGL (double const &xmin, double const &xmax) const
 Function that integrates the integrand using the Gauss-Legendre method.
 
std::pair< double, double > integrateGK (double const &xmin, double const &xmax) const
 Function that integrates the integrand using the Gauss-Kronrod method.
 
double integrateGL (double const &xmin, double const &xmax, int const &n) const
 Function that integrates the integrand using the Gauss-Legendre method (no accuracy estimate).
 
double integrateGK (double const &xmin, double const &xmax, int const &n) const
 Function that integrates the integrand using the Gauss-Kronrod method (no accuracy estimate).
 

Detailed Description

The Integrator class performs unidimensional numerical integrations using the Guassian quadrature.

Examples
integrator_test.cc, ogata_test.cc, principal_value_test.cc, and qgriddist_test.cc.

Member Enumeration Documentation

◆ IntegrationMethod

Enumerator
GAUSS_LEGENDRE 
GAUSS_KRONROD 

Constructor & Destructor Documentation

◆ Integrator()

apfel::Integrator::Integrator ( std::function< double(double const &)> const & func,
IntegrationMethod const & method = GAUSS_KRONROD )

The Integrator constructor.

Parameters
funcThe function of one variable to be integrated
methodThe integration method to be used (default: GAUSS_KRONROD)

Member Function Documentation

◆ integrand()

double apfel::Integrator::integrand ( double const & x) const
inline

Function for the integrand.

Parameters
xthe integration variable
Returns
the integrand evaluated at x

◆ integrate() [1/6]

double apfel::Integrator::integrate ( double const & xmin,
double const & xmax,
double const & eps ) const

Function that integrates the integrand with a given relative accuracy using the method defined in the constructor.

Parameters
xminthe lower bound integration bound
xmaxthe upper bound integration bound
epsthe required relative accuracy
Returns
the value of the integral
Examples
qgriddist_test.cc.

◆ integrate() [2/6]

double apfel::Integrator::integrate ( double const & xmin,
double const & xmax,
int const & n = 1 ) const

Function that integrates the integrand with a given relative accuracy using the method defined in the constructor.

Parameters
xminthe lower bound integration bound
xmaxthe upper bound integration bound
nindex associated to the number of points used for the integration: 0 for 8/7 points for Gauss-Legendre/Kronrod, 1 for 16/15 points for Gauss-Legendre/Kronrod (default: 1)
Returns
the value of the integral

◆ integrate() [3/6]

double apfel::Integrator::integrate ( double const & xmin,
double const & xmax,
std::vector< double > const & FixPts,
double const & eps ) const

Function that integrates the integrand with a given relative accuracy using a set of fixed point on the integration range.

Parameters
xminthe lower bound integration bound
xmaxthe upper bound integration bound
FixPtsthe vector of fixed points of the integration
epsthe required relative accuracy
Returns
the value of the integral

◆ integrate() [4/6]

double apfel::Integrator::integrate ( double const & xmin,
double const & xmax,
std::vector< double > const & FixPts,
int const & n = 1 ) const

Function that integrates the integrand with a given relative accuracy using a set of fixed point on the integration range.

Parameters
xminthe lower bound integration bound
xmaxthe upper bound integration bound
FixPtsthe vector of fixed points of the integration
nindex associated to the number of points used for the integration: 0 for 8/7 points for Gauss-Legendre/Kronrod, 1 for 16/15 points for Gauss-Legendre/Kronrod (default: 1)
Returns
the value of the integral

◆ integrate() [5/6]

double apfel::Integrator::integrate ( std::vector< double > const & FixPts,
double const & eps ) const

Function that integrates the integrand with a given relative accuracy using a set of fixed point on the integration range. In this case, the vector also contains the lower and upper bounds.

Parameters
FixPtsthe vector of fixed points of the integration
epsthe required relative accuracy integration: 0 for 8/7 points for Gauss-Legendre/Kronrod, 1 for 16/15 points for Gauss-Legendre/Kronrod (default: 1)
Returns
the value of the integral
Note
In order to make this function as fast as possible, no manipulation of the vector "FixPts" is made. To be used with care.

◆ integrate() [6/6]

double apfel::Integrator::integrate ( std::vector< double > const & FixPts,
int const & n = 1 ) const

Function that integrates the integrand with a given relative accuracy using a set of fixed point on the integration range. In this case, the vector also contains the lower and upper bounds.

Parameters
FixPtsthe vector of fixed points of the integration
nindex associated to the number of points used for the integration: 0 for 8/7 points for Gauss-Legendre/Kronrod, 1 for 16/15 points for Gauss-Legendre/Kronrod (default: 1)
Returns
the value of the integral
Note
In order to make this function as fast as possible, no manipulation of the vector "FixPts" is made. To be used with care.

◆ integrateGK() [1/2]

std::pair< double, double > apfel::Integrator::integrateGK ( double const & xmin,
double const & xmax ) const
private

Function that integrates the integrand using the Gauss-Kronrod method.

Parameters
xminthe lower bound integration bound
xmaxthe upper bound integration bound
Returns
a pair containing the value of the integral computed with the 15-point method and the relative difference w.r.t. the 7-point one.

◆ integrateGK() [2/2]

double apfel::Integrator::integrateGK ( double const & xmin,
double const & xmax,
int const & n ) const
private

Function that integrates the integrand using the Gauss-Kronrod method (no accuracy estimate).

Parameters
xminthe lower bound integration bound
xmaxthe upper bound integration bound
nindex associated to the number of points used for the integration: 0 for 7 points for Gauss-Legendr, 1 for 15 points
Returns
the value of the integral

◆ integrateGL() [1/2]

std::pair< double, double > apfel::Integrator::integrateGL ( double const & xmin,
double const & xmax ) const
private

Function that integrates the integrand using the Gauss-Legendre method.

Parameters
xminthe lower bound integration bound
xmaxthe upper bound integration bound
Returns
a pair containing the value of the integral computed with the 16-point method and the relative difference w.r.t. the 8-point one.

◆ integrateGL() [2/2]

double apfel::Integrator::integrateGL ( double const & xmin,
double const & xmax,
int const & n ) const
private

Function that integrates the integrand using the Gauss-Legendre method (no accuracy estimate).

Parameters
xminthe lower bound integration bound
xmaxthe upper bound integration bound
nindex associated to the number of points used for the integration: 0 for 8 points for Gauss-Legendr, 1 for 16 points
Returns
the value of the integral

◆ Method()

IntegrationMethod apfel::Integrator::Method ( ) const
inline

Function that returns the integration method.

Member Data Documentation

◆ _func

std::function<double(double const&)> cons apfel::Integrator::_func)
private

The integrand function.

◆ _method

IntegrationMethod const apfel::Integrator::_method
private

The integration method.


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