1 #ifndef TINY_AD_INTEGRATE_H
2 #define TINY_AD_INTEGRATE_H
11 namespace gauss_kronrod {
27 double value(T
x){
return ((
double*) &x)[0]; }
28 template<
class S,
class T>
29 int imin2(S
x, T y) {
return (x < y) ? x : y;}
30 template<
class S,
class T>
32 template<
class S,
class T>
49 double reltol_ = 1e-4,
50 double abstol_ = 1e-4) :
70 template<
class Integrand>
72 typedef typename Integrand::Scalar
Type;
78 for(
int i=0; i<n; i++) x[i] =
f(x[i]);
88 void setAccuracy(
double epsrel_ = 1e-4,
double epsabs_ = 1e-4) {
100 int a_finite = (a_ != -INFINITY) && (a_ != INFINITY);
101 int b_finite = (b_ != -INFINITY) && (b_ != INFINITY);
102 if ( a_finite && b_finite) {
inf = 0;
a = a_;
b = b_; }
103 else if ( a_finite && !b_finite) {
inf = 1;
bound = a_; }
104 else if (!a_finite && b_finite) {
inf = -1;
bound = b_; }
157 template<
class Integrand>
159 typename Integrand::Scalar a = -INFINITY,
160 typename Integrand::Scalar b = INFINITY,
180 template<
class Integrand>
182 typedef typename Integrand::Scalar
Scalar;
184 typedef typename Integrand::Scalar
Scalar;
201 ev(f_, x_),
c(c_),
I(
ev, a, b, c_) {}
212 template<
class Integrand>
214 typedef typename Integrand::Scalar
Scalar;
253 template<
class Integrand>
mvIntegral< Integrand > wrt(Scalar &x, Scalar a=-INFINITY, Scalar b=INFINITY)
With respect to.
mvIntegral< mvIntegral > wrt(Scalar &x, Scalar a=-INFINITY, Scalar b=INFINITY)
With respect to.
Integral(Integrand f_, Type a_, Type b_, control c=control())
Constructor.
void operator()(Type *x, int n, void *ex)
evaluator(Integrand &f_, Scalar &x_)
User control parameters for R's integrate.
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.
mvIntegral0< Integrand > mvIntegrate(Integrand &f, control c=control())
Multivariate integration.
struct gauss_kronrod::mvIntegral::evaluator ev
Interface to R's adaptive integrate routine.
Scalar operator()(const Scalar &x_)
struct gauss_kronrod::Integral::vectorized_integrand fn
void Rdqagi(integr_fn f, void *ex, Float *bound, int *inf, Float *epsabs, Float *epsrel, Float *result, Float *abserr, int *neval, int *ier, int *limit, int *lenw, int *last, int *iwork, Float *work)
Multivariate integral class.
control(int subdivisions_=100, double reltol_=1e-4, double abstol_=1e-4)
void setAccuracy(double epsrel_=1e-4, double epsabs_=1e-4)
mvIntegral0(Integrand &f_, control c_)
void setBounds(Type a_, Type b_)
void setWorkspace(int subdivisions=100)
void Rdqags(integr_fn f, void *ex, Float *a, Float *b, Float *epsabs, Float *epsrel, Float *result, Float *abserr, int *neval, int *ier, int *limit, int *lenw, int *last, int *iwork, Float *work)
vectorized_integrand(Integrand f_)
mvIntegral(Integrand &f_, Scalar &x_, Scalar a=-INFINITY, Scalar b=INFINITY, control c_=control())
Integrand & integrand()
Return reference to integrand so the user can change parameters.