qr Interface

public interface qr

Description

Given an array of types derived from abstract_vector, it computes the in-place QR factorization of , i.e.

where is an orthonormal arrays of vectors such that and is upper triangular. Note that it can also perform the QR factorization with column pivoting

where is a permutation matrix ensuring that the diagonal entries of have non-increasing absolute values. This amounts to using the pivoting QR as a rank-revealing factorization.

References

  • G. H. Golub & C. F. Van Loan. "Matrix Computations". 4th edition, The John Hopkins University Press, 2013. See Chapter 5.2.8: Modified Gram-Schmidt algorithm.

Syntax

    call qr(Q [, R] [, perm], info [, tol])

Arguments

Q: Array of types derived from one of the base types provided in the AbstractVectors module. On entry, it contains the original array. On exit, it is overwritten by the orthogonal basis for its span. It is an intent(inout) argument.

R: real or complex rank-2 array. On exit, its contains the upper triangular matrix resulting from the QR factorization. It is an intent(out) argument.

perm (optional): Rank-1 array of integer corresponding to the indices of permuted columns. If perm is absent, the naive QR factorization is being computed.

info: integer information flag.

tol (optional): Numerical tolerance to determine whether two vectors are colinear or not. Default tol = atol_sp or tol = atol_dp.


Module Procedures

private subroutine qr_no_pivoting_rsp(Q, R, info, tol)

Arguments

Type IntentOptional Attributes Name
class(abstract_vector_rsp), intent(inout) :: Q(:)

Array of abstract_vector to be orthogonalized.

real(kind=sp), intent(out) :: R(:,:)

Upper triangular matrix resulting from the QR factorization.

integer, intent(out) :: info

Information flag.

real(kind=sp), intent(in), optional :: tol

Tolerance to determine colinearity.

private subroutine qr_with_pivoting_rsp(Q, R, perm, info, tol)

Arguments

Type IntentOptional Attributes Name
class(abstract_vector_rsp), intent(inout) :: Q(:)

Array of abstract_vector to be orthogonalized.

real(kind=sp), intent(out) :: R(:,:)

Upper triangular matrix resulting from the QR factorization.

integer, intent(out) :: perm(size(Q))

Permutation matrix.

integer, intent(out) :: info

Information flag.

real(kind=sp), intent(in), optional :: tol

Tolerance to detect colinearity.

private subroutine qr_no_pivoting_rdp(Q, R, info, tol)

Arguments

Type IntentOptional Attributes Name
class(abstract_vector_rdp), intent(inout) :: Q(:)

Array of abstract_vector to be orthogonalized.

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

Upper triangular matrix resulting from the QR factorization.

integer, intent(out) :: info

Information flag.

real(kind=dp), intent(in), optional :: tol

Tolerance to determine colinearity.

private subroutine qr_with_pivoting_rdp(Q, R, perm, info, tol)

Arguments

Type IntentOptional Attributes Name
class(abstract_vector_rdp), intent(inout) :: Q(:)

Array of abstract_vector to be orthogonalized.

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

Upper triangular matrix resulting from the QR factorization.

integer, intent(out) :: perm(size(Q))

Permutation matrix.

integer, intent(out) :: info

Information flag.

real(kind=dp), intent(in), optional :: tol

Tolerance to detect colinearity.

private subroutine qr_no_pivoting_csp(Q, R, info, tol)

Arguments

Type IntentOptional Attributes Name
class(abstract_vector_csp), intent(inout) :: Q(:)

Array of abstract_vector to be orthogonalized.

complex(kind=sp), intent(out) :: R(:,:)

Upper triangular matrix resulting from the QR factorization.

integer, intent(out) :: info

Information flag.

real(kind=sp), intent(in), optional :: tol

Tolerance to determine colinearity.

private subroutine qr_with_pivoting_csp(Q, R, perm, info, tol)

Arguments

Type IntentOptional Attributes Name
class(abstract_vector_csp), intent(inout) :: Q(:)

Array of abstract_vector to be orthogonalized.

complex(kind=sp), intent(out) :: R(:,:)

Upper triangular matrix resulting from the QR factorization.

integer, intent(out) :: perm(size(Q))

Permutation matrix.

integer, intent(out) :: info

Information flag.

real(kind=sp), intent(in), optional :: tol

Tolerance to detect colinearity.

private subroutine qr_no_pivoting_cdp(Q, R, info, tol)

Arguments

Type IntentOptional Attributes Name
class(abstract_vector_cdp), intent(inout) :: Q(:)

Array of abstract_vector to be orthogonalized.

complex(kind=dp), intent(out) :: R(:,:)

Upper triangular matrix resulting from the QR factorization.

integer, intent(out) :: info

Information flag.

real(kind=dp), intent(in), optional :: tol

Tolerance to determine colinearity.

private subroutine qr_with_pivoting_cdp(Q, R, perm, info, tol)

Arguments

Type IntentOptional Attributes Name
class(abstract_vector_cdp), intent(inout) :: Q(:)

Array of abstract_vector to be orthogonalized.

complex(kind=dp), intent(out) :: R(:,:)

Upper triangular matrix resulting from the QR factorization.

integer, intent(out) :: perm(size(Q))

Permutation matrix.

integer, intent(out) :: info

Information flag.

real(kind=dp), intent(in), optional :: tol

Tolerance to detect colinearity.