Integration of functions using adaptive Guassian quadrature.
The default real kind (wp
) can be
changed using optional preprocessor flags.
This library was built with real kind:
real(kind=real64)
[8 bytes]
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | quadrature_wp | = | real64 | real kind used by this module [8 bytes] |
integer, | private, | parameter | :: | wp | = | quadrature_wp | local copy of |
real(kind=wp), | private, | parameter | :: | zero | = | 0.0_wp | |
real(kind=wp), | private, | parameter | :: | one_half | = | 0.5_wp | |
real(kind=wp), | private, | parameter | :: | one | = | 1.0_wp | |
real(kind=wp), | private, | parameter | :: | two | = | 2.0_wp | |
real(kind=wp), | private, | parameter | :: | three | = | 3.0_wp | |
real(kind=wp), | private, | parameter | :: | four | = | 4.0_wp | |
type(quadrature_method), | private, | parameter | :: | quad_gauss_6 | = | quadrature_method(6, 'Adaptive 6-point Legendre-Gauss') | |
type(quadrature_method), | private, | parameter | :: | quad_gauss_8 | = | quadrature_method(8, 'Adaptive 8-point Legendre-Gauss') | |
type(quadrature_method), | private, | parameter | :: | quad_gauss_10 | = | quadrature_method(10, 'Adaptive 10-point Legendre-Gauss') | |
type(quadrature_method), | private, | parameter | :: | quad_gauss_12 | = | quadrature_method(12, 'Adaptive 12-point Legendre-Gauss') | |
type(quadrature_method), | private, | parameter | :: | quad_gauss_14 | = | quadrature_method(14, 'Adaptive 14-point Legendre-Gauss') | |
type(quadrature_method), | public, | parameter, dimension(5) | :: | set_of_quadrature_methods | = | [quad_gauss_6, quad_gauss_8, quad_gauss_10, quad_gauss_12, quad_gauss_14] |
1d user function f(x)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x |
2d user function f(x,y)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_2d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | y |
3d user function f(x,y,z)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_3d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | y | |||
real(kind=wp), | intent(in) | :: | z |
4d user function f(x,y,z,q)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_4d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | y | |||
real(kind=wp), | intent(in) | :: | z | |||
real(kind=wp), | intent(in) | :: | q |
5d user function f(x,y,z,q,r)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_5d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | y | |||
real(kind=wp), | intent(in) | :: | z | |||
real(kind=wp), | intent(in) | :: | q | |||
real(kind=wp), | intent(in) | :: | r |
6d user function f(x,y,z,q,r,s)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_6d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | y | |||
real(kind=wp), | intent(in) | :: | z | |||
real(kind=wp), | intent(in) | :: | q | |||
real(kind=wp), | intent(in) | :: | r | |||
real(kind=wp), | intent(in) | :: | s |
guass quadrature formula
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | h |
quadrature methods
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | n_points | = | 0 | ||
character(len=100), | public | :: | name | = | '' |
single integration class: for 1d integration of f(x)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
procedure(func_1d), | public, | pointer | :: | fun | => | null() | function |
procedure(gauss_func), | public, | pointer | :: | g | => | null() | the guass quadrature formula to use |
real(kind=wp), | public | :: | a | = | zero | lower limit of integration |
|
real(kind=wp), | public | :: | b | = | zero | upper limit of integration (may be less than a) |
|
real(kind=wp), | public | :: | tol | = | zero | the requested relative error tolerance. |
|
real(kind=wp), | public | :: | val | = | zero | the value of |
procedure, public :: dgauss_generic | core integration routine. refactored from SLATEC with selectable quadrature method |
procedure, public :: initialize => initialize_integration_class | to set up the class |
procedure, public :: integrate => integrate_1d | to integrate the function |
double integration class: for 2d integration of f(x,y)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
procedure(func_2d), | public, | pointer | :: | fxy | => | null() | function |
type(integration_class_1d), | public | :: | iy | for the dy integration |
|||
type(integration_class_1d), | public | :: | ix | for the dx integration |
procedure, public :: initialize => initialize_integration_class_2d | to set up the class |
procedure, public :: integrate => integrate_2d | to integrate the function |
double integration class: for 3d integration of f(x,y,z)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
procedure(func_3d), | public, | pointer | :: | fxyz | => | null() | function |
type(integration_class_1d), | public | :: | iz | for the dz integration |
|||
type(integration_class_1d), | public | :: | iy | for the dy integration |
|||
type(integration_class_1d), | public | :: | ix | for the dx integration |
procedure, public :: initialize => initialize_integration_class_3d | to set up the class |
procedure, public :: integrate => integrate_3d | to integrate the function |
double integration class: for 4d integration of f(x,y,z,q)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
procedure(func_4d), | public, | pointer | :: | fxyzq | => | null() | function |
type(integration_class_1d), | public | :: | iq | for the dq integration |
|||
type(integration_class_1d), | public | :: | iz | for the dz integration |
|||
type(integration_class_1d), | public | :: | iy | for the dy integration |
|||
type(integration_class_1d), | public | :: | ix | for the dx integration |
procedure, public :: initialize => initialize_integration_class_4d | to set up the class |
procedure, public :: integrate => integrate_4d | to integrate the function |
double integration class: for 5d integration of f(x,y,z,q,r)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
procedure(func_5d), | public, | pointer | :: | fxyzqr | => | null() | function |
type(integration_class_1d), | public | :: | ir | for the dr integration |
|||
type(integration_class_1d), | public | :: | iq | for the dq integration |
|||
type(integration_class_1d), | public | :: | iz | for the dz integration |
|||
type(integration_class_1d), | public | :: | iy | for the dy integration |
|||
type(integration_class_1d), | public | :: | ix | for the dx integration |
procedure, public :: initialize => initialize_integration_class_5d | to set up the class |
procedure, public :: integrate => integrate_5d | to integrate the function |
double integration class: for 6d integration of f(x,y,z,q,r,s)
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
procedure(func_6d), | public, | pointer | :: | fxyzqrs | => | null() | function |
type(integration_class_1d), | public | :: | is | for the ds integration |
|||
type(integration_class_1d), | public | :: | ir | for the dr integration |
|||
type(integration_class_1d), | public | :: | iq | for the dq integration |
|||
type(integration_class_1d), | public | :: | iz | for the dz integration |
|||
type(integration_class_1d), | public | :: | iy | for the dy integration |
|||
type(integration_class_1d), | public | :: | ix | for the dx integration |
procedure, public :: initialize => initialize_integration_class_6d | to set up the class |
procedure, public :: integrate => integrate_6d | to integrate the function |
6-point method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | h |
This is the 8-point formula from the original SLATEC routine DGAUS8.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | h |
10-point method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | h |
12-point method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | h |
14-point method.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | h |
Initialize the 1D integration class. Must be called before integration is performed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
procedure(func_1d) | :: | fx | 1d function: f(x) |
|||
real(kind=wp), | intent(in) | :: | xl | x integration lower bound |
||
real(kind=wp), | intent(in) | :: | xu | x integration upper bound |
||
real(kind=wp), | intent(in) | :: | tolx | error tolerance for dx integration |
||
integer, | intent(in) | :: | methodx | quadrature method to use for x |
Initialize the 2D integration class. Must be called before integration is performed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_2d), | intent(inout) | :: | me | |||
procedure(func_2d) | :: | fxy | 2d function: f(x,y) |
|||
real(kind=wp), | intent(in) | :: | xl | x integration lower bound |
||
real(kind=wp), | intent(in) | :: | xu | x integration upper bound |
||
real(kind=wp), | intent(in) | :: | yl | y integration lower bound |
||
real(kind=wp), | intent(in) | :: | yu | y integration upper bound |
||
real(kind=wp), | intent(in) | :: | tolx | error tolerance for dx integration |
||
real(kind=wp), | intent(in) | :: | toly | error tolerance for dy integration |
||
integer, | intent(in) | :: | methodx | quadrature method to use for x |
||
integer, | intent(in) | :: | methody | quadrature method to use for y |
Initialize the 3D integration class. Must be called before integration is performed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_3d), | intent(inout) | :: | me | |||
procedure(func_3d) | :: | fxyz | 3d function: f(x,y,z) |
|||
real(kind=wp), | intent(in) | :: | xl | x integration lower bound |
||
real(kind=wp), | intent(in) | :: | xu | x integration upper bound |
||
real(kind=wp), | intent(in) | :: | yl | y integration lower bound |
||
real(kind=wp), | intent(in) | :: | yu | y integration upper bound |
||
real(kind=wp), | intent(in) | :: | zl | z integration lower bound |
||
real(kind=wp), | intent(in) | :: | zu | z integration upper bound |
||
real(kind=wp), | intent(in) | :: | tolx | error tolerance for dx integration |
||
real(kind=wp), | intent(in) | :: | toly | error tolerance for dy integration |
||
real(kind=wp), | intent(in) | :: | tolz | error tolerance for dz integration |
||
integer, | intent(in) | :: | methodx | quadrature method to use for x |
||
integer, | intent(in) | :: | methody | quadrature method to use for y |
||
integer, | intent(in) | :: | methodz | quadrature method to use for z |
Initialize the 4D integration class. Must be called before integration is performed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_4d), | intent(inout) | :: | me | |||
procedure(func_4d) | :: | fxyzq | 4d function: f(x,y,z,q) |
|||
real(kind=wp), | intent(in) | :: | xl | x integration lower bound |
||
real(kind=wp), | intent(in) | :: | xu | x integration upper bound |
||
real(kind=wp), | intent(in) | :: | yl | y integration lower bound |
||
real(kind=wp), | intent(in) | :: | yu | y integration upper bound |
||
real(kind=wp), | intent(in) | :: | zl | z integration lower bound |
||
real(kind=wp), | intent(in) | :: | zu | z integration upper bound |
||
real(kind=wp), | intent(in) | :: | ql | q integration lower bound |
||
real(kind=wp), | intent(in) | :: | qu | q integration upper bound |
||
real(kind=wp), | intent(in) | :: | tolx | error tolerance for dx integration |
||
real(kind=wp), | intent(in) | :: | toly | error tolerance for dy integration |
||
real(kind=wp), | intent(in) | :: | tolz | error tolerance for dz integration |
||
real(kind=wp), | intent(in) | :: | tolq | error tolerance for dq integration |
||
integer, | intent(in) | :: | methodx | quadrature method to use for x |
||
integer, | intent(in) | :: | methody | quadrature method to use for y |
||
integer, | intent(in) | :: | methodz | quadrature method to use for z |
||
integer, | intent(in) | :: | methodq | quadrature method to use for q |
Initialize the 5D integration class. Must be called before integration is performed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_5d), | intent(inout) | :: | me | |||
procedure(func_5d) | :: | fxyzqr | 5d function: f(x,y,z,q,r) |
|||
real(kind=wp), | intent(in) | :: | xl | x integration lower bound |
||
real(kind=wp), | intent(in) | :: | xu | x integration upper bound |
||
real(kind=wp), | intent(in) | :: | yl | y integration lower bound |
||
real(kind=wp), | intent(in) | :: | yu | y integration upper bound |
||
real(kind=wp), | intent(in) | :: | zl | z integration lower bound |
||
real(kind=wp), | intent(in) | :: | zu | z integration upper bound |
||
real(kind=wp), | intent(in) | :: | ql | q integration lower bound |
||
real(kind=wp), | intent(in) | :: | qu | q integration upper bound |
||
real(kind=wp), | intent(in) | :: | rl | r integration lower bound |
||
real(kind=wp), | intent(in) | :: | ru | r integration upper bound |
||
real(kind=wp), | intent(in) | :: | tolx | error tolerance for dx integration |
||
real(kind=wp), | intent(in) | :: | toly | error tolerance for dy integration |
||
real(kind=wp), | intent(in) | :: | tolz | error tolerance for dz integration |
||
real(kind=wp), | intent(in) | :: | tolq | error tolerance for dq integration |
||
real(kind=wp), | intent(in) | :: | tolr | error tolerance for dr integration |
||
integer, | intent(in) | :: | methodx | quadrature method to use for x |
||
integer, | intent(in) | :: | methody | quadrature method to use for y |
||
integer, | intent(in) | :: | methodz | quadrature method to use for z |
||
integer, | intent(in) | :: | methodq | quadrature method to use for q |
||
integer, | intent(in) | :: | methodr | quadrature method to use for r |
Initialize the 6D integration class. Must be called before integration is performed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_6d), | intent(inout) | :: | me | |||
procedure(func_6d) | :: | fxyzqrs | 6d function: f(x,y,z,q,r,s) |
|||
real(kind=wp), | intent(in) | :: | xl | x integration lower bound |
||
real(kind=wp), | intent(in) | :: | xu | x integration upper bound |
||
real(kind=wp), | intent(in) | :: | yl | y integration lower bound |
||
real(kind=wp), | intent(in) | :: | yu | y integration upper bound |
||
real(kind=wp), | intent(in) | :: | zl | z integration lower bound |
||
real(kind=wp), | intent(in) | :: | zu | z integration upper bound |
||
real(kind=wp), | intent(in) | :: | ql | q integration lower bound |
||
real(kind=wp), | intent(in) | :: | qu | q integration upper bound |
||
real(kind=wp), | intent(in) | :: | rl | r integration lower bound |
||
real(kind=wp), | intent(in) | :: | ru | r integration upper bound |
||
real(kind=wp), | intent(in) | :: | sl | s integration lower bound |
||
real(kind=wp), | intent(in) | :: | su | s integration upper bound |
||
real(kind=wp), | intent(in) | :: | tolx | error tolerance for dx integration |
||
real(kind=wp), | intent(in) | :: | toly | error tolerance for dy integration |
||
real(kind=wp), | intent(in) | :: | tolz | error tolerance for dz integration |
||
real(kind=wp), | intent(in) | :: | tolq | error tolerance for dq integration |
||
real(kind=wp), | intent(in) | :: | tolr | error tolerance for dr integration |
||
real(kind=wp), | intent(in) | :: | tols | error tolerance for ds integration |
||
integer, | intent(in) | :: | methodx | quadrature method to use for x |
||
integer, | intent(in) | :: | methody | quadrature method to use for y |
||
integer, | intent(in) | :: | methodz | quadrature method to use for z |
||
integer, | intent(in) | :: | methodq | quadrature method to use for q |
||
integer, | intent(in) | :: | methodr | quadrature method to use for r |
||
integer, | intent(in) | :: | methods | quadrature method to use for s |
Perform the 1D integration.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(out) | :: | ans | |||
integer, | intent(out) | :: | ierr | |||
real(kind=wp), | intent(out) | :: | err |
Perform the 2D integration.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_2d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(out) | :: | ans | |||
integer, | intent(out) | :: | ierr | |||
real(kind=wp), | intent(out) | :: | err |
Perform the 3D integration.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_3d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(out) | :: | ans | |||
integer, | intent(out) | :: | ierr | |||
real(kind=wp), | intent(out) | :: | err |
Perform the 4D integration.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_4d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(out) | :: | ans | |||
integer, | intent(out) | :: | ierr | |||
real(kind=wp), | intent(out) | :: | err |
Perform the 5D integration.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_5d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(out) | :: | ans | |||
integer, | intent(out) | :: | ierr | |||
real(kind=wp), | intent(out) | :: | err |
Perform the 6D integration.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_6d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(out) | :: | ans | |||
integer, | intent(out) | :: | ierr | |||
real(kind=wp), | intent(out) | :: | err |
Integrate a real function of one variable over a finite interval using the specified adaptive algorithm. Intended primarily for high accuracy integration or integration of smooth functions.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(integration_class_1d), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in) | :: | lb | lower bound of the integration |
||
real(kind=wp), | intent(in) | :: | ub | upper bound of the integration |
||
real(kind=wp), | intent(in) | :: | error_tol | is a requested pseudorelative error tolerance. normally pick a value of abs(error_tol) so that dtol < abs(error_tol) <= 1.0e-3 where dtol is the larger of 1.0e-18 and the real(wp) unit roundoff d1mach(4). ans will normally have no more error than abs(error_tol) times the integral of the absolute value of fun(x). usually, smaller values of error_tol yield more accuracy and require more function evaluations. |
||
real(kind=wp), | intent(out) | :: | ans | computed value of integral |
||
integer, | intent(out) | :: | ierr | status code:
|
||
real(kind=wp), | intent(out) | :: | err | an estimate of the absolute error in |