def test_LU_3x3_matrix(self): matrix = Matrix([[1, 2, 4], [2, 1, 2], [1, 2, 1]]) matrix.LU() self.assertEqual(matrix.L.tolist(), [[1, 0, 0], [0.5, 1, 0], [0.5, 1, 1]]) self.assertEqual(matrix.U.tolist(), [[2, 1, 2], [0, 1.5, 0], [0, 0, 3]])
def test_LU_2x2_matrix(self): matrix = Matrix([[3, 4], [5, 6]]) matrix.LU() self.assertEqual(matrix.L.tolist(), [[1.0, 0.0], [0.6, 1.0]]) self.assertEqual(matrix.U.tolist(), [[5.0, 6], [0.0, 0.4]])