pinv Interface

public interface pinv

Pseudo-inverse of a matrix (Specification)

Summary

This interface provides methods for computing the Moore-Penrose pseudo-inverse of a matrix. The pseudo-inverse is a generalization of the matrix inverse, computed for square, singular, or rectangular matrices. It is defined such that it satisfies the conditions: - - - -

Description

This function interface provides methods that return the Moore-Penrose pseudo-inverse of a matrix.
Supported data types include real and complex. The pseudo-inverse is returned as a function result. The computation is based on the singular value decomposition (SVD). An optional relative tolerance rtol is provided to control the inclusion of singular values during inversion. Singular values below are treated as zero, where is the largest singular value. If rtol is not provided, a default threshold is applied.

Exceptions are raised in case of computational errors or invalid input, and trigger an error stop if the state flag err is not provided.

Note

The provided functions are intended for both rectangular and square matrices.


Functions

private module function stdlib_linalg_pseudoinverse_c(a, rtol, err) result(pinva)

Arguments

Type IntentOptional Attributes Name
complex(kind=sp), intent(in), target :: a(:,:)

Input matrix a[m,n]

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

[optional] Relative tolerance for singular value cutoff

type(linalg_state_type), intent(out), optional :: err

[optional] State return flag. On error if not requested, the code will stop

Return Value complex(kind=sp), (size(a,2,kind=ilp),size(a,1,kind=ilp))

Output matrix pseudo-inverse [n,m]

private module function stdlib_linalg_pseudoinverse_d(a, rtol, err) result(pinva)

Arguments

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

Input matrix a[m,n]

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

[optional] Relative tolerance for singular value cutoff

type(linalg_state_type), intent(out), optional :: err

[optional] State return flag. On error if not requested, the code will stop

Return Value real(kind=dp), (size(a,2,kind=ilp),size(a,1,kind=ilp))

Output matrix pseudo-inverse [n,m]

private module function stdlib_linalg_pseudoinverse_s(a, rtol, err) result(pinva)

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(in), target :: a(:,:)

Input matrix a[m,n]

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

[optional] Relative tolerance for singular value cutoff

type(linalg_state_type), intent(out), optional :: err

[optional] State return flag. On error if not requested, the code will stop

Return Value real(kind=sp), (size(a,2,kind=ilp),size(a,1,kind=ilp))

Output matrix pseudo-inverse [n,m]

private module function stdlib_linalg_pseudoinverse_z(a, rtol, err) result(pinva)

Arguments

Type IntentOptional Attributes Name
complex(kind=dp), intent(in), target :: a(:,:)

Input matrix a[m,n]

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

[optional] Relative tolerance for singular value cutoff

type(linalg_state_type), intent(out), optional :: err

[optional] State return flag. On error if not requested, the code will stop

Return Value complex(kind=dp), (size(a,2,kind=ilp),size(a,1,kind=ilp))

Output matrix pseudo-inverse [n,m]