/* (non-Javadoc) * @see com.amtx.math.Group#op(java.lang.Object, java.lang.Object) */ @Override public Polynomial<T> op(final Polynomial<T> p1, final Polynomial<T> p2) { Polynomial<T> p = addition.identity(); for (Map.Entry<Integer, T> e : p1.coefficients.entrySet()) { int i = e.getKey(); T d1 = e.getValue(); for (Map.Entry<Integer, T> e2 : p2.coefficients.entrySet()) { int j = e2.getKey(); T d2 = e2.getValue(); p = addition.op(p, addition.identity().setCoefficient(i + j, ring.multiply(d1, d2))); } } return p; }
/** * Constructs a PolynomialMultiplication * * @param addition The addition group * @param ring Ring for the coefficients */ public PolynomialMultiplication(Group<Polynomial<T>> addition, Ring<T, ?> ring) { super(); this.addition = addition; this.ring = ring; this.one = addition.identity().setCoefficient(0, ring.one()); }