A linear system of equations is written in matrix terms as:
| (27.8) |
and
| (27.9) | |||
![]() |
(27.10) |
or
The determinant of
is simply the product of the
diagonal elements of the decomposed matrix:
. The inverse matrix
can be computed by performing a
column-by-column backsubstitution of the identity matrix.
The routines in DetInverse.c simply call the routines in
DetInverseInternal.c, first using LALSLUDecomp() or
LALDLUDecomp() to perform an LU decomposition of the matrix,
then either computing the determinant from the diagonal elements, or
using LALSLUBackSub() or LALDLUBackSub() to determine
the inverse by back-substitution of basis vectors. The routines that
compute the determinant will also handle any ``singular matrix'' error
code returned by the LU decomposition routines, returning zero as the
determinant.
Since the diagonal components
are conventionally assigned to
1, they do not need to be explicitly stored. Therefore we can store
both matrices
and
``in-place'', in the same memory block used for the input matrix
. This the procedure taken by LALSLUDecomp()
and LALDLUDecomp(); hence on return the routines in this module
will leave the input *matrix in this decomposed state.
However, these routines also permute the rows of the input
matrix, and the information on this permutation is not returned
by the routines in DetInverse.c, so the information in
*matrix will be irretrievably mangled. If you want to do
further work with the LU-decomposed matrix, call the routines in
DetInverseInternal.c directly.
Computing the determinant is dominated by the cost of doing the LU
decomposition, or of order
operations. Computing the inverse
requires an additional
back-substitutions, but since most of the
vector elements are zero, this reduces the average cost of each
back-substitution from
to
, for a total operation count
of
.