## udfactor

Factors a positive semi-definite matrix, A, into an upper-unitriangular matrix, U, and diagonal matrix with elements in d such that:

U * diag(d) * U.' == A

This function is nearly identical to ldfactor. See that function for more.

## Inputs

A Positive, semi-definite matrix Division tolerance; when divisors are below this value, no division will actually take place.

## Outputs

U Upper unitriangular matrix Vector of diagonals Number of zero diagonals found during factorization

## Example

Generate a random covariance matrix.

Break it down to U and d.

P = randcov(3)
[U, d] = udfactor(P)
P =
0.5052   -0.2311   -0.2059
-0.2311    0.5124   -0.0714
-0.2059   -0.0714    0.7502
U =
1.0000   -0.4959   -0.2744
0    1.0000   -0.0951
0         0    1.0000
d =
0.3243
0.5056
0.7502

Reconstruct the original matrix

U * diag(d) * U.'
ans =
0.5052   -0.2311   -0.2059
-0.2311    0.5124   -0.0714
-0.2059   -0.0714    0.7502

## Reference

Stengel, Robert F. Optimal Control and Estimation. New York: Dover Publications, Inc. 1994. Print. Page 360.