CHOLESKY

Purpose:

Computes the Cholesky factorization of a square matrix.

Syntax:

CHOLESKY(a, eflag, "triangle")

(C, p) = CHOLESKY(a, eflag, "triangle")

a

-

A square matrix.

eflag

-

Optional. An integer, the error report flag:

0:

report errors (default)

1:

suppress errors

"triangle"

-

Optional. A string, the output triangle:

"upper":

upper triangle (default)

"lower":

lower triangle

Returns:

An upper or lower triangular matrix, the Cholesky factor of the input matrix.

 

(C, p) = CHOLESKY(a, eflag, "triangle") 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 non-zero, a is not positive definite and C is not fully computed.

Example:

a = {{3, 2, 3},

     {2, 4, 2}, 

     {3, 2, 4}};

 

C = cholesky(a);

 

C == {{1.73205, 1.15470,  1.73205},

      {0,       1.63299, -4.07615e-16}, 

      {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.

 

For any non-zero vector v:

 

v = {1, 10, -20}

conj(v’) *^ a *^ v == {1123}

 

also demonstrating that a is positive definite.

Example:

a = {{3, 2, 3},

     {2, 4, 2}, 

     {3, 2, 4}};

 

C = cholesky(a, "lower");

 

C == {{1.73205,  0,           0},

      {1.15470,  1.63299,     0},

      {1.73205, -4.07615e-16, 1}}

 

Same as above except the lower triangle is returned.

Example:

a = {{3, 2, 3},

     {2, 4, 2}, 

     {3, 2, 4}};

 

(C, p) = cholesky(a);

 

C == {{1.73205, 1.1547,   1.73205},

      {0,       1.63299, -2.71948e-016}, 

      {0,       0,        1}}

 

p == 0

 

Same as the first example except the result of p == 0 demonstrates that matrix a is positive definite.

Example:

b = {{3, 2, 3},

     {2, 4, 2}, 

     {3, 2, 1}};

 

(C, p) = chol(b);

 

p > 0 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.

Remarks:

Matrix a is positive definite if conj(v’) *^ a *^ v > 0 for any vector v with the same number of rows as the number of columns of a.

 

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 (C, p) = cholesky(a), no error message is printed regardless of the eflag argument. In this case, testing for p > 0 is one method of determining if the input is not positive definite without returning an error.

 

CHOLESKY can be abbreviated CHOL.

 

See DADiSP/MatrixXL to significantly optimize CHOLESKY.

See Also:

*^ (Matrix Multiply)

DADiSP/MatrixXL

DIAGONAL

EIG

LU

SVD

QR