File Exchange

image thumbnail


version 1.0 (1.91 KB) by

Performs the U-D factorization of a symmetric matrix.



View License

[U D] = UDFactor(P) returns matrices U and D such that U.'*D*U = P
[U D] = UDFactor(P,uflag) returns matrices U and D such that U*D*U.' = P
when uflag is set to TRUE. Setting uflag to FALSE is equivalent to
running UDFactor with only one argument.

The alogrithm of UDFactor is similar to the Cholesky decomposition except
that the matrix is factored into a unitary upper triangular matrix (U)
and diagonal matrix (D) such that P = U*D*U.' (or U.'*D*U). Note that
while this is equivalent to P = (U*D^0.5)*(U*D^0.5).' = S*S.' where S is
the upper triangular square root of P, no square roots are taken in the
calculations of U and D. This makes this factorization ideal for a
square-root implementation of a Kalman filter (a U-D filter). For more
details, see Bierman, G. J., Factorization methods for discrete
sequential estimation, 1977.

Note: This factorization is only guaranteed to work for symmetric

%create symmetric matrix
P = rand(5)*10;, P = triu(P)+triu(P).';
[U1,D1] = UDFactor(P);
[U2,D2] = UDFactor(P,true);
%check factorization
P - U1.'*D1*U1
P - U2*D2*U2.'

Comments and Ratings (5)


sun (view profile)

very usefule

Nice work!

Markus Buehren

Markus Buehren (view profile)

Tim Davis

Note that this function was written for R14SP1. It's very useful there, since (if recall) there is no LDL' factorization in that version of MATLAB. In more recent versions of MATLAB, there is a new LDL' factorization function (called LDL) which does the same thing that this function does (but the built-in LDL function is a lot faster). So if you have a recent MATLAB version, use the built-in LDL function; use this one for older versions (or to read the algorithm).

Note that this function doesn't handle the sparse case.

The built-in LDL function works for all symmetric indefinite matrices. Since the function here does not handle 2-by-2 pivots, it will work for only a subset of symmetric indefinite matrices. Both this function and the built-in LDL will work fine for symmetric positive definite matrices.

However, the code here is still well written for the dense case, with ample comments. It's just that you won't need it for recent MATLAB versions except for its educational value.

MATLAB Release
MATLAB 7.0.1 (R14SP1)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today