specialmatrices_hankel Module


Uses


Interfaces

public interface Hankel

This interface provides methods to construct Hankel matrices. Given a vector vc specifying the first column of the matrix and a vector vr specifying its last row, the associated Hankel matrix is the following matrix

Syntax

   integer, parameter :: m = 100, n = 200
   real(dp) :: vc(n), vr(n)
   type(Hankel) :: A

   call random_number(vc) ; call random_number(vr)
   A = hankel(Hc, vr)

Warning

The element is read from the last entry of the vector vc. The first entry of vr is not referenced.

Note

Only double precision is currently supported for this matrix type.

  • private pure module function construct(v, m, n) result(A)

    Construct a Hankel matrix from the rank-1 arrays vc and vr.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: v(:)

    Generating vector.

    integer(kind=ilp), intent(in) :: m

    Dimensions of the matrix.

    integer(kind=ilp), intent(in) :: n

    Dimensions of the matrix.

    Return Value type(Hankel)

    Corresponding hankel matrix.

public interface dense

Convert a Hankel matrix to a standard rank-2 array.

Syntax

   B = dense(A)

Arguments

  • A : Matrix of Hankel type. It is an intent(in) argument.

  • B : Rank-2 array representation of the matrix .

  • private pure module function dense_rdp(A) result(B)

    Utility function to convert a Hankel matrix to a rank-2 array.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input diagonal matrix.

    Return Value real(kind=dp), allocatable, (:,:)

    Output dense rank-2 array.

public interface eigh

This interface overloads the eigh interface from stdlib_linalg to compute the eigenvalues and eigenvectors of a real-valued matrix whose type is Hankel.

Syntax

   call eigh(A, lambda [, left] [, right])

Arguments

  • A : real-valued matrix of Hankel. It is an intent(in) argument.

  • lambda : Rank-1 real array returning the eigenvalues of A in increasing order. It is an intent(out) argument.

  • vectors (optional) : real rank-2 array of the same kind as A returning the left eigenvectors of A. It is an intent(out) argument.

Note

No analytic expression exist for the eigendecomposition of a general hankel matrix. Under the hood, the matrix A is converted to its dense representation and the function eigh from stdlib_linalg is used.

  • private module subroutine eigh_rdp(A, lambda, vectors)

    Utility function to compute the eigenvalues and eigenvectors of a Hankel matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input matrix.

    real(kind=dp), intent(out) :: lambda(:)

    Eigenvalues.

    real(kind=dp), intent(out), optional :: vectors(:,:)

    Eigenvectors.

public interface eigvalsh

This interface overloads the eigvals interface from stdlib_linalg to compute the eigenvalues of a real-valued matrix whose type is Hankel.

Syntax

   lambda = eigvals(A)

Arguments

  • A : real-valued matrix of Hankel type. It is an intent(in) argument.

  • lambda : Vector of eigenvalues in increasing order.

Note

No analytic expression exist for the eigenvalues of a general Hankel matrix. Under the hood, the matrix A is converted to its dense representation and the function eigvals from stdlib_linalg is used.

  • private module function eigvalsh_rdp(A) result(lambda)

    Utility function to compute the eigenvalues of a real Hankel matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input matrix.

    Return Value real(kind=dp), allocatable, (:)

    Eigenvalues.

public interface matmul

This interface overloads the Fortran intrinsic matmul for a Hankel matrix, both for matrix-vector and matrix-matrix products. For a matrix-matrix product , only the matrix has to be a Hankel matrix. Both and need to be standard Fortran rank-2 arrays. All the underlying functions are defined as pure.

Syntax

   y = matmul(A, x)

Note

Matrix-vector products for Hankel matrices can be efficiently computed by transforming the matrix into a Toeplitz one and embedding the Toeplitz matrix into a Circulant matrix of size [m+n x m+n] and using the Fast Fourier Transform provided by fftpack.

  • private pure module function spmv(A, x) result(y)

    Compute the matrix-vector product for a Hankel matrix . Both x and y are rank-1 arrays with the same kind as A.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input matrix.

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

    Input vector.

    Return Value real(kind=dp), allocatable, (:)

    Output vector.

  • private pure module function spmvs(A, x) result(y)

    Compute the matrix-matrix product for a Hankel matrix A. Both X and Y are rank-2 arrays with the same kind as A.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input matrix.

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

    Input matrix.

    Return Value real(kind=dp), allocatable, (:,:)

    Output matrix.

public interface operator(*)

  • private pure module function scalar_multiplication_bis_rdp(A, alpha) result(B)

    Utility function to perform a scalar multiplication with a Hankel matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A
    real(kind=dp), intent(in) :: alpha

    Return Value type(Hankel)

  • private pure module function scalar_multiplication_rdp(alpha, A) result(B)

    Utility function to perform a scalar multiplication with a Hankel matrix.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=dp), intent(in) :: alpha
    type(Hankel), intent(in) :: A

    Return Value type(Hankel)

