Computes the Cholesky factorization of a square matrix.
CHOLESKY(a, eflag)
(C, p) = CHOLESKY(a)
a |
- |
A square matrix. |
||||
eflag |
- |
Optional. An integer, the error report flag:
|
An upper triangular matrix, the Cholesky factor of the input matrix.
(C, p) = CHOLESKY(a) returns both the Cholesky factor C and p, the number of Nulls if the input is not positive definite, or 0 if the input is positive definite. If p is
a = {{3, 2, 3},
{2, 4, 2},
{3, 2, 4}}
C = cholesky(a)
C == {{1.73205, 1.1547, 1.73205},
{0, 1.63299, -2.71948e-016},
{0, 0, 1}}
Matrix a is positive definite and C represents the Cholesky factor.
conj(C’) *^ C == {{3, 2, 3},
{2, 4, 2},
{3, 2, 4}}
eig(a) == {8.36468, 0.434583, 2.20074}
Because matrix a is positive definite, the eigenvalues of a are all positive.
v = {1, 10, -20}
conj(v’) *^ a *^ v == {1123}
also demonstrating that a is positive definite.
b = {{3, 2, 3},
{2, 4, 2},
{3, 2, 1}}
(C, p) = chol(b)
p == 1 indicating b is not positive definite and C was not fully computed.
eig(b) == {7.44241, -1.21371, 1.7713}
Because matrix b is not positive definite, the eigenvalues of b are not all positive.
conj(v’) *^ b *^ v == {-77}
also demonstrating that b is not positive definite.
Matrix a is positive definite if
The eigenvalues of a positive definite matrix are all positive.
For a positive definite matrix a, the Cholesky factor C is an upper triangular matrix such that:
conj(C’) * C == a
If the input matrix is not positive definite, an error results unless eflag is 1. However, for
CHOLESKY can be abbreviated CHOL.
See DADiSP/MatrixXL to significantly optimize CHOLESKY.