fordiff Module

Module for numerical differentiation using complex step differentiation and finite difference methods


Used by

  • module~~fordiff~~UsedByGraph module~fordiff fordiff module~mod_func1 mod_func1 module~mod_func1->module~fordiff module~mod_func2 mod_func2 module~mod_func2->module~fordiff module~mod_func3 mod_func3 module~mod_func3->module~fordiff module~mod_func4 mod_func4 module~mod_func4->module~fordiff module~mod_func5 mod_func5 module~mod_func5->module~fordiff module~mod_func6 mod_func6 module~mod_func6->module~fordiff program~demo1 demo1 program~demo1->module~fordiff program~demo2 demo2 program~demo2->module~fordiff program~demo3 demo3 program~demo3->module~fordiff program~test1 test1 program~test1->module~fordiff program~test1->module~mod_func1 program~test2 test2 program~test2->module~fordiff program~test2->module~mod_func2 program~test3 test3 program~test3->module~fordiff program~test3->module~mod_func3 program~test4 test4 program~test4->module~fordiff program~test4->module~mod_func4 program~test5 test5 program~test5->module~fordiff program~test5->module~mod_func5 program~test6 test6 program~test6->module~fordiff program~test6->module~mod_func6

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: rk = selected_real_kind(15)

Interfaces

public interface derivative

Derivative interface

  • private impure function complex_step_derivative_T0_T0(f, x, h) result(dfdx)

    Author
    Seyed Ali Ghasemi
    License
    BSD 3-Clause

    Calculates the derivative of a scalar-valued function w.r.t. a scalar-valued variable using complex step differentiation.

    Arguments

    Type IntentOptional Attributes Name
    private impure function f(z) result(fz)
    Arguments
    Type IntentOptional Attributes Name
    complex(kind=rk), intent(in) :: z

    scalar complex variable

    Return Value complex(kind=rk)

    scalar complex function

    real(kind=rk), intent(in) :: x

    scalar variable

    real(kind=rk), intent(in) :: h

    perturbation for complex step differentiation

    Return Value real(kind=rk)

    derivative of w.r.t.

  • private impure function complex_step_derivative_T0_T1(f, x, h) result(dfdx)

    Author
    Seyed Ali Ghasemi
    License
    BSD 3-Clause

    Calculates the derivative of a scalar-valued function w.r.t. a vector-valued variable using complex step differentiation.

    Arguments

    Type IntentOptional Attributes Name
    private impure function f(z) result(fz)
    Arguments
    Type IntentOptional Attributes Name
    complex(kind=rk), intent(in), dimension(:) :: z

    vector complex variable

    Return Value complex(kind=rk)

    scalar complex function

    real(kind=rk), intent(in), dimension(:) :: x

    vector variable

    real(kind=rk), intent(in) :: h

    perturbation for complex step differentiation

    Return Value real(kind=rk), dimension(size(x))

    derivative of w.r.t.

  • private impure function complex_step_derivative_T1_T1(f, x, h) result(dfdx)

    Author
    Seyed Ali Ghasemi
    License
    BSD 3-Clause

    Calculates the derivative of a vector-valued function w.r.t. a vector-valued variable using complex step differentiation.

    Arguments

    Type IntentOptional Attributes Name
    private impure function f(z) result(fz)
    Arguments
    Type IntentOptional Attributes Name
    complex(kind=rk), intent(in), dimension(:) :: z

    vector complex variable

    Return Value complex(kind=rk), dimension(:), allocatable

    vector complex function

    real(kind=rk), intent(in), dimension(:) :: x

    vector variable

    real(kind=rk), intent(in) :: h

    perturbation for complex step differentiation

    Return Value real(kind=rk), dimension(:,:), allocatable

    derivative of w.r.t.

  • private impure function finite_difference_T0_T0(f, x, h, method) result(dfdx)

    Author
    Seyed Ali Ghasemi
    License
    BSD 3-Clause

    Calculates the derivative of a scalar-valued function w.r.t. a scalar-valued variable using finite difference methods (forward, backward, central).

    Arguments

    Type IntentOptional Attributes Name
    private impure function f(z) result(fz)
    Arguments
    Type IntentOptional Attributes Name
    real(kind=rk), intent(in) :: z

    scalar variable

    Return Value real(kind=rk)

    scalar function

    real(kind=rk), intent(in) :: x

    scalar variable

    real(kind=rk), intent(in) :: h

    perturbation for finite difference methods

    character(len=*), intent(in) :: method

    finite difference method (forward, backward, central)

    Return Value real(kind=rk)

    derivative of w.r.t.

  • private impure function finite_difference_T0_T1(f, x, h, method) result(dfdx)

    Author
    Seyed Ali Ghasemi
    License
    BSD 3-Clause

    Calculates the derivative of a scalar-valued function w.r.t. a vector-valued variable using finite difference methods (forward, backward, central).

    Arguments

    Type IntentOptional Attributes Name
    private impure function f(z) result(fz)
    Arguments
    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), dimension(:) :: z

    vector variable

    Return Value real(kind=rk)

    scalar function

    real(kind=rk), intent(in), dimension(:) :: x

    vector variable

    real(kind=rk), intent(in) :: h

    perturbation for finite difference methods

    character(len=*), intent(in) :: method

    finite difference method (forward, backward, central)

    Return Value real(kind=rk), dimension(size(x))

    derivative of w.r.t.

  • private impure function finite_difference_T1_T1(f, x, h, method) result(dfdx)

    Author
    Seyed Ali Ghasemi
    License
    BSD 3-Clause

    Calculates the derivative of a vector-valued function w.r.t. a vector-valued variable using finite difference methods (forward, backward, central).

    Arguments

    Type IntentOptional Attributes Name
    private impure function f(z) result(fz)
    Arguments
    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), dimension(:) :: z

    vector variable

    Return Value real(kind=rk), dimension(:), allocatable

    vector function

    real(kind=rk), intent(in), dimension(:) :: x

    vector variable

    real(kind=rk), intent(in) :: h

    perturbation for finite difference methods

    character(len=*), intent(in) :: method

    finite difference method (forward, backward, central)

    Return Value real(kind=rk), dimension(:,:), allocatable

    derivative of w.r.t.


