# CHOLESKY

## Purpose:

Computes the Cholesky factorization of a square matrix.

## Syntax:

CHOLESKY(a, eflag)

(C, p) = CHOLESKY(a)

a

-

A square matrix.

eflag

-

Optional. An integer, the error report flag:

 0: report errors (default) 1: suppress errors

## Returns:

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

## Example:

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.

## 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. Testing for p > 0 is one method of determining if the input is positive definite without returning an error.

CHOLESKY can be abbreviated CHOL.

See DADiSP/MatrixXL to significantly optimize CHOLESKY.

*^ (Matrix Multiply)