ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation. |
This module contains abstract and concrete derived types and procedures related to the inversion of square matrices.
More...
Data Types | |
interface | getMatInv |
Generate and return the full inverse of an input matrix of general or triangular form directly or through its input the LU/Cholesky factorization. More... | |
type | inversion_type |
This is a concrete derived type whose instances are exclusively used to request inversion operation on a given matrix within an interface of a procedure of the ParaMonte library. More... | |
interface | setMatInv |
Generate and return the full inverse of a general or triangular matrix or a subset of the inverse of a positive-definite matrix complementary to its specified Cholesky factorization subset. More... | |
Variables | |
character(*, SK), parameter | MODULE_NAME = "@pm_matrixInv" |
type(inversion_type), parameter | inversion = inversion_type() |
This is a scalar parameter object of type inversion_type that is exclusively used to request no transpose of a given matrix within an interface of a procedure of the ParaMonte library.More... | |
This module contains abstract and concrete derived types and procedures related to the inversion of square matrices.
In linear algebra, an \(n\)-by- \(n\) square matrix \(A\) is called invertible (also nonsingular, nondegenerate), if there exists an \(n\)-by- \(n\) square matrix \(B\) such that,
\begin{equation} \mathbf{AB} = \mathbf{BA} = \mathbf{I}_{n}~, \end{equation}
where \(I_n\) denotes the \(n\)-by- \(n\) identity matrix and the multiplication used is ordinary matrix multiplication.
If this is the case, then the matrix \(B\) is uniquely determined by \(A\), and is called the **(multiplicative) inverse** of \(A\), denoted by \(A^{−1}\).
source inversion is the process of finding the matrix \(B\) that satisfies the prior equation for a given invertible matrix \(A\).
Over a field, a square matrix that is not invertible is called singular or degenerate.
A square matrix with entries in a field is singular if and only if its determinant is zero.
Singular matrices are rare in the sense that if a square matrix entries are randomly selected from any bounded region on the number line or complex plane, the probability that the matrix is singular is \(0\), that is, it will almost never be singular.
Non-square matrices do not have an inverse.
However, in some cases such a matrix may have a left inverse or right inverse.
If \(A\) is \(m\)-by- \(n\) and the rank of \(A\) is equal to \(n\) ( \(n \leq m\)), then \(A\) has a left inverse, an \(n\)-by- \(m\) matrix \(B\) such that \(BA = I_n\).
If \(A\) has rank \(m\) ( \(m \leq n\)), then it has a right inverse, an \(n\)-by- \(m\) matrix \(B\) such that \(AB = I_m\).
The following properties hold for an invertible matrix \(A\):
The common approach to computing the inverse matrix stems from its definition.
The inverse matrix \(A^{-1}\) of a square matrix \(A\) is a square matrix such that \(AA^{-1} = I\), where \(I\) is the identity matrix.
Depending on the class of the square matrix \(A\), there are several approaches that can be taken to compute its inverse.
However, all such methods attempt to factorize the matrix first (for example, Cholesky decomposition or LU decomposition) and cast the problem into seeking the solution to a system of linear equations.
For example, for a general square matrix of shape \(3\times 3\), the corresponding system of equations to solve would be:
\begin{equation} \begin{bmatrix} A_{11} & A_{12} & A_{13} \\ A_{21} & A_{22} & A_{23} \\ A_{31} & A_{32} & A_{33} \end{bmatrix} \begin{bmatrix} A_{11}^{-1} & A_{12}^{-1} & A_{13}^{-1} \\ A_{21}^{-1} & A_{22}^{-1} & A_{23}^{-1} \\ A_{31}^{-1} & A_{32}^{-1} & A_{33}^{-1} \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} ~, \end{equation}
where the second matrix on the left hand side is the inverse of the first square matrix \(A\).
The inverse matrix can be constructed as the collection of solutions to \(n = 3\) systems of equations of the form \(Ax=b\) with different right hand sides \(b\) matrices and \(x\) representing \(n^{\mathrm{th}}\) column of the inverse matrix.
The first system of equations to solve for the above problem would be:
\begin{equation} \begin{bmatrix} A_{11} & A_{12} & A_{13} \\ A_{21} & A_{22} & A_{23} \\ A_{31} & A_{32} & A_{33} \end{bmatrix} \begin{bmatrix} A_{11}^{-1} \\ A_{21}^{-1} \\ A_{31}^{-1} \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \\ 0 \\ \end{bmatrix} ~. \end{equation}
The second column of the inverse can be computed by changing \(b\) to \([0,1,0]^T\), the third column with \([0,0,1]^T\), and so on.
The task of computing the inverse of the matrix is now reduced to solving a series of systems of linear equations.
This can be done if the matrix \(A\) is factorized into lower and upper triangular matrices,
\begin{equation} \begin{bmatrix} A_{11} & A_{12} & A_{13} \\ A_{21} & A_{22} & A_{23} \\ A_{31} & A_{32} & A_{33} \end{bmatrix} = \begin{bmatrix} l_{11} & 0 & 0 \\ l_{21} & l_{22} & 0 \\ l_{31} & l_{32} & l_{33} \end{bmatrix} \begin{bmatrix} u_{11} & u_{12} & u_{13} \\ 0 & u_{22} & u_{23} \\ 0 & 0 & u_{33} ~, \end{bmatrix} \end{equation}
such that the above system can be written as,
\begin{equation} \begin{bmatrix} l_{11} & 0 & 0 \\ l_{21} & l_{22} & 0 \\ l_{31} & l_{32} & l_{33} \end{bmatrix} \left( \begin{bmatrix} u_{11} & u_{12} & u_{13} \\ 0 & u_{22} & u_{23} \\ 0 & 0 & u_{33} \end{bmatrix} \begin{bmatrix} A_{11}^{-1} \\ A_{21}^{-1} \\ A_{31}^{-1} \end{bmatrix} \right) = \begin{bmatrix} 1 \\ 0 \\ 0 ~. \end{bmatrix} \end{equation}
The above form of equations implied that the two systems of triangular equations have to be solved to obtain one column of the inverse matrix.
However, this method is fast because only back- and forward-substitution are required to solve for the column vectors after the initial factorization of the matrix \(A\).
The most common factorization methods used for \(A\) to obtain its inverse are:
There are also special matrix operations that mix inversion with Symmetric and Hermitian each having corresponding matrix classes:**
Benchmark :: The runtime performance of setMatInv for various methods and inverse matrix subsets. ⛓
ifort
compiler ⛓ ifort
compiler ⛓ gfortran
compiler ⛓
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
type(inversion_type), parameter pm_matrixInv::inversion = inversion_type() |
This is a scalar parameter
object of type inversion_type that is exclusively used to request no transpose of a given matrix within an interface of a procedure of the ParaMonte library.
For example usage, see the documentation of the target procedure requiring this object.
Final Remarks ⛓
If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.
This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.
Definition at line 277 of file pm_matrixInv.F90.
character(*,SK), parameter pm_matrixInv::MODULE_NAME = "@pm_matrixInv" |
Definition at line 231 of file pm_matrixInv.F90.