Group: | Linear Algebra |
See also: | chold |
Function: | ludecomp | |
Description: | computes the LU decomposition of a square matrix, ; where L represents the lower ; and U the upper triangular matrix. |
Usage: | z = ludecomp (x) | |
Input: | ||
x | p x p matrix of user-defined data which should be decomposed | |
Output: | ||
z.l | p x p lower triangular matrix | |
z.u | p x p upper triangular matrix | |
z.index | p x 1 indexvector, defining the order of the z.l*z.u matrix |
z.index is needed to restore the original matrix x from z.l ; and z.u. To rebuild x use index(z.l*z.u, z.index).
Keep in mind that the LU decomposition is not unique.
x = #(1, 2, 3)~#(2, 3, 4)~#(3, 4, 5) z = ludecomp(x) z index(z.l*z.u, z.index)
Contents of z.l [1,] 1 0 0 [2,] 0.33333 1 0 [3,] 0.66667 0.5 1 Contents of z.u [1,] 3 4 5 [2,] 0 0.66667 1.3333 [3,] 0 0 1.1102e-16 Contents of z.index [1,] 2 [2,] 3 [3,] 1 Contents of index [1,] 1 2 3 [2,] 2 3 4 [3,] 3 4 5