Giter VIP home page Giter VIP logo

quadrature-fortran's Introduction

quadrature-fortran

Adaptive Gaussian Quadrature with Modern Fortran

Status

GitHub release CI Status codecov last-commit

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

quadrature-fortran's People

Contributors

jacobwilliams avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

quadrature-fortran's Issues

0.30102000

Is this supposed to be log10(2.0_wp)? That would be 0.3010299957.

Quadrature on the semi-infinite interval (improper integrals)

I'm looking for a code which supports quadrature on the interval [a,Inf). From a quick glance at the code, I don't think this is supported currently?

The only Fortran code I've found so far for the semi-infinite interval is QAGI subroutine in QUADPACK. It uses a transformation of the interval [a,Inf) to the range [0,1] and then relies upon a 15-point Kronrod rule. Error estimates are provided by comparison with a 7-point Gauss rule.

The MATLAB built-in method integrate has support also for the semi-infinite interval. It uses a method from Shampine described in:

Shampine, L. F. (2008). Vectorized adaptive quadrature in MATLAB. Journal of Computational and Applied Mathematics, 211(2), 131-140. https://doi.org/10.1016/j.cam.2006.11.021

The code first checks if the upper (or lower bounds) are equal to Infinity, and adapts accordingly.

I'm not sure how difficult it would be to modify the integrate methods to also cover the semi-infinite interval, or should this be deferred to a specialist routine (like in QUADPACK). MATLAB cites user-friendliness as the reason for having both cases under the same interface.

Would it be reasonable if I submit a PR adding a comment the bounds x_l, x_u are expected to be finite?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.