TMB Documentation  v1.9.11
Classes | Functions
gauss_kronrod Namespace Reference

Namespace with utility functions for adaptive numerical integration. More...

Classes

struct  control
 User control parameters for R's integrate. More...
 
struct  Integral
 Interface to R's adaptive integrate routine. More...
 
struct  mvIntegral
 Multivariate integral class. More...
 

Functions

template<class Integrand >
Integrand::Scalar integrate (Integrand f, typename Integrand::Scalar a=-INFINITY, typename Integrand::Scalar b=INFINITY, control c=control())
 Integrate function over finite or infinite interval. More...
 
template<class Integrand >
mvIntegral0< Integrand > mvIntegrate (Integrand &f, control c=control())
 Multivariate integration. More...
 

Detailed Description

Namespace with utility functions for adaptive numerical integration.

Interfaces to R's integrator that can be used with forward mode AD.

Function Documentation

§ integrate()

template<class Integrand >
Integrand::Scalar gauss_kronrod::integrate ( Integrand  f,
typename Integrand::Scalar  a = -INFINITY,
typename Integrand::Scalar  b = INFINITY,
control  c = control() 
)

Integrate function over finite or infinite interval.

Parameters
fUnivariate integrand (functor)
aLower integration limit. Default is negative infinity.
aUpper integration limit. Default is positive infinity.
cOptional control parameters.

Example:

template<class Float>
struct Gauss_t {
typedef Float Scalar;
Float a; // Parameter
// Evaluate integrand
Float operator(Float x) () {
Float ans = exp(- a*x*x);
return ans;
}
// Integrate wrt x
Float my_integrate() {
Float ans = integrate(*this);
return ans;
}
};
Examples:
adaptive_integration.cpp.

Definition at line 163 of file tiny_ad/integrate/integrate.hpp.

§ mvIntegrate()

template<class Integrand >
mvIntegral0<Integrand> gauss_kronrod::mvIntegrate ( Integrand &  f,
control  c = control() 
)

Multivariate integration.

Parameters
fMultivariate integrand (functor)
cOptional control parameters

Example:

template<class Float>
struct Gauss2D_t {
typedef Float Scalar;
Float a, b; // Parameters
Float x, y; // Integration variables
// Evaluate integrand (u1,u2)
Float operator() () {
Float ans = exp(- a*x*x - b*y*y);
return ans;
}
// Integrate wrt (x,y)
Float my_integrate() {
Float ans = mvIntegrate(*this).
wrt(x, -INFINITY, INFINITY).
wrt(y, -INFINITY, INFINITY) ();
return ans;
}
};

Definition at line 259 of file tiny_ad/integrate/integrate.hpp.

License: GPL v2