linalg::matlinsolveLU
--
solving the linear system given by an LU decompositionlinalg::matlinsolveLU
(L, U, b)
solves the
linear system L*U*x=b, where the matrices L and
U form an LU-decomposition, as computed by
linalg::factorLU
.
linalg::matlinsolveLU(L, U, b)
linalg::matlinsolveLU(L, U, B)
L |
- | an n x n lower triangular matrix of a
domain of category Cat::Matrix |
U |
- | an n x n upper triangular form matrix of
the same domain as L |
B |
- | an n x k matrix of a domain of category
Cat::Matrix |
b |
- | an n-dimensional column vector, i.e., an
n x 1 matrix of a domain of category
Cat::Matrix |
an n-dimensional solution vector or n x k
dimensional solution matrix, respectively, of the domain type
Dom::Matrix(R)
, where R
is the component ring
of A
.
linalg::factorLU
,
linalg::inverseLU
,
linalg::matlinsolve
B
then the result is an n x k matrix X satisfying
the matrix equation L*U*X=B.L
must be equal to one (Doolittle-decomposition, see linalg::factorLU
).linalg::matlinsolveLU
expects L
and
U
to be nonsingular.linalg::matlinsolveLU
does not check on any of the
required properties of L
and U
.L
and
U
must be a field, i.e., a domain of category Cat::Field
.We solve the system
+- -+ +- -+ | 2, -3, -1 | | 1, 0, 0 | | | | | | 1, 1, -1 | * X = | 0, 1, 0 |: | | | | | 0, 1, -1 | | 0, 0, 1 | +- -+ +- -+
>> MatR := Dom::Matrix(Dom::Real): A := MatR([[2, -3, -1], [1, 1, -1], [0, 1, -1]]); I3 := MatR::identity(3)
+- -+ | 2, -3, -1 | | | | 1, 1, -1 | | | | 0, 1, -1 | +- -+ +- -+ | 1, 0, 0 | | | | 0, 1, 0 | | | | 0, 0, 1 | +- -+
We start by computing an LU-decomposition of A:
>> LU := linalg::factorLU(A)
-- +- -+ +- -+ -- | | 1, 0, 0 | | 2, -3, -1 | | | | | | | | | | 1/2, 1, 0 |, | 0, 5/2, -1/2 |, [1, 2, 3] | | | | | | | | | 0, 2/5, 1 | | 0, 0, -4/5 | | -- +- -+ +- -+ --
Now we solve the system A * X = I, which gives us the inverse of A:
>> Ai := linalg::matlinsolveLU(LU[1], LU[2], I3)
+- -+ | 0, 1, -1 | | | | -1/4, 1/2, -1/4 | | | | -1/4, 1/2, -5/4 | +- -+
>> A * Ai, Ai * A
+- -+ +- -+ | 1, 0, 0 | | 1, 0, 0 | | | | | | 0, 1, 0 |, | 0, 1, 0 | | | | | | 0, 0, 1 | | 0, 0, 1 | +- -+ +- -+