Exemple #1
0
        /// <returns> evaluation of this polynomial at a given point
        /// </returns>
        internal int evaluateAt(int a)
        {
            if (a == 0)
            {
                // Just return the x^0 coefficient
                return(getCoefficient(0));
            }
            int size = coefficients.Length;

            if (a == 1)
            {
                // Just the sum of the coefficients
                int result = 0;
                for (int i = 0; i < size; i++)
                {
                    result = GF256.addOrSubtract(result, coefficients[i]);
                }
                return(result);
            }
            int result2 = coefficients[0];

            for (int i = 1; i < size; i++)
            {
                result2 = GF256.addOrSubtract(field.multiply(a, result2), coefficients[i]);
            }
            return(result2);
        }