예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }
예제 #6
0
 public void TestArgumentException3()
 {
     JacobiMethodD solver = new JacobiMethodD();
     VectorD       x      = solver.Solve(new MatrixD(3, 3), new VectorD(4), new VectorD(3));
 }
예제 #7
0
 public void TestArgumentNullException2()
 {
     JacobiMethodD solver = new JacobiMethodD();
     VectorD       x      = solver.Solve(new MatrixD(), null, null);
 }
예제 #8
0
 public void TestArgumentNullException()
 {
     JacobiMethodD solver = new JacobiMethodD();
     VectorD       x      = solver.Solve(null, null, new VectorD());
 }
예제 #9
0
        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));
        }
예제 #10
0
        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));
        }
예제 #11
0
 public void TestArgumentNullException2()
 {
     JacobiMethodD solver = new JacobiMethodD();
       VectorD x = solver.Solve(new MatrixD(), null, null);
 }
예제 #12
0
 public void TestArgumentNullException()
 {
     JacobiMethodD solver = new JacobiMethodD();
       VectorD x = solver.Solve(null, null, new VectorD());
 }
예제 #13
0
 public void TestArgumentException3()
 {
     JacobiMethodD solver = new JacobiMethodD();
       VectorD x = solver.Solve(new MatrixD(3, 3), new VectorD(4), new VectorD(3));
 }
예제 #14
0
        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);
        }