Ejemplo n.º 1
0
  public Number calculateValue(Number rootVal) {
    Number val = coeffs[this.getDegree()];

    for (int i = this.getDegree() - 1; i >= 0; --i) {
      Number val2 = coeffs[i];
      Number prod = baseRing.mul(val, rootVal);
      val = baseRing.add(prod, val2);
    }
    return val;
  }
Ejemplo n.º 2
0
  public Polynomial mul(Polynomial poly) {
    int deg = degree + poly.degree;
    Number lcoeffs[] = new Number[deg + 1];
    for (int i = 0; i <= deg; ++i) lcoeffs[i] = baseRing.getZERO();

    for (int i = 0; i <= degree; ++i)
      for (int j = 0; j <= poly.degree; ++j) {
        lcoeffs[i + j] = baseRing.add(lcoeffs[i + j], baseRing.mul(coeffs[i], poly.coeffs[j]));
      }
    return valueOf(lcoeffs);
  }