예제 #1
0
        public void Test1()
        {
            MatrixF A = new MatrixF(new float[,] { { 4 } });
              VectorF b = new VectorF(new float[] { 20 });

              JacobiMethodF solver = new JacobiMethodF();
              VectorF x = solver.Solve(A, null, b);

              Assert.IsTrue(VectorF.AreNumericallyEqual(new VectorF(1, 5), x));
              Assert.AreEqual(2, solver.NumberOfIterations);
        }
예제 #2
0
        public void Test1()
        {
            MatrixF A = new MatrixF(new float[, ] {
                { 4 }
            });
            VectorF b = new VectorF(new float[] { 20 });

            JacobiMethodF solver = new JacobiMethodF();
            VectorF       x      = solver.Solve(A, null, b);

            Assert.IsTrue(VectorF.AreNumericallyEqual(new VectorF(1, 5), x));
            Assert.AreEqual(2, solver.NumberOfIterations);
        }
예제 #3
0
        public void Test4()
        {
            MatrixF A = new MatrixF(new float[, ] {
                { -12, 2 },
                { 2, 3 }
            });
            VectorF b = new VectorF(new float[] { 20, 28 });

            JacobiMethodF solver = new JacobiMethodF();
            VectorF       x      = solver.Solve(A, null, b);

            VectorF solution = MatrixF.SolveLinearEquations(A, b);

            Assert.IsTrue(VectorF.AreNumericallyEqual(solution, x));
        }
예제 #4
0
        public void Test5()
        {
            MatrixF A = new MatrixF(new float[, ] {
                { -21, 2, -4, 0 },
                { 2, 3, 0.1f, -1 },
                { 2, 10, 111.1f, -11 },
                { 23, 112, 111.1f, -143 }
            });
            VectorF b = new VectorF(new float[] { 20, 28, -12, 0.1f });

            JacobiMethodF solver = new JacobiMethodF();
            VectorF       x      = solver.Solve(A, null, b);

            VectorF solution = MatrixF.SolveLinearEquations(A, b);

            Assert.IsTrue(VectorF.AreNumericallyEqual(solution, x));
        }
예제 #5
0
        public void Test7()
        {
            MatrixF A = new MatrixF(new float[, ] {
                { -21, 2, -4, 0 },
                { 2, 3, 0.1f, -1 },
                { 2, 10, 111.1f, -11 },
                { 23, 112, 111.1f, -143 }
            });
            VectorF b = new VectorF(new float[] { 20, 28, -12, 0.1f });

            JacobiMethodF solver = new JacobiMethodF();

            solver.MaxNumberOfIterations = 10;
            solver.Epsilon = 0.1f;
            VectorF x = solver.Solve(A, null, b);

            VectorF solution = MatrixF.SolveLinearEquations(A, b);

            Assert.IsTrue(VectorF.AreNumericallyEqual(solution, x, 0.1f));
            Assert.IsFalse(VectorF.AreNumericallyEqual(solution, x));
            Assert.Greater(10, solver.NumberOfIterations);
        }
예제 #6
0
 public void TestArgumentException3()
 {
     JacobiMethodF solver = new JacobiMethodF();
     VectorF       x      = solver.Solve(new MatrixF(3, 3), new VectorF(4), new VectorF(3));
 }
예제 #7
0
 public void TestArgumentNullException2()
 {
     JacobiMethodF solver = new JacobiMethodF();
     VectorF       x      = solver.Solve(new MatrixF(), null, null);
 }
예제 #8
0
 public void TestArgumentNullException()
 {
     JacobiMethodF solver = new JacobiMethodF();
     VectorF       x      = solver.Solve(null, null, new VectorF());
 }
예제 #9
0
        public void Test5()
        {
            MatrixF A = new MatrixF(new float[,] { { -21, 2, -4, 0 },
                                             { 2, 3, 0.1f, -1 },
                                             { 2, 10, 111.1f, -11 },
                                             { 23, 112, 111.1f, -143 }});
              VectorF b = new VectorF(new float[] { 20, 28, -12, 0.1f });

              JacobiMethodF solver = new JacobiMethodF();
              VectorF x = solver.Solve(A, null, b);

              VectorF solution = MatrixF.SolveLinearEquations(A, b);
              Assert.IsTrue(VectorF.AreNumericallyEqual(solution, x));
        }
예제 #10
0
        public void Test4()
        {
            MatrixF A = new MatrixF(new float[,] { { -12, 2 },
                                             { 2, 3 }});
              VectorF b = new VectorF(new float[] { 20, 28 });

              JacobiMethodF solver = new JacobiMethodF();
              VectorF x = solver.Solve(A, null, b);

              VectorF solution = MatrixF.SolveLinearEquations(A, b);
              Assert.IsTrue(VectorF.AreNumericallyEqual(solution, x));
        }
예제 #11
0
 public void TestArgumentNullException2()
 {
     JacobiMethodF solver = new JacobiMethodF();
       VectorF x = solver.Solve(new MatrixF(), null, null);
 }
예제 #12
0
 public void TestArgumentNullException()
 {
     JacobiMethodF solver = new JacobiMethodF();
       VectorF x = solver.Solve(null, null, new VectorF());
 }
예제 #13
0
 public void TestArgumentException3()
 {
     JacobiMethodF solver = new JacobiMethodF();
       VectorF x = solver.Solve(new MatrixF(3, 3), new VectorF(4), new VectorF(3));
 }
예제 #14
0
        public void Test7()
        {
            MatrixF A = new MatrixF(new float[,] { { -21, 2, -4, 0 },
                                             { 2, 3, 0.1f, -1 },
                                             { 2, 10, 111.1f, -11 },
                                             { 23, 112, 111.1f, -143 }});
              VectorF b = new VectorF(new float[] { 20, 28, -12, 0.1f });

              JacobiMethodF solver = new JacobiMethodF();
              solver.MaxNumberOfIterations = 10;
              solver.Epsilon = 0.1f;
              VectorF x = solver.Solve(A, null, b);

              VectorF solution = MatrixF.SolveLinearEquations(A, b);
              Assert.IsTrue(VectorF.AreNumericallyEqual(solution, x, 0.1f));
              Assert.IsFalse(VectorF.AreNumericallyEqual(solution, x));
              Assert.Greater(10, solver.NumberOfIterations);
        }