Protected Attributes | List of all members
o2scl::inte_adapt_cern< func_t, nsub > Class Template Reference

Adaptive integration (CERNLIB) More...

#include <inte_adapt_cern.h>

Inheritance diagram for o2scl::inte_adapt_cern< func_t, nsub >:
o2scl::inte< func_t >

Public Member Functions

Basic usage
virtual int integ_err (func_t &func, double a, double b, double &res, double &err)
 Integrate function func from a to b giving result res and error err.
- Public Member Functions inherited from o2scl::inte< func_t >
virtual double integ (func_t &func, double a, double b)
 Integrate function func from a to b.
double get_error ()
 Return the numerically estimated error in the result from the last call to integ() More...
virtual const char * type ()
 Return string denoting type ("inte")

Protected Attributes

double xlo [nsub]
 Lower end of subdivision.
double xhi [nsub]
 High end of subdivision.
double tval [nsub]
 Value of integral for subdivision.
double ters [nsub]
 Squared error for subdivision.
int prev_subdiv
 Previous number of subdivisions.
inte< func_t > * it
 The base integration object.
- Protected Attributes inherited from o2scl::inte< func_t >
double interror
 The uncertainty for the last integration computation.

Integration object

inte_gauss56_cern< func_t > def_inte
 Default integration object.
int set_inte (inte< func_t > &i)
 Set the base integration object to use.


size_t nsubdiv
 Number of subdivisions. More...
size_t get_nsubdivisions ()
 Return the number of subdivisions used in the last integration.
int get_ith_subdivision (size_t i, double &xlow, double &xhigh, double &value, double &errsq)
 Return the ith subdivision.
template<class vec_t >
int get_subdivisions (vec_t &xlow, vec_t &xhigh, vec_t &value, vec_t &errsq)
 Return all of the subdivisions.

Additional Inherited Members

- Public Attributes inherited from o2scl::inte< func_t >
int verbose
size_t last_iter
 The most recent number of iterations taken.
double tol_rel
 The maximum relative uncertainty in the value of the integral (default $ 10^{-8} $)
double tol_abs
 The maximum absolute uncertainty in the value of the integral (default $ 10^{-8} $)
bool err_nonconv
 If true, call the error handler if the routine does not converge or reach the desired tolerance (default true) More...

Detailed Description

template<class func_t = funct11, size_t nsub = 100>
class o2scl::inte_adapt_cern< func_t, nsub >

Uses a base integration object (default is inte_gauss56_cern) to perform adaptive integration by automatically subdividing the integration interval. At each step, the interval with the largest absolute uncertainty is divided in half. The routine succeeds if the absolute tolerance is less than tol_abs or if the relative tolerance is less than tol_rel, i.e.

\[ \mathrm{err}\leq\mathrm{tol\_abs}~\mathrm{or}~ \mathrm{err}\leq\mathrm{tol\_rel}\cdot|I| \]

where $ I $ is the current estimate for the integral and $ \mathrm{err} $ is the current estimate for the uncertainty. If the number of subdivisions exceeds the template parameter nsub, the error handler is called, since the integration may not have been successful. The number of subdivisions used in the last integration can be obtained from get_nsubdivisions().

The template parameter nsub, is the maximum number of subdivisions. It is automatically set to 100 in the original CERNLIB routine, and defaults to 100 here. The default base integration object is of type inte_gauss56_cern. This is the CERNLIB default, but can be modified by calling set_inte().

This class is based on the CERNLIB routines RADAPT and DADAPT which are documented at

Idea for Future:
  • Allow user to set the initial subdivisions?
  • It might be interesting to directly compare the performance of this class to o2scl::inte_qag_gsl .
  • There is a fixme entry in the code which could be resolved.
  • Output the point where most subdividing was required?

Definition at line 75 of file inte_adapt_cern.h.

Member Data Documentation

◆ nsubdiv

template<class func_t = funct11, size_t nsub = 100>
size_t o2scl::inte_adapt_cern< func_t, nsub >::nsubdiv

The options are

  • 0: Use previous binning and do not subdivide further
  • 1: Automatic - adapt until tolerance is attained (default)
  • n: (n>1) split first in n equal subdivisions, then adapt until tolerance is obtained.

Definition at line 267 of file inte_adapt_cern.h.

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

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).