Example #1
0
        public static FiniteFieldPolynomial EvaluateAt(long x, FiniteFieldPolynomial[] coefficients)
        {
            // Use Horner's Scheme: http://en.wikipedia.org/wiki/Horner_scheme

            FiniteFieldPolynomial xAsPoly = coefficients[0].GetValueInField(x);

            // assume the coefficient for highest monomial is 1
            FiniteFieldPolynomial result = xAsPoly.Clone();

            for (int i = coefficients.Length - 1; i > 0; i--)
            {
                result = result + coefficients[i];
                result = result * xAsPoly;
            }

            result = result + coefficients[0];

            return(result);
        }