ModulusPoly constructor
Implementation
ModulusPoly(this._field, List<int> coefficients) {
if (coefficients.isEmpty) {
throw ArgumentError();
}
final 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) {
_coefficients = [];
} else {
_coefficients = List.filled(coefficientsLength - firstNonZero, 0);
List.copyRange(
_coefficients,
0,
coefficients,
firstNonZero,
firstNonZero + _coefficients.length,
);
}
} else {
_coefficients = coefficients;
}
}