def test_Matrix_LU(): list = [[2,3,1,5], [6,13,5,19], [2,19,10,23], [4,10,11,31], ] LU = [[2,3,1,5], [3,4,2,4], [1,4,1,2], [2,1,7,3], ] LTrue = [[1,0,0,0], [3,1,0,0], [1,4,1,0], [2,1,7,1], ] UTrue = [[2,3,1,5], [0,4,2,4], [0,0,1,2], [0,0,0,3], ] matrix = Matrix(list) L, U = Matrix.LU(matrix) assert matrix == Matrix(list) #assert matrix == Matrix(LU) assert L == Matrix(LTrue) assert U == Matrix(UTrue)
def test_Matrix_solveLyPb(Matrix120): b = Matrix([[0.1], [12.5], [10.3]]) L, U = Matrix.LU(Matrix120) P = Matrix120._CreateI() y = Matrix120._solveLyPb(L, P, b) assert y == Matrix([[0.1], [12.2], [-39]]) x = Matrix120._solveUxy(U, y) assert x == Matrix([[0.5], [-0.2], [3]])