Ejemplo n.º 1
0
        public string Solve()
        {
            Equations = Equations.OrderBy(i => i.TotalNumberOfVariables).ToList();
            //Populate the Variable List
            List <string> variablesList = new List <string>();

            foreach (var equation in Equations)
            {
                equation.PopulateVariableList(variablesList);
            }

            //Validate the Number of Variables and Number of Equations
            if ((variablesList.Count() - 1) < Equations.Count())
            {
                throw new Exception("Number of Equations and Variables should be same for Linear Equation Solver");
            }


            double[,] gaussMatrix = new double[Equations.Count(), variablesList.Count()]; //+1 for Vector

            //Populate Matrix
            for (int i = 0; i < Equations.Count(); i++)
            {
                var equation = Equations[i];
                for (int j = 0; j < variablesList.Count(); j++)
                {
                    gaussMatrix[i, j] = equation[variablesList[j]];
                }
            }

            //Solve it by Gaussian Elimination Method

            return(ToString());
        }
Ejemplo n.º 2
0
        public bool CheckVerificationEquation(GroupElementVector publicNonces, Scalar challenge, ScalarVector responses)
        {
            // The responses matrix should match the generators in the equations and
            // there should be once nonce per equation.
            Guard.True(nameof(publicNonces), Equations.Count() == publicNonces.Count());

            return(Equations.Zip(publicNonces, (equation, r) => equation.Verify(r, challenge, responses)).All(x => x));
        }