コード例 #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);
        }