next | previous | forward | backward | up | top | index | toc | home

LU -- LU decomposition

Synopsis

Description

If Q is the m by m permutation matrix such that Q_(i,P_i) = 1, and all other entries are zero, then A = QLU. The matrix A is not modified

There are several restrictions. The first is that there are only a limited number of rings for which this function is implemented. Second, if A is defined over RR or CC, then A must be densely encoded.

i1 : kk = ZZ/101;
i2 : A = matrix"1,2,3,4;1,3,6,10;19,7,11,13" ** kk

o2 = | 1  2 3  4  |
     | 1  3 6  10 |
     | 19 7 11 13 |

              3        4
o2 : Matrix kk  <--- kk
i3 : A = mutableMatrix A

o3 = | 1  2 3  4  |
     | 1  3 6  10 |
     | 19 7 11 13 |

o3 : MutableMatrix
i4 : (P,L,U) = LU A

o4 = ({0, 1, 2}, | 1  .   . |, | 1 2 3  4  |)
                 | 1  1   . |  | . 1 3  6  |
                 | 19 -31 1 |  | . . 47 22 |

o4 : Sequence
i5 : matrix L * matrix U == matrix A

o5 = true
Over RR or CC, the matrix A must be densely encoded (which is the default).
i6 : kk = RR

o6 = RR

o6 : Ring
i7 : A = matrix"1,2,3,4,5,6;1,3,6,12,13,16;19,7,11,47,48,21" ** kk

o7 = | 1         2.000000 3.000000  4.000000  5.000000  6.000000  |
     | 1         3.000000 6.000000  12.000000 13.000000 16.000000 |
     | 19.000000 7.000000 11.000000 47.000000 48.000000 21.000000 |

              3        6
o7 : Matrix RR  <--- RR
i8 : A = mutableMatrix(A, Dense=>true)

o8 = | 1         2.000000 3.000000  4.000000  5.000000  6.000000  |
     | 1         3.000000 6.000000  12.000000 13.000000 16.000000 |
     | 19.000000 7.000000 11.000000 47.000000 48.000000 21.000000 |

o8 : MutableMatrix
i9 : (P,L,U) = LU A

o9 = ({2, 1, 0}, | 1        .        . |, | 19.000000 7.000000 11.000000
                 | 0.052632 1        . |  | .         2.631579 5.421053 
                 | 0.052632 0.620000 1 |  | .         .        -0.940000
     ------------------------------------------------------------------------
     47.000000 48.000000 21.000000 |)
     9.526316  10.473684 14.894737 |
     -4.380000 -4.020000 -4.340000 |

o9 : Sequence
i10 : Q = mutableZero(kk, numrows A, numrows A)

o10 = 0

o10 : MutableMatrix
i11 : for i from 0 to numrows A - 1 do Q_(i,P_i) = 1.0
i12 : matrix Q * matrix L * matrix U == matrix A

o12 = true
For matrices over RR or CC, this function calls the lapack routines.
i13 : kk = CC

o13 = CC

o13 : Ring
i14 : A = mutableZero(kk,1000,900, Dense=>true)

o14 = 0

o14 : MutableMatrix
i15 : for i from 1 to 10000 do A_(random 1000, random 900) = random 1.0 + ii * random 1.0;
i16 : time (P,L,U) = LU A;
     -- used 2.40815 seconds

Caveat

This function is limited in scope, but is sometimes useful for very large matrices

See also

Ways to use LU :