Computing the inverse of a matrix using LUdecomposition
This functionality does not run in MATLAB.
linalg::inverseLU(A
) linalg::inverseLU(L
,U
,pivindex
)
linalg::inverseLU(A)
computes the inverse
of the square
matrix A using
LUdecomposition.
linalg::inverseLU(L, U, pivindex)
computes
the inverse of the matrix A = P^{
1} L U where L
, U
and pivindex
are
the result of an LUdeomposition of the (nonsingular) Matrix A,
as computed by linalg::factorLU
.
The matrix A
must be nonsingular.
pivindex
is a list [r[1], r[2],
...]
representing a permutation matrix P such
that B = PA = LU,
where b_{ij} = a_{ri, j}.
It is not checked whether pivindex
has such
a form.
The component ring of the input matrices must be a field, i.e.,
a domain of category Cat::Field
.
We compute the inverse of the matrix:
A := Dom::Matrix(Dom::Real)( [[2, 3, 1], [1, 1, 1], [0, 1, 1]] )
using LUdecomposition:
Ai := linalg::inverseLU(A)
We check the result:
A * Ai, Ai * A
We can also compute the inverse of A in the usual way:
1/A
linalg::inverseLU
should be used for efficiency
reasons in the case where an LU decomposition of a matrix already
is computed, as the next example illustrates.
If we already have an LU decomposition of a (nonsingular) matrix, we can compute the inverse of the matrix A = P^{ 1} L U as follows:
LU := linalg::factorLU(linalg::hilbert(3))
linalg::inverseLU(op(LU))
linalg::inverseLU
then only needs to perform
forward and backward substitution to compute the inverse matrix (see
also linalg::matlinsolveLU
).

A square matrix of a domain of category 

A list of positive integers 
Matrix of the same domain type as A
or L
,
respectively.