public interface shape

Utility function to return the size of a Hankel matrix.

  • private pure module function shape_rdp(A) result(arr_shape)

    Utility function to get the shape of a Hankel matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input matrix.

    Return Value integer(kind=ilp), (2)

    Shape of the matrix.

public interface size

Utility function to return the size of Hankel matrix along a given dimension.

  • private pure module function size_rdp(A, dim) result(arr_size)

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input matrix.

    integer(kind=ilp), intent(in), optional :: dim

    Queried dimension.

    Return Value integer(kind=ilp)

    Size of the matrix along the dimension dim.

public interface solve

This interface overloads the solve interface from stdlib_linalg for solving a linear system where is a Hankel matrix. It also enables to solve a linear system with multiple right-hand sides.

Syntax

To solve a system with being of type Hankel:

   x = solve(A, b)

Arguments

  • A : Matrix of Hankel type. It is an intent(in) argument.

  • b : Rank-1 or rank-2 array defining the right-hand side(s). It is an intent(in) argument.

  • x : Solution of the linear system. It has the same type and shape as b.

Note

Under the hood, a gmres solver is being used along with a Circulant preconditioner. By design, gmres is run until a relative tolerance of is reached.

  • private pure module function solve_multi_rhs(A, B) result(X)

    Solve the linear system , where A is Hankel and B is a rank-2 array. The solution matrix X has the same dimension and kind as the right-hand side matrix B.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Coefficient matrix.

    real(kind=dp), intent(in) :: B(:,:)

    Right-hand side vectors.

    Return Value real(kind=dp), allocatable, (:,:)

    Solution vectors.

  • private pure module function solve_single_rhs(A, b) result(x)

    Solve the linear system where is Hankel and b a standard rank-1 array. The solution vector x has the same dimension and kind as the right-hand side vector b.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Coefficient matrix.

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

    Right-hand side vector.

    Return Value real(kind=dp), allocatable, (:)

    Solution vector.

public interface svd

This interface overloads the svd interface from stdlib_linalg to compute the the singular value decomposition of a Hankel matrix .

Syntax

   call svd(A, s, u, vt)

Arguments

  • A : Matrix of Hankel type. It is an intent(in) argument.

  • s : Rank-1 array real array returning the singular values of A. It is an intent(out) argument.

  • u (optional) : Rank-2 array of the same kind as A returning the left singular vectors of A as columns. Its size should be [n, n]. It is an intent(out) argument.

  • vt (optional) : Rank-2 array of the same kind as A returning the right singular vectors of A as rows. Its size should be [n, n]. It is an intent(out) argument.

Note

No analytic expression exist for the singular value of a general Hankel matrix. Under the hood, the matrix A is converted to its dense representation and the function svdvals from stdlib_linalg is used.

  • private module subroutine svd_rdp(A, s, u, vt)

    Compute the singular value decomposition of a Hankel matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input matrix.

    real(kind=dp), intent(out) :: s(:)

    Singular values in descending order.

    real(kind=dp), intent(out), optional :: u(:,:)

    Left singular vectors as columns.

    real(kind=dp), intent(out), optional :: vt(:,:)

    Right singular vectors as rows.

public interface svdvals

This interface overloads the svdvals interface from stdlib_linalg to compute the singular values of a Hankel matrix .

Syntax

   s = svdvals(A)

Arguments

  • A : Matrix of Hankel type. It is an intent(in) argument.

  • s : Vector of singular values sorted in decreasing order.

Note

No analytic expression exist for the singular values of a general Hankel matrix. Under the hood, the matrix A is converted to its dense representation and the function svdvals from stdlib_linalg is used.

  • private module function svdvals_rdp(A) result(s)

    Compute the singular values of a hankel matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input matrix.

    Return Value real(kind=dp), allocatable, (:)

    Singular values in descending order.

public interface transpose

This interface overloads the Fortran intrinsic procedure to define the transpose operation of a Hankel matrix.

Syntax

   B = transpose(A)

Arguments

  • A : Matrix of Hankel type. It is an intent(in) argument.

  • B : Resulting transposed matrix. It is of the same type as A.

  • private pure module function transpose_rdp(A) result(B)

    Utility function to compute the transpose of a hankel matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Hankel), intent(in) :: A

    Input matrix.

    Return Value type(Hankel)

    Transpose of the matrix.


Derived Types

type, public ::  Hankel

Base type to define a Hankel matrix of size [m x n] generate from the vector v.

Constructor

This interface provides methods to construct Hankel matrices. Given a vector vc specifying the first column of the matrix and a vector vr specifying its last row, the associated Hankel matrix is the following matrix

Read more…
private pure, module function construct (v, m, n)

Construct a Hankel matrix from the rank-1 arrays vc and vr.