Functions

private impure function complex_step_derivative_T0_T0(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a scalar-valued variable using complex step differentiation.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
complex(kind=rk), intent(in) :: z

scalar complex variable

Return Value complex(kind=rk)

scalar complex function

real(kind=rk), intent(in) :: x

scalar variable

real(kind=rk), intent(in) :: h

perturbation for complex step differentiation

Return Value real(kind=rk)

derivative of w.r.t.

private impure function complex_step_derivative_T0_T1(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a vector-valued variable using complex step differentiation.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
complex(kind=rk), intent(in), dimension(:) :: z

vector complex variable

Return Value complex(kind=rk)

scalar complex function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for complex step differentiation

Return Value real(kind=rk), dimension(size(x))

derivative of w.r.t.

private impure function complex_step_derivative_T1_T1(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a vector-valued function w.r.t. a vector-valued variable using complex step differentiation.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
complex(kind=rk), intent(in), dimension(:) :: z

vector complex variable

Return Value complex(kind=rk), dimension(:), allocatable

vector complex function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for complex step differentiation

Return Value real(kind=rk), dimension(:,:), allocatable

derivative of w.r.t.

private impure function finite_difference_T0_T0(f, x, h, method) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a scalar-valued variable using finite difference methods (forward, backward, central).

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: z

scalar variable

Return Value real(kind=rk)

scalar function

real(kind=rk), intent(in) :: x

scalar variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

character(len=*), intent(in) :: method

finite difference method (forward, backward, central)

Return Value real(kind=rk)

derivative of w.r.t.

private impure function finite_difference_T0_T1(f, x, h, method) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a vector-valued variable using finite difference methods (forward, backward, central).

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: z

vector variable

Return Value real(kind=rk)

scalar function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

character(len=*), intent(in) :: method

finite difference method (forward, backward, central)

Return Value real(kind=rk), dimension(size(x))

derivative of w.r.t.

private impure function finite_difference_T1_T1(f, x, h, method) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a vector-valued function w.r.t. a vector-valued variable using finite difference methods (forward, backward, central).

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: z

vector variable

Return Value real(kind=rk), dimension(:), allocatable

vector function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

character(len=*), intent(in) :: method

finite difference method (forward, backward, central)

Return Value real(kind=rk), dimension(:,:), allocatable

derivative of w.r.t.

private impure function finite_difference_backward_T0_T0(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a scalar-valued variable using the backward finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: z

scalar variable

Return Value real(kind=rk)

scalar function

real(kind=rk), intent(in) :: x

scalar variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

Return Value real(kind=rk)

derivative of w.r.t.

private impure function finite_difference_backward_T0_T1(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a vector-valued variable using the backward finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: z

vector variable

Return Value real(kind=rk)

scalar function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

Return Value real(kind=rk), dimension(size(x))

derivative of w.r.t.

private impure function finite_difference_backward_T1_T1(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a vector-valued function w.r.t. a vector-valued variable using the backward finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: z

vector variable

Return Value real(kind=rk), dimension(:), allocatable

vector function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

Return Value real(kind=rk), dimension(:,:), allocatable

derivative of w.r.t.

private impure function finite_difference_central_T0_T0(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a scalar-valued variable using the central finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: z

scalar variable

Return Value real(kind=rk)

scalar function

real(kind=rk), intent(in) :: x

scalar variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

Return Value real(kind=rk)

derivative of w.r.t.

private impure function finite_difference_central_T0_T1(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a vector-valued variable using the central finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: z

vector variable

Return Value real(kind=rk)

scalar function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

Return Value real(kind=rk), dimension(size(x))

derivative of w.r.t.

private impure function finite_difference_central_T1_T1(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a vector-valued function w.r.t. a vector-valued variable using the central finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: z

vector variable

Return Value real(kind=rk), dimension(:), allocatable

vector function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

Return Value real(kind=rk), dimension(:,:), allocatable

derivative of w.r.t.

private impure function finite_difference_forward_T0_T0(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a scalar-valued variable using the forward finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: z

scalar variable

Return Value real(kind=rk)

scalar function

real(kind=rk), intent(in) :: x

scalar variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

Return Value real(kind=rk)

derivative of w.r.t.

private impure function finite_difference_forward_T0_T1(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a scalar-valued function w.r.t. a vector-valued variable using the forward finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: z

vector variable

Return Value real(kind=rk)

scalar function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

Return Value real(kind=rk), dimension(size(x))

derivative of w.r.t.

private impure function finite_difference_forward_T1_T1(f, x, h) result(dfdx)

Author
Seyed Ali Ghasemi
License
BSD 3-Clause

Calculates the derivative of a vector-valued function w.r.t. a vector-valued variable using the forward finite difference method.

Arguments

Type IntentOptional Attributes Name
private impure function f(z) result(fz)
Arguments
Type IntentOptional Attributes Name
real(kind=rk), intent(in), dimension(:) :: z

vector variable

Return Value real(kind=rk), dimension(:), allocatable

vector function

real(kind=rk), intent(in), dimension(:) :: x

vector variable

real(kind=rk), intent(in) :: h

perturbation for finite difference methods

Return Value real(kind=rk), dimension(:,:), allocatable

derivative of w.r.t.