Example #1
0
        private static void GaussEliminationProblem()
        {
            Console.WriteLine($"Solving system with Gauss elimination:\n\nA = \n{systemMatrix2}\nb = \n{constantVector2}");
            var solution = SystemSolver.Gauss(systemMatrix2, constantVector2);

            Console.WriteLine($"Solution:\n\n~x = \n{solution}");
        }
Example #2
0
        private static void ConditionNumberProblem()
        {
            Console.WriteLine($"Source system:\n\nA = \n{systemMatrix1}\nb = \n{constantVector11}");
            var systemSolution = SystemSolver.Gauss(systemMatrix1, constantVector11);

            Console.WriteLine($"Solution:\n\nx = \n{systemSolution}\n");

            Console.WriteLine($"Modified system\n\nA = \n{systemMatrix1}\nb = \n{constantVector12}");
            var modifiedSystemSolution = SystemSolver.Gauss(systemMatrix1, constantVector12);

            Console.WriteLine($"Solution:\n\n~x = \n{modifiedSystemSolution}\n");

            var conditionNumber = systemMatrix1.ConditionNumber();

            var constantVectorDeviation = (constantVector11 - constantVector12).FrobeniusNorm / constantVector11.FrobeniusNorm;
            var solutionRelativeError   = (systemSolution - modifiedSystemSolution).FrobeniusNorm / systemSolution.FrobeniusNorm;

            var errorEstimation = conditionNumber * constantVectorDeviation;

            Console.WriteLine($"System matrix condition number: {conditionNumber.Format()}");
            Console.WriteLine($"Solution relative error: {solutionRelativeError.Format()}");
            Console.WriteLine($"Relative error estimation: {errorEstimation.Format()}");
        }
 /// <summary>
 /// Изменить метод решения СЛАУ
 /// </summary>
 /// <param name="systemSolver">Метод решения СЛАУ</param>
 public void SetSystemSolver(SystemSolver systemSolver)
 {
     this.systemSolver = systemSolver;
 }