def test_compare_straight_and_vondermond(self): operations = MOperations(Simple()) vectorA = [[35.0], [2.0], [-50.0], [-13.0]] vectorC = [[2.0], [-1.0], [-3.0], [-2.0]] vondermondResult = operations.solveVondermond(vectorA, vectorC) vondermondMatrix = operations.generateVondermondMatrix(vectorC) inversedMatrix = operations.getMatrixInverse(vondermondMatrix) straightResult = operations.matrixMult(inversedMatrix, vectorA) self.assertTrue(self.assertEqualWithInaccuaracy(vondermondResult, straightResult))
def test_solve_straight_way(self): operations = MOperations(Simple()) vectorA = [[35.0], [2.0], [-50.0], [-13.0]] vondermondMatrix = [[1.0, 2.0, 4.0, 8.0], [1.0, -1.0, 1.0, -1.0], [1.0, -3.0, 9.0, -27.0], [1.0, -2.0, 4.0, -8.0]] expectedResult = [[7.0], [4.0], [1.0], [2.0]] inversedMatrix = operations.getMatrixInverse(vondermondMatrix) calculatedResult = operations.matrixMult(inversedMatrix, vectorA) self.assertTrue(self.assertEqualWithInaccuaracy(expectedResult, calculatedResult))
def test_inverse(self): operations = MOperations(Simple()) matrixA = [[7.0, 1.0, 2.0], [-5.0, 2.0, 12.0], [2.0, 3.0, 1.0]] identityMatrix = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] inversedMatrix = operations.getMatrixInverse(matrixA) calculatedIdentityMatrix = operations.matrixMult(matrixA, inversedMatrix) self.assertTrue(self.assertEqualWithInaccuaracy(identityMatrix, calculatedIdentityMatrix))