multiplyPoly method
Implementation
ModulusPoly multiplyPoly(ModulusPoly other) {
if (_field != other._field) {
throw ArgumentError('ModulusPolys do not have same ModulusGF field');
}
if (isZero || other.isZero) {
return _field.zero;
}
final aCoefficients = _coefficients;
final aLength = aCoefficients.length;
final bCoefficients = other._coefficients;
final bLength = bCoefficients.length;
final product = List.filled(aLength + bLength - 1, 0);
for (int i = 0; i < aLength; i++) {
final aCoeff = aCoefficients[i];
for (int j = 0; j < bLength; j++) {
product[i + j] = _field.add(
product[i + j],
_field.multiply(aCoeff, bCoefficients[j]),
);
}
}
return ModulusPoly(_field, product);
}