cern_adapt Class Template Reference

#include <cern_adapt.h>

Inheritance diagram for cern_adapt:

inte

Detailed Description

template<class param_t, class func_t, size_t nsub = 100>
class cern_adapt< param_t, func_t, nsub >

Adaptive integration (CERNLIB).

Uses cern_gauss56 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 stops if the absolute tolerance is less than tolx, the relative tolerance is less than tolf, or the number of segments exceeds the template parameter nsub (in which case the error handler is called, since the integration may not have been successful). The number of segments used in the last integration can be obtained from get_nsegments().

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 cern_gauss56. This is the CERNLIB default, but can be modified by calling set_inte().

Todo:
It looks like the first segment is of zero size, is this because there's an offset? Double check that we don't have memory issues if nseg=nsub.
Idea for future:
More error checking, e.g. ensure the user doesn't try to get a segment greater than the total number of segments.
Idea for future:
Allow user to set the initial segments?

Definition at line 63 of file cern_adapt.h.


Public Member Functions

int set_inte (inte< param_t, func_t > &i)
 Set the base integration object to use.
size_t get_nsegments ()
 Return the number of segments used in the last integration.
int get_ith_segment (size_t i, double &xlow, double &xhigh, double &value, double &errsq)
 Return the ith segment.
template<class vec_t>
int get_segments (vec_t &xlow, vec_t &xhigh, vec_t &value, vec_t &errsq)
 Return all of the segments.
virtual double integ (func_t &func, double a, double b, param_t &pa)
 Integrate function func from a to b.
virtual int integ_err (func_t &func, double a, double b, param_t &pa, double &res, double &err)
 Integrate function func from a to b giving result res and error err.

Data Fields

size_t nseg
 Number of subdivisions.

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 nter
 Previous number of subdivisions.
cern_gauss56< param_t, func_t > cg56
 Default integration object.
inte< param_t, func_t > * it
 The base integration object.

Field Documentation

size_t nseg

Number of subdivisions.

The options are

Definition at line 116 of file cern_adapt.h.


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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page