decomposition
Matrix decomposition object for solving linear systems repeatedly.
Category: Mathematics > Linear Algebra
Syntax
dA = decomposition(A)
Chooses a factorization suited to the structure of A.
dA = decomposition(A, type)
Uses the named factorization, such as 'lu', 'chol', 'qr', 'ldl' or 'diagonal'.
x = dA\b
Solves A*x = b reusing the stored factorization.
Description
Solving A\b factors A each time. When the same matrix is used with many right-hand sides, building a decomposition once and then writing dA\b skips the repeated factorization and gives the same answers.
The object keeps the factorization type it picked, which can be read from dA.Type. It cannot be used as an ordinary matrix: multiplying, indexing and similar operations are not defined for it.
Input arguments
A- Square or rectangular matrix.
type- Name of the factorization to compute.
Output arguments
dA- Object with properties such as
TypeandMatrixSize, which also works with\,/,isIllConditionedandrcond.
Example
Solving with a stored factorization
A = [4 1; 2 3];
dA = decomposition(A);
x = dA\[1; 2]
dA.Type
disp(dA.MatrixSize)
Output
x = 2×1
0.1000
0.6000
ans = 'lu'
2 2