Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Computational Lab 4. Variant 1. Task 2. (c) 2019 Nekhaev Alexander\n");
            //Берем начальные данные
            TaskData inputs = new TaskData();

            inputs.PrintTask();
            AnalyticSolver analyticSolver = new AnalyticSolver(inputs);

            Console.WriteLine("Analytic solution");
            analyticSolver.PrintEquation();
            Console.WriteLine();
            Console.WriteLine("Solutions");
            DifferModelSolver differModelSolver = new DifferModelSolver(inputs)
            {
                Knots = points
            };
            VariableCoefsNumericalSolver variableCoefsNumerical = new VariableCoefsNumericalSolver(inputs)
            {
                Knots = points
            };

            double[] analyticSolve = analyticSolver.GetSolution(points);
            double[] differSolve   = differModelSolver.GetSolution();
            double[] variableSolve = variableCoefsNumerical.GetSolution();
            double[] differ        = new double[points];
            for (int i = 0; i < points; i++)
            {
                differ[i] = (analyticSolve[i] - differSolve[i]);
            }
            double maxDiffer = differ[0];

            for (int i = 1; i < points; i++)
            {
                if (maxDiffer < differ[i])
                {
                    maxDiffer = differ[i];
                }
            }
            //double[] answer = new double[points];
            //for(int i = 0; i<points; i++)
            //{
            //    answer[i] = maxDiffer + variableSolve[i];
            //}
            PrintEvaluatedValues(new string[] { "X", "Analytic Solution", "Thomas algorithm", "Variable Coeffitients", "Differ Analytic-Thomas" }, MakeNet(), analyticSolve, differSolve, variableSolve, differ);
            Console.WriteLine("Max differ: " + maxDiffer);
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Computational Lab 4. Variant 1. Task 2. (c) 2019 Nekhaev Alexander\n");
            //Берем начальные данные
            TaskData inputs = new TaskData();

            inputs.PrintTask();
            AnalyticSolver analyticSolver = new AnalyticSolver(inputs);

            Console.WriteLine("Analytic solution");
            analyticSolver.PrintEquation();
            Console.WriteLine();
            Console.WriteLine("Analytic solution evaluated points");
            PrintEvaluatedValues(analyticSolver.GetSolutions(points));
            NumericalSolver numericalSolver = new NumericalSolver(inputs);

            Console.ReadLine();
        }