public void Test1() { MatrixD A = new MatrixD(new double[,] { { 4 } }); VectorD b = new VectorD(new double[] { 20 }); JacobiMethodD solver = new JacobiMethodD(); VectorD x = solver.Solve(A, null, b); Assert.IsTrue(VectorD.AreNumericallyEqual(new VectorD(1, 5), x)); Assert.AreEqual(2, solver.NumberOfIterations); }
public void Test1() { MatrixD A = new MatrixD(new double[, ] { { 4 } }); VectorD b = new VectorD(new double[] { 20 }); JacobiMethodD solver = new JacobiMethodD(); VectorD x = solver.Solve(A, null, b); Assert.IsTrue(VectorD.AreNumericallyEqual(new VectorD(1, 5), x)); Assert.AreEqual(2, solver.NumberOfIterations); }
public void Test4() { MatrixD A = new MatrixD(new double[, ] { { -12, 2 }, { 2, 3 } }); VectorD b = new VectorD(new double[] { 20, 28 }); JacobiMethodD solver = new JacobiMethodD(); VectorD x = solver.Solve(A, null, b); VectorD solution = MatrixD.SolveLinearEquations(A, b); Assert.IsTrue(VectorD.AreNumericallyEqual(solution, x)); }
public void Test5() { MatrixD A = new MatrixD(new double[, ] { { -21, 2, -4, 0 }, { 2, 3, 0.1, -1 }, { 2, 10, 111.1, -11 }, { 23, 112, 111.1, -143 } }); VectorD b = new VectorD(new double[] { 20, 28, -12, 0.1 }); JacobiMethodD solver = new JacobiMethodD(); VectorD x = solver.Solve(A, null, b); VectorD solution = MatrixD.SolveLinearEquations(A, b); Assert.IsTrue(VectorD.AreNumericallyEqual(solution, x)); }
public void Test7() { MatrixD A = new MatrixD(new double[, ] { { -21, 2, -4, 0 }, { 2, 3, 0.1, -1 }, { 2, 10, 111.1, -11 }, { 23, 112, 111.1, -143 } }); VectorD b = new VectorD(new double[] { 20, 28, -12, 0.1 }); JacobiMethodD solver = new JacobiMethodD(); solver.MaxNumberOfIterations = 10; solver.Epsilon = 0.1; VectorD x = solver.Solve(A, null, b); VectorD solution = MatrixD.SolveLinearEquations(A, b); Assert.IsTrue(VectorD.AreNumericallyEqual(solution, x, 0.1)); Assert.IsFalse(VectorD.AreNumericallyEqual(solution, x)); Assert.Greater(10, solver.NumberOfIterations); }
public void TestArgumentException3() { JacobiMethodD solver = new JacobiMethodD(); VectorD x = solver.Solve(new MatrixD(3, 3), new VectorD(4), new VectorD(3)); }
public void TestArgumentNullException2() { JacobiMethodD solver = new JacobiMethodD(); VectorD x = solver.Solve(new MatrixD(), null, null); }
public void TestArgumentNullException() { JacobiMethodD solver = new JacobiMethodD(); VectorD x = solver.Solve(null, null, new VectorD()); }
public void Test5() { MatrixD A = new MatrixD(new double[,] { { -21, 2, -4, 0 }, { 2, 3, 0.1, -1 }, { 2, 10, 111.1, -11 }, { 23, 112, 111.1, -143 }}); VectorD b = new VectorD(new double[] { 20, 28, -12, 0.1 }); JacobiMethodD solver = new JacobiMethodD(); VectorD x = solver.Solve(A, null, b); VectorD solution = MatrixD.SolveLinearEquations(A, b); Assert.IsTrue(VectorD.AreNumericallyEqual(solution, x)); }
public void Test4() { MatrixD A = new MatrixD(new double[,] { { -12, 2 }, { 2, 3 }}); VectorD b = new VectorD(new double[] { 20, 28 }); JacobiMethodD solver = new JacobiMethodD(); VectorD x = solver.Solve(A, null, b); VectorD solution = MatrixD.SolveLinearEquations(A, b); Assert.IsTrue(VectorD.AreNumericallyEqual(solution, x)); }
public void Test7() { MatrixD A = new MatrixD(new double[,] { { -21, 2, -4, 0 }, { 2, 3, 0.1, -1 }, { 2, 10, 111.1, -11 }, { 23, 112, 111.1, -143 }}); VectorD b = new VectorD(new double[] { 20, 28, -12, 0.1 }); JacobiMethodD solver = new JacobiMethodD(); solver.MaxNumberOfIterations = 10; solver.Epsilon = 0.1; VectorD x = solver.Solve(A, null, b); VectorD solution = MatrixD.SolveLinearEquations(A, b); Assert.IsTrue(VectorD.AreNumericallyEqual(solution, x, 0.1)); Assert.IsFalse(VectorD.AreNumericallyEqual(solution, x)); Assert.Greater(10, solver.NumberOfIterations); }