math_m Module

This file provides a common interface to a large library of mathematical functions and subroutines. See the documentation of individual interfaces below for more information about the contents of the mathematical library.



Contents


Interfaces

public interface trace

Public interface for functions that calculate a matrix trace.

  • public pure function matrix_trace(A) result(r)

    Calculate the trace of a general complex matrix.

    Arguments

    Type IntentOptional AttributesName
    complex(kind=wp), intent(in), dimension(:,:):: A

    Matrix [n×m]

    Return Value complex(kind=wp)

    r = Tr(A)

public interface inverse

Public interface for functions that calculate a matrix inverse.

  • public pure function matrix_inverse_re(A) result(R)

    Wrapper for matrix_inverse_cx that allows the procedure to be used for real matrices.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:,:):: A

    Matrix A [n×n]

    Return Value real(kind=wp), dimension(size(A,1),size(A,1))

    Matrix R=A¯¹

  • public pure function matrix_inverse_cx(A) result(R)

    Invert a square n×n matrix using Gauss-Jordan elimination with partial pivoting. In the special case n=2, the inverse is evaluated using a cofactoring algorithm. [This implementation is based on Algorithm #2 in "Efficient matrix inversion via Gauss-Jordan elimination and its parallelization" by E.S. Quintana et al. (1998)]

    Arguments

    Type IntentOptional AttributesName
    complex(kind=wp), intent(in), dimension(:,:):: A

    Matrix A [n×n]

    Return Value complex(kind=wp), dimension(size(A,1),size(A,1))

    Matrix R=A¯¹

public interface diag

Public interface for functions that deal with matrix diagonals.

  • public pure function matrix_diag(A, B) result(R)

    Construct a block-diagonal matrix R from two general matrices A and B.

    Arguments

    Type IntentOptional AttributesName
    complex(kind=wp), intent(in), dimension(:,:):: A

    Left matrix [n×m]

    complex(kind=wp), intent(in), dimension(:,:):: B

    Right matrix [p×q]

    Return Value complex(kind=wp), dimension(size(A,1)+size(B,1), size(A,2)+size(B,2))

    R = Diag(A,B)

  • public pure function vector_diag(A) result(r)

    Extract the diagonal of a general complex matrix.

    Arguments

    Type IntentOptional AttributesName
    complex(kind=wp), intent(in), dimension(:,:):: A

    Matrix [n×m]

    Return Value complex(kind=wp), dimension(min(size(A,1),size(A,2)))

    r = Diag(A)

public interface mean

Public interface for routines that calculate the mean value.

  • public pure function mean_array_re(x) result(r)

    Calculates the mean value of a real-valued array.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Real-valued array

    Return Value real(kind=wp)

    Mean value

  • public pure function mean_array_cx(x) result(r)

    Calculates the mean value of a complex-valued array.

    Arguments

    Type IntentOptional AttributesName
    complex(kind=wp), intent(in), dimension(:):: x

    Complex-valued array

    Return Value complex(kind=wp)

    Mean value

public interface differentiate

Public interface for various differentiation routines.

  • public pure function differentiate_array_re(x, y) result(r)

    This function calculates the numerical derivative of an array y with respect to x, using a central difference approximation at the interior points and forward/backward difference approximations at the exterior points. Note that since all the three approaches yield two-point approximations of the derivative, the mesh spacing of x does not necessarily have to be uniform.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    real(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

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

    Derivative dy/dx

  • public pure function differentiate_array_cx(x, y) result(r)

    Complex version of differentiate_array_re.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    complex(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

    Return Value complex(kind=wp), dimension(size(x))

    Derivative dy/dx

public interface integrate

Public interface for various integration routines.

  • public pure function integrate_array_re(x, y) result(r)

    This function calculates the integral of an array y with respect to x using a trapezoid approximation. Note that the mesh spacing of x does not necessarily have to be uniform.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    real(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

    Return Value real(kind=wp)

    Integral ∫y(x)·dx

  • public pure function integrate_array_cx(x, y) result(r)

    Complex version of integrate_array_re.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    complex(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

    Return Value complex(kind=wp)

    Integral ∫y(x)·dx

  • public function integrate_range_re(x, y, a, b) result(r)

    This function constructs a piecewise hermitian cubic interpolation of an array y(x) based on discrete numerical data, and subsequently evaluates the integral of the interpolation in the range (a,b). Note that the mesh spacing of x does not necessarily have to be uniform.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    real(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

    real(kind=wp), intent(in) :: a

    Left endpoint

    real(kind=wp), intent(in) :: b

    Right endpoint

    Return Value real(kind=wp)

    Integral ∫y(x)·dx

  • public function integrate_range_cx(x, y, a, b) result(r)

    Complex version of integrate_range_re.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    complex(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

    real(kind=wp), intent(in) :: a

    Left endpoint

    real(kind=wp), intent(in) :: b

    Right endpoint

    Return Value complex(kind=wp)

    Integral ∫y(x)·dx

public interface interpolate

Public interface for various interpolation routines.

  • public function interpolate_point_re(x, y, p) result(r)

    Wrapper for interpolate_array_re that accepts scalar arguments.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    real(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

    real(kind=wp), intent(in) :: p

    Interpolation point p

    Return Value real(kind=wp)

    Interpolation result y(p)

  • public function interpolate_point_cx(x, y, p) result(r)

    Complex version of interpolate_point_re.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    complex(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

    real(kind=wp), intent(in) :: p

    Interpolation point p

    Return Value complex(kind=wp)

    Interpolation result y(p)

  • public function interpolate_array_re(x, y, p) result(r)

    This function constructs a piecewise hermitian cubic interpolation of an array y(x) based on discrete numerical data, and evaluates the interpolation at points p. Note that the mesh spacing of x does not necessarily have to be uniform.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    real(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

    real(kind=wp), intent(in), dimension(:):: p

    Interpolation domain p

    Return Value real(kind=wp), dimension(size(p))

    Interpolation result y(p)

  • public function interpolate_array_cx(x, y, p) result(r)

    Complex version of interpolate_array_re.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    complex(kind=wp), intent(in), dimension(size(x)):: y

    Function y(x)

    real(kind=wp), intent(in), dimension(:):: p

    Interpolation domain p

    Return Value complex(kind=wp), dimension(size(p))

    Interpolation result y(p)

  • public pure function interpolate_point_matrix_re(x, y, p) result(r)

    Perform a Piecewise Cubic Hermitian Interpolation of a matrix function using Catmull-Rom splines.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(in), dimension(:):: x

    Variable x

    real(kind=wp), intent(in), dimension(:,:,:):: y

    Function y(x)

    real(kind=wp), intent(in) :: p

    Interpolation point p

    Return Value real(kind=wp), dimension(size(y,1),size(y,2))

    Interpolation result y(p)

public interface linspace

Public interface for routines that initialize arrays.

  • public pure subroutine linspace_array_re(array, first, last)

    Populates an existing array with elements from first to last, inclusive.

    Arguments

    Type IntentOptional AttributesName
    real(kind=wp), intent(out), dimension(:):: array

    Output array to populate

    real(kind=wp), intent(in) :: first

    Value of first element

    real(kind=wp), intent(in) :: last

    Value of last element