static void Main(string[] args)
        {
            while (true)
            {
                SystemOfEquations SystemOfLinEquations = new SystemOfEquations();
                NumericalMethods  nm = new NumericalMethods();
                asdfasdf

                Console.WriteLine("Welcome to linear equation solver. ");

                Console.WriteLine("To get equation, type an integer coefficients in line, separated by space.");
                Console.WriteLine("When system is ready, enter END to bash.");
                int step = 0;

                while (true)
                {
                    Console.Write($"Eq #{step} > ");
                    string entry = Console.ReadLine();
                    if (entry.ToLower() == "end")
                    {
                        break;
                    }
                    SystemOfLinEquations.AddEquation(new Equation(entry));
                    step++;
                }

                try
                {
                    Console.WriteLine("We have now the system: ");
                    SystemOfLinEquations.PrintSystem();
                    Console.WriteLine("The Augmented matrix is: ");
                    SystemOfLinEquations.PrintAugMatrix();
                    Console.WriteLine("Forward Elimintation is: ");
                    SystemOfLinEquations.PrintElimMatrix();
                    Console.WriteLine("And solutions are: ");
                    SystemOfLinEquations.PrintSolutions();
                }

                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    continue;
                }

                Console.WriteLine("If you want to solve other system - press any key");
                Console.WriteLine("If you want to quite - press X");

                string ExitOrNot = Console.ReadLine();
                if (ExitOrNot.ToLower() == "x")
                {
                    break;
                }
                Console.Clear();
            }
        }
Esempio n. 2
0
        public void TestOfSolveLinearEquations()
        {
            SystemOfEquations s1  = new SystemOfEquations();
            Equation          eq1 = new Equation("1 2 3");

            s1.AddEquation(eq1);
            Equation eq2 = new Equation("4 5 6");

            s1.AddEquation(eq2);
            double[] solutions = s1.GetSolutions;
            Assert.That(solutions, Is.EqualTo(new double[] { -1, 2 }));
        }
Esempio n. 3
0
        public void TestOfPivot()
        {
            SystemOfEquations s1  = new SystemOfEquations();
            Equation          eq1 = new Equation("0 2 4");

            s1.AddEquation(eq1);
            Equation eq2 = new Equation("1 -3 3");

            s1.AddEquation(eq2);
            double[] solutions = s1.GetSolutions;
            Assert.That(solutions, Is.EqualTo(new double[] { 9, 2 }));
        }
Esempio n. 4
0
        public void TestOfForwardElimination()
        {
            SystemOfEquations s1  = new SystemOfEquations();
            Equation          eq1 = new Equation("1 2 3");

            s1.AddEquation(eq1);
            Equation eq2 = new Equation("4 5 6");

            s1.AddEquation(eq2);
            double[][] test = s1.GetElimMatrix;
            Assert.That(test[1], Is.EqualTo(new double[] { 0, -3, -6 }));
            Assert.That(test[0], Is.EqualTo(new double[] { 1, 2, 3 }));
        }