internal GF256Poly(GF256 field, int[] coefficients) {
if (coefficients == null || coefficients.Length == 0) {
throw new ArgumentException();
}
this.field = field;
int coefficientsLength = coefficients.Length;
if (coefficientsLength > 1 && coefficients[0] == 0) {
// Leading term must be non-zero for anything except the constant polynomial "0"
int firstNonZero = 1;
while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) {
firstNonZero++;
}
if (firstNonZero == coefficientsLength) {
this.coefficients = field.GetZero().coefficients;
}
else {
this.coefficients = new int[coefficientsLength - firstNonZero];
System.Array.Copy(coefficients,
firstNonZero,
this.coefficients,
0,
this.coefficients.Length);
}
}
else {
this.coefficients = coefficients;
}
}