Exemple #1
0
        public string Results()
        {
            string          answers = null;
            Matrix <double> result;
            string          relationresult = null;

            if (Coefficients.Determinant(Coefficients) == 0)
            {
                for (var i = 0; i < MyEquations.Length; i++)
                {
                    for (var j = i + 1; j < MyEquations.Length; j++)
                    {
                        result = SetRelations(i, j);
                        if (HasSameRelation(result) != null)
                        {
                            if (HasSameRelation(result) == "No Solution")
                            {
                                return(HasSameRelation(result));
                            }
                            if (HasSameRelation(result) == "No Unique Solution")
                            {
                                relationresult = HasSameRelation(result);
                            }
                        }
                    }
                }

                if (relationresult == "No Unique Solution")
                {
                    return(relationresult);
                }
            }

            MyResult = new Matrix <double>(MyEquations.Length, 1);
            MyResult = Coefficients.InverseMatrix() * Numbers;
            for (var i = 0; i < MyResult.RowCount; i++)
            {
                if (i != MyResult.RowCount - 1)
                {
                    answers += $"{Variables[i]}={MyResult[i, 0]},";
                }
                else
                {
                    answers += $"{Variables[i]}={MyResult[i, 0]}";
                }
            }

            return(answers);
        }