functioncholesky
Return the Cholesky factorization of a symmetric positive definite matrix
Extends from Modelica.Icons.Function (Icon for functions).
Information
Syntax
H = Matrices.cholesky(A); H = Matrices.cholesky(A, upper=true);
Description
Function cholesky computes the Cholesky factorization of a real symmetric positive definite matrix A. The optional Boolean input "upper" specifies whether the upper or the lower triangular matrix is returned, i.e.
A = H'*H if upper is true (H is upper triangular) A = H*H' if upper is false (H is lower triangular)
The computation is performed by LAPACK.dpotrf.
Example
A = [1, 0, 0;
6, 5, 0;
1, -2, 2];
S = A*transpose(A);
H = Matrices.cholesky(S);
results in:
H = [1.0, 6.0, 1.0;
0.0, 5.0, -2.0;
0.0, 0.0, 2.0]
with
transpose(H)*H = [1.0, 6.0, 1;
6.0, 61.0, -4.0;
1.0, -4.0, 9.0] //=S
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[:,size(A, 1)] | A | Symmetric positive definite matrix | |
| Boolean | upper | true | = true, if the right Cholesky factor (upper triangle) should be returned |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real[size(A, 1),size(A, 2)] | H | Cholesky factor U (upper=true) or L (upper=false) for A = U'*U or A = L*L' |
Revisions
- 2010/05/31 by Marcus Baur, DLR-RM