public void LinearSystemSolutionTest3() { int countX = 2; string[] eq = { "1x0+2x1=6", "2x0+4x1=12" }; LinearSystem LS = new LinearSystem(countX, eq); Matrix ans = LS.SolutionGaussMethod(); Matrix correctAns = new Matrix(1, 2); correctAns[0, 0] = -2; correctAns[0, 1] = 6; for (int i = 0; i < 2; i++) { Assert.AreEqual(correctAns[0, i], ans[0, i]); } }
public void LinearSystemSolutionTest1() { int countX = 2; string[] eq = { "2x0+1x1=3", "4x0+1x1=5" }; LinearSystem LS = new LinearSystem(countX, eq); Matrix ans = LS.SolutionGaussMethod(); Matrix correctAns = new Matrix(2, 1); correctAns[0, 0] = 1; correctAns[1, 0] = 1; for (int i = 0; i < 2; i++) { Assert.AreEqual(correctAns[i, 0], ans[i, 0]); } }
public void LinearSystemSolutionTest2() { int countX = 3; string[] eq = { "1x0+1x1+1x2=6", "1x0+2x1+0x2=5", "0x0+1x1+2x2=8" }; LinearSystem LS = new LinearSystem(countX, eq); Matrix ans = LS.SolutionGaussMethod(); Matrix correctAns = new Matrix(3, 1); correctAns[0, 0] = 1; correctAns[1, 0] = 2; correctAns[2, 0] = 3; for (int i = 0; i < 3; i++) { Assert.AreEqual(correctAns[i, 0], ans[i, 0]); } }