Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
 public void TestArgumentException3()
 {
     JacobiMethodD solver = new JacobiMethodD();
     VectorD       x      = solver.Solve(new MatrixD(3, 3), new VectorD(4), new VectorD(3));
 }
Ejemplo n.º 7
0
 public void TestArgumentNullException2()
 {
     JacobiMethodD solver = new JacobiMethodD();
     VectorD       x      = solver.Solve(new MatrixD(), null, null);
 }
Ejemplo n.º 8
0
 public void TestArgumentNullException()
 {
     JacobiMethodD solver = new JacobiMethodD();
     VectorD       x      = solver.Solve(null, null, new VectorD());
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 11
0
 public void TestArgumentNullException2()
 {
     JacobiMethodD solver = new JacobiMethodD();
       VectorD x = solver.Solve(new MatrixD(), null, null);
 }
Ejemplo n.º 12
0
 public void TestArgumentNullException()
 {
     JacobiMethodD solver = new JacobiMethodD();
       VectorD x = solver.Solve(null, null, new VectorD());
 }
Ejemplo n.º 13
0
 public void TestArgumentException3()
 {
     JacobiMethodD solver = new JacobiMethodD();
       VectorD x = solver.Solve(new MatrixD(3, 3), new VectorD(4), new VectorD(3));
 }
Ejemplo n.º 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);
        }