quadrature-fortran
quadrature-fortran copied to clipboard
1D-6D Adaptive Gaussian Quadrature with Modern Fortran
Adaptive Gaussian Quadrature with Modern Fortran
Status
Brief description
An object-oriented modern Fortran library to integrate functions using adaptive Gaussian quadrature. There are five selectable methods to use:
- Adaptive 6-point Legendre-Gauss
- Adaptive 8-point Legendre-Gauss
- Adaptive 10-point Legendre-Gauss
- Adaptive 12-point Legendre-Gauss
- Adaptive 14-point Legendre-Gauss
The library supports:
1D integration: $$\int_{x_l}^{x_u} f(x) dx$$ 2D integration: $$\int_{y_l}^{y_u} \int_{x_l}^{x_u} f(x,y) dx dy$$ 3D integration: $$\int_{z_l}^{z_u} \int_{y_l}^{y_u} \int_{x_l} ^{x_u} f(x,y,z) dx dy dz$$ 4D integration: $$\int_{q_l}^{q_u} \int_{z_l}^{z_u} \int_{y_l} ^{y_u} \int_{x_l}^{x_u} f(x,y,z,q) dx dy dz dq$$ 5D integration: $$\int_{r_l}^{r_u} \int_{q_l}^{q_u} \int_{z_l} ^{z_u} \int_{y_l}^{y_u} \int_{x_l}^{x_u} f(x, y,z,q,r) dx dy dz dq dr$$ 6D integration: $$\int_{s_l}^{s_u} \int_{r_l}^{r_u} \int_{q_l} ^{q_u} \int_{z_l}^{z_u} \int_{y_l}^{y_u} \int_ {x_l}^{x_u} f(x,y,z,q,r,s) dx dy dz dq dr ds$$
The core code is based on the SLATEC routine DGAUS8 (which is the source of the 8-point routine). Coefficients for the others were obtained from here. The original 1D code has been generalized for multi-dimensional integration.
Compiling
A Fortran Package Manager manifest file is included, so that the library and test cases can be compiled with FPM. For example:
fpm build --profile release
fpm test --profile release
By default, the library is built with double precision (real64) real values. Explicitly specifying the real kind can be done using the following preprocessor flags:
| Preprocessor flag | Kind | Number of bytes |
|---|---|---|
REAL32 |
real(kind=real32) |
4 |
REAL64 |
real(kind=real64) |
8 |
REAL128 |
real(kind=real128) |
16 |
For example, to build a single precision version of the library, use:
fpm build --profile release --flag "-DREAL32"
To use quadrature-fortran within your fpm project, add the following to your fpm.toml file:
[dependencies]
quadrature-fortran = { git="https://github.com/jacobwilliams/quadrature-fortran.git" }
or, to use a specific version:
[dependencies]
quadrature-fortran = { git="https://github.com/jacobwilliams/quadrature-fortran.git", tag = "1.0.0" }
Documentation
The API documentation for the current master branch can be found here. This is generated by processing the source files with FORD.
License
The quadrature-fortran source code and related files and documentation are distributed under a permissive free software license (BSD-style).
See also
- quadpack -- Modern Fortran QUADPACK Library for 1D numerical quadrature
Keywords
- adaptive quadrature, automatic integrator, gauss quadrature, numerical integration
