integration_class_1d Derived Type

type, public, extends(integration_class) :: integration_class_1d

single integration class: for 1d integration of f(x)


Inherits

type~~integration_class_1d~~InheritsGraph type~integration_class_1d integration_class_1d type~integration_class integration_class type~integration_class_1d->type~integration_class

Inherited by

type~~integration_class_1d~~InheritedByGraph type~integration_class_1d integration_class_1d type~integration_class_6d integration_class_6d type~integration_class_6d->type~integration_class_1d is, ir, iq, iz, iy, ix type~integration_class_3d integration_class_3d type~integration_class_3d->type~integration_class_1d iz, iy, ix type~integration_class_2d integration_class_2d type~integration_class_2d->type~integration_class_1d iy, ix type~integration_class_4d integration_class_4d type~integration_class_4d->type~integration_class_1d iq, iz, iy, ix type~integration_class_5d integration_class_5d type~integration_class_5d->type~integration_class_1d ir, iq, iz, iy, ix

Contents

Source Code


Components

TypeVisibilityAttributesNameInitial
procedure(func_1d), public, pointer:: fun=> null()

function f(x) to be integrated

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 x. Only used for multiple integration to pass to the inner integrals


Type-Bound Procedures

procedure, public :: dgauss_generic

core integration routine. refactored from SLATEC with selectable quadrature method

  • private recursive subroutine dgauss_generic(me, lb, ub, error_tol, ans, ierr, 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.

    Read more…

    Arguments

    TypeIntentOptionalAttributesName
    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:

    • normal codes:
    • 1 : ans most likely meets requested error tolerance, or lb=ub.
    • -1 : lb and ub are too nearly equal to allow normal integration. ans is set to zero.
    • abnormal code:
    • 2 : ans probably does not meet requested error tolerance.
    real(kind=wp), intent(out) :: err

    an estimate of the absolute error in ans. the estimated error is solely for information to the user and should not be used as a correction to the computed integral.

procedure, public :: initialize => initialize_integration_class

to set up the class

  • private subroutine initialize_integration_class(me, fx, xl, xu, tolx, methodx)

    Initialize the 1D integration class. Must be called before integration is performed.

    Arguments

    TypeIntentOptionalAttributesName
    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

procedure, public :: integrate => integrate_1d

to integrate the function fun

  • private subroutine integrate_1d(me, ans, ierr, err)

    Perform the 1D integration.

    Arguments

    TypeIntentOptionalAttributesName
    class(integration_class_1d), intent(inout) :: me
    real(kind=wp), intent(out) :: ans
    integer, intent(out) :: ierr
    real(kind=wp), intent(out) :: err

Source Code

    type,extends(integration_class),public :: integration_class_1d
        !! single integration class: for 1d integration of `f(x)`

        private

        procedure(func_1d),pointer :: fun => null()  !! function `f(x)` to be integrated

        procedure(gauss_func),pointer :: g => null()  !! the guass quadrature formula to use
        real(wp) :: a      = zero      !! lower limit of integration
        real(wp) :: b      = zero      !! upper limit of integration (may be less than a)
        real(wp) :: tol    = zero      !! the requested relative error tolerance.

        real(wp) :: val = zero   !! the value of `x`. Only used for multiple
                                 !! integration to pass to the inner integrals

        contains

        private

        procedure :: 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 `fun`

    end type integration_class_1d