public void TestSolveNEquationsNUnknowns(int testCaseId) { double epsilon = 0.0001; var matrixUtilities = new MatrixUtilities(); var testCase = this.TestCaseIdToMatrixDictionary[testCaseId]; var solution = matrixUtilities.SolveNEquationsNUnknowns(testCase.Equations, testCase.Constants); var resultFromMultiplication = matrixUtilities.MultiplyMatrixByVector(testCase.Equations, solution); Assert.AreEqual(testCase.Solution.Length, solution.Length); Assert.AreEqual(testCase.Constants.Length, resultFromMultiplication.Length); for (int i = 0; i < solution.Length; i++) { Assert.LessOrEqual(Math.Abs(solution[i] - testCase.Solution[i]), epsilon); Assert.LessOrEqual(Math.Abs(resultFromMultiplication[i] - testCase.Constants[i]), epsilon); } var linearEquationRepresentation = this.ConvertMatrixIntoLinearEquations(testCase.Equations, testCase.Constants); var solutionOfLinearEquations = matrixUtilities.SolveLinearSystemOfEquations(linearEquationRepresentation); Assert.AreEqual(testCase.Solution.Length, solutionOfLinearEquations.Length); for (int i = 0; i < solution.Length; i++) { Assert.LessOrEqual(Math.Abs(solution[i] - testCase.Solution[i]), epsilon); } }