Class inte_pcubature (o2scl)¶
-
template<class func_t, class vec_t, class vec_crange_t, class vec_range_t>
class o2scl::inte_pcubature : public o2scl::inte_cubature_base¶ Integration by p-adaptive cubature from the Cubature library.
This class is experimental.
Documentation adapted from Cubature
This class performs adaptive integration by increasing the degree of the cubature rule rather than subdividing the domain, using products of Clenshaw-Curtis rules. This algorithm may be superior to Genz-Malik for smooth integrands lacking strongly-localized features, in moderate dimensions.
Public Functions
-
inline int integ_v_buf(size_t fdim, func_t &f, size_t dim, const vec_t &xmin, const vec_t &xmax, size_t maxEval, double reqAbsError, double reqRelError, error_norm norm, std::vector<size_t> &m, vec_t &buf, size_t &nbuf, size_t max_nbuf, vec_t &val, vec_t &err)¶
Desc.
Vectorized version with user-supplied buffer to store points and values. The buffer *buf should be of length *nbuf * dim on entry (these parameters are changed upon return to the final buffer and length that was used). The buffer length will be kept <= max(max_nbuf, 1) * dim.
Also allows the caller to specify an array m[dim] of starting degrees for the rule, which upon return will hold the final degrees. The number of points in each dimension i is 2^(m[i]+1)
1.
Public Static Attributes
-
static const size_t DEFAULT_MAX_NBUF = (1U << 20)¶
Desc.
Protected Functions
-
inline int compute_cacheval(const std::vector<size_t> &m, size_t mi, vec_t &val, size_t &vali, size_t fdim, func_t &f, size_t dim, size_t id, std::vector<double> &p, const vec_t &xmin, const vec_t &xmax, vec_t &buf, size_t nbuf, size_t &ibuf)¶
Desc.
recursive loop over all cubature points for the given (m,mi) cache entry: add each point to the buffer buf, evaluating all at once whenever the buffer is full or when we are done
-
inline size_t num_cacheval(const std::vector<size_t> &m, size_t mi, size_t dim, size_t i_shift)¶
Desc.
-
inline int add_cacheval(std::vector<cache> &vc, const std::vector<size_t> &m, size_t mi, size_t fdim, func_t &f, size_t dim, const vec_t &xmin, const vec_t &xmax, vec_t &buf, size_t nbuf)¶
Desc.
-
inline size_t eval(const std::vector<size_t> &cm, size_t cmi, vec_t &cval, const std::vector<size_t> &m, size_t md, size_t fdim, size_t dim, size_t id, double weight, vec_t &val, size_t voff2)¶
Desc.
Recursive loop to evaluate the integral contribution from the cache entry c, accumulating in val, for the given m[] except with m[md] -> m[md] - 1 if md < dim, using the cached values (cm,cmi,cval). id is the current loop dimension (from 0 to dim-1).
-
inline void evals(std::vector<cache> &vc, const std::vector<size_t> &m, size_t md, size_t fdim, size_t dim, double V, vec_t &val)¶
Desc.
Loop over all cache entries that contribute to the integral, (with m[md] decremented by 1)
-
inline void eval_integral(std::vector<cache> &vc, const std::vector<size_t> &m, size_t fdim, size_t dim, double V, size_t &mi, vec_t &val, vec_t &err, vec_t &val1)¶
Desc.
Evaluate the integrals for the given m[] using the cached values in vc, storing the integrals in val[], the error estimate in err[], and the dimension to subdivide next (the largest error contribution) in *mi
Protected Static Attributes
-
static const size_t MAXDIM = 20¶
Maximum integral dimension.
-
class cache¶
Cache of the values for the m[dim] grid.
For adaptive cubature, thanks to the nesting of the C-C rules, we can re-use the values from coarser grids for finer grids, and the coarser grids are also used for error estimation.
A grid is determined by an m[dim] array, where m[i] denotes 2^(m[i]+1)+1 points in the i-th dimension.
If mi < dim, then we only store the values corresponding to the difference between the m grid and the grid with m[mi] -> m[mi]-1. (m[mi]-1 == -1 corresponds to the trivial grid of one point in the center.)
Public Functions
-
inline cache()¶
-
inline cache()¶
-
inline int integ_v_buf(size_t fdim, func_t &f, size_t dim, const vec_t &xmin, const vec_t &xmax, size_t maxEval, double reqAbsError, double reqRelError, error_norm norm, std::vector<size_t> &m, vec_t &buf, size_t &nbuf, size_t max_nbuf, vec_t &val, vec_t &err)¶