예제 #1
0
        }//matrix

        static double[,] PopulateMatrix(List <String[, ]> results, int lSize, int rSize, Equation eqn)
        {
            double[,] matrix = new double[eqn.elements.Count + 1, lSize + rSize + 1];

            matrix[eqn.elements.Count, 0]             = 1;
            matrix[eqn.elements.Count, lSize + rSize] = 1;
            for (int i = 0; i < eqn.elements.Count; i++)
            {
                int j = 0;
                for (; j < lSize; j++)
                {
                    if (indexOf(results[j], eqn.elements[i]) > -1)
                    {
                        matrix[i, j] = double.Parse(results[j][1, indexOf(results[j], eqn.elements[i])]);
                    }
                }
                for (; j < lSize + rSize; j++)
                {
                    if (indexOf(results[j], eqn.elements[i]) > -1)
                    {
                        matrix[i, j] = -int.Parse(results[j][1, indexOf(results[j], eqn.elements[i])]);
                    }
                }
            }
            //Console.WriteLine("//////////////////////");
            //DisplayMatrix(matrix);
            //Console.WriteLine("//////////////////////");
            return(matrix);
        }