Пример #1
0
def test_LUdecomp():
    testmat = DenseMatrix([[0, 2, 5, 3], [3, 3, 7, 4], [8, 4, 0, 2],
                           [-2, 6, 3, 4]])
    L, U, p = testmat.LUdecomposition()
    res = L * U
    for orig, new in p:
        res.row_swap(orig, new)
    assert res - testmat == zeros(4)