Ejemplo n.º 1
0
        static public int CalculateOrder(MatrixClass matrix)
        {
            if (matrix == null || matrix.Length == 0)
            {
                throw new Exception("Unable to claculate");
            }

            return(matrix.Length - 1);
        }
        public double[] BackwardSubstitution(MatrixClass matrix)
        {
            int length = matrix.GetEquation(0).Array.Length;

            double[] result = new double[matrix.Length];
            for (int i = matrix.Length - 1; i >= 0; i--)
            {
                double val = matrix.GetEquation(i).Array[length - 1];
                for (int j = length - 2; j > i - 1; j--)
                {
                    val -= matrix.GetEquation(i).Array[j] * result[j];
                }

                result[i] = val / matrix.GetEquation(i).Array[i];
            }
            return(result);
        }
        private bool PivotProcedure(MatrixClass matrix, int row, int column)
        {
            bool swapped = false;

            for (int z = matrix.Length - 1; z > row; z--)
            {
                if (matrix.GetEquation(z).Array[row] != 0)
                {
                    _ = new double[matrix.GetEquation(0).Array.Length];
                    double[] temp = matrix.GetEquation(z).Array;
                    matrix.SetEquation(z, matrix.GetEquation(column));
                    matrix.SetEquation(column, new EquationClass(temp));
                    swapped = true;
                }
            }
            return(swapped);
        }