/**
  * Construct a polynomial over a ring. In general the valueOf method should be used to construct a
  * new polynomial.
  *
  * @param baseRing the underlying ring of the polynomial.
  * @param symbol the symbol used to display the polynomial
  * @param coeffs an array of coefficients in the base ring coeff[0] is constant, coeff[1] is
  *     coefficient of t etc.
  */
 public Polynomial(RingI baseRing, String symbol, Number coeffs[]) {
   this.baseRing = baseRing;
   this.symbol = symbol;
   int deg = 0;
   for (int i = coeffs.length - 1; i > 0; --i)
     if (!baseRing.equals(coeffs[i], baseRing.getZERO())) {
       deg = i;
       break;
     }
   if (deg == coeffs.length - 1) this.coeffs = coeffs;
   else {
     this.coeffs = new Number[deg + 1];
     System.arraycopy(coeffs, 0, this.coeffs, 0, deg + 1);
   }
   this.degree = deg;
 }
 public boolean equalsPoly(Polynomial n) {
   if (this.getDegree() != n.getDegree()) return false;
   for (int i = 0; i <= this.getDegree(); ++i)
     if (!baseRing.equals(this.getCoeff(i), n.getCoeff(i))) return false;
   return true;
 }