Exemple #1
0
        public Matrix(String s)
        {
            Equation eqn = new Equation(s);

            left  = eqn.GetLeft();
            right = eqn.GetRight();
            //for (int i = 0; i < 2; i++)
            //{
            //    Console.WriteLine("l " + left[i]);
            //    Console.WriteLine("r " + right[i]);
            //}

            List <String[, ]> results = new List <String[, ]>();

            for (int k = 0; k < left.Length; k++)
            {
                results.Add(eqn.Parse(left[k]));
            }

            for (int k = 0; k < right.Length; k++)
            {
                results.Add(eqn.Parse(right[k]));
            }

            PopulateMatrix(results, left.Length, right.Length, eqn);
            //matrix = SolveMatrix(matrix);
        }
        static string Solve(string s)
        {
            Equation eqn = new Equation(s);

            String[] left  = eqn.GetLeft();
            String[] right = eqn.GetRight();
            //for(int i = 0; i < 2; i++)
            //{
            //    Console.WriteLine("l " + left[i]);
            //    Console.WriteLine("r " + right[i]);
            //}

            List <String[, ]> results = new List <String[, ]>();

            for (int k = 0; k < left.Length; k++)
            {
                results.Add(eqn.Parse(left[k]));
            }

            for (int k = 0; k < right.Length; k++)
            {
                results.Add(eqn.Parse(right[k]));
            }

            double[,] matrix = PopulateMatrix(results, left.Length, right.Length, eqn);
            matrix           = SolveMatrix(matrix);
            //Console.WriteLine("???????????????????????");
            //DisplayMatrix(matrix);
            //Console.WriteLine("???????????????????????");
            return(InsertCoeff(DetermineCoefficients(matrix), left, right));
        }