示例#1
0
        public void SolveWithJacobiMethod_Test()
        {
            Matrix inputMatrix = new Matrix(new double[3, 3]
            {
                { 10, -4, -2 },
                { -4, 10, -4 },
                { -6, -2, 12 }
            });

            Vector rightSideVector = new Vector(new double[3]
            {
                2,
                3,
                1
            });

            Vector startValue = new Vector(new double[3]
            {
                0,
                0,
                0
            });

            string info;
            LGS    lgs    = new LGS(inputMatrix, rightSideVector);
            Vector actual = lgs.SolveLGSJacobi(startValue, 100, out info);

            if (!string.IsNullOrEmpty(info))
            {
                File.WriteAllText(@"C:\Users\User\Documents\Berufsschule\2. Lehrjahr\LF 8\Iterative Lösungsverfahren\Jacobi_Second_Diagonal.csv", info);
            }

            actual.Round(3);

            Vector expected = new Vector(new double[3]
            {
                0.598,
                0.741,
                0.506
            });

            Assert.IsFalse(false);
        }
示例#2
0
        public void Jacobi_First_Diagonal_Test()
        {
            Matrix inputMatrix = new Matrix(new double[3, 3]
            {
                { 12, 3, -5 },
                { 1, 5, 3 },
                { 3, 7, 13 }
            });

            Vector rightSideVector = new Vector(new double[3]
            {
                1,
                28,
                76
            });

            Vector startValue = new Vector(new double[3]
            {
                0,
                0,
                0
            });

            string info;
            LGS    lgs    = new LGS(inputMatrix, rightSideVector);
            Vector actual = lgs.SolveLGSJacobi(startValue, 100, out info);

            if (!string.IsNullOrEmpty(info))
            {
                File.WriteAllText(@"C:\Users\User\Documents\Berufsschule\2. Lehrjahr\LF 8\Iterative Lösungsverfahren\Jacobi_First_Diagonal.csv", info);
            }

            actual.Round(3);

            Vector expected = new Vector(new double[3]
            {
                0.598,
                0.741,
                0.506
            });

            Assert.IsTrue(true);
        }