multiply method

GFPoly multiply(
  1. GFPoly other
)

Implementation

GFPoly multiply(GFPoly other) {
  if (zero() || other.zero()) {
    return gf.zero();
  }
  final aCoeff = coefficients;
  final aLen = aCoeff.length;
  final bCoeff = other.coefficients;
  final bLen = bCoeff.length;
  final product = List<int>.filled(aLen + bLen - 1, 0);
  for (var i = 0; i < aLen; i++) {
    final ac = aCoeff[i];
    for (var j = 0; j < bLen; j++) {
      final bc = bCoeff[j];
      product[i + j] = gf.addOrSub(product[i + j], gf.multiply(ac, bc));
    }
  }
  return GFPoly(gf, product);
}