multiply method

GFPoly multiply(
  1. GFPoly other
)

Implementation

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