Class inte_kronrod_gsl (o2scl)¶
-
template<class func_t>
class inte_kronrod_gsl : public o2scl::inte_gsl, public o2scl::inte<func_t>¶ Basic Gauss-Kronrod integration class (GSL)
This class provides the basic Gauss-Kronrod integration function and integration workspace for some of the GSL-based integration classes.
The main function of interest is set_rule(), which sets the integration rule for the GSL integration classes which inherit from this base class. The argument to set rule should be selected from the following list:
1: 15-point Gauss-Kronrod integration rule (default)
2: 21-point rule
3: 31-point rule
4: 41-point rule
5: 51-point rule
6: 61-point rule Any value other than 1-6 forces the error handler to be called. All classes default to the 15-point rule, except for o2scl::inte_qags_gsl which defaults to the 21-point rule for singularities.
The integration coefficients for use with this class and associated children are stored in the o2scl_inte_gk_coeffs namespace.
- Idea for Future:
Convert ‘double *’ objects to ubvector
Subclassed by o2scl::inte_qag_gsl< funct >, o2scl::inte_singular_gsl< funct >, o2scl::inte_qag_gsl< func_t >, o2scl::inte_singular_gsl< func_t >
Public Functions
-
inline inte_kronrod_gsl()¶
-
inline ~inte_kronrod_gsl()¶
-
inline inte_workspace_gsl &get_workspace()¶
Get a const reference to the workspace.
-
inline int get_rule()¶
Get the Gauss-Kronrod integration rule.
This returns the index of the GSL integration rule a number between 1 and 6 (inclusive)
-
inline void set_rule(int rule)¶
Set the Gauss-Kronrod integration rule to be used.
-
inline int set_limit(size_t lim)¶
Set the limit for the number of subdivisions of the integration region (default 1000)
If the value of
size
is zero, the error handler will be called.
-
template<class func2_t>
inline void gauss_kronrod_base(func2_t &func, double a, double b, double *result, double *abserr, double *resabs, double *resasc)¶ The base Gauss-Kronrod integration function template.
Given abcissas and weights, this performs the integration of
func
betweena
andb
, providing a result with uncertainties.The Gauss-Kronrod rule uses \( 2m+1 \) abscissae \( x_1, \ldots, x_{2m+1} \in (a, b) \) to estimate the integral of a function as a linear combination of values,
\[ \int_a^b f~dx \; \approx \; Q_m^{GK}f \; \equiv \; \sum_{k=1}^{2m+1} \beta_k f(x_k), \]where the weights \( \beta_1,\ldots, \beta_{2m+1} \) are intrinsic to the abscissae. The data are designed so that the even-indexed abscissae yield a coarser estimate,\[ Q_m^{G}f \; \equiv \; \sum_{j=1}^{m} \alpha_j f(x_{2j}), \]and their difference \( |Q_m^Gf - Q_m^{GK}f| \) is the “raw” error estimate. The various quantities that the function computes are\[\begin{split}\begin{eqnarray*} \mathtt{result} &=& Q_m^{GK}f, \\ \mathtt{resabs} &=& Q_m^{GK}|f|, \\ \mathtt{resasc} &=& Q_m^{GK}(|f| - \mu), \quad \mu \equiv \frac{Q_m^{GK}f}{b - a}. \end{eqnarray*}\end{split}\]The “absolute” errorabserr
is computed from the raw error value using the function inte_gsl::rescale_error.This function is designed for use with the values given in the o2scl_inte_gk_coeffs namespace.
This function never calls the error handler.
- Idea for Future:
This function, in principle, is an integration object in and of itself, and could be implemented separately as an object of type o2scl::inte.
Protected Attributes
-
inte_workspace_gsl *w¶
The integration workspace.
-
int n_gk¶
Size of Gauss-Kronrod arrays.
-
const double *x_gk¶
Gauss-Kronrod abscissae pointer.
-
const double *w_g¶
Gauss weight pointer.
-
const double *w_gk¶
Gauss-Kronrod weight pointer.
-
double *f_v1¶
Scratch space.
-
double *f_v2¶
Scratch space.