Пример #1
0
 /**
  * The constructor creates a Quotient object from a ring factory and a numerator and denominator
  * element.
  *
  * @param r ring factory.
  * @param n numerator.
  * @param d denominator.
  * @param isred true if gcd(n,d) == 1, else false.
  */
 @SuppressWarnings("unchecked")
 protected Quotient(QuotientRing<C> r, C n, C d, boolean isred) {
   if (d == null || d.isZERO()) {
     throw new IllegalArgumentException("denominator may not be zero");
   }
   ring = r;
   if (d.signum() < 0) {
     n = n.negate();
     d = d.negate();
   }
   if (isred) {
     num = n;
     den = d;
     return;
   }
   // must reduce to lowest terms
   if (n instanceof GcdRingElem && d instanceof GcdRingElem) {
     GcdRingElem ng = (GcdRingElem) n;
     GcdRingElem dg = (GcdRingElem) d;
     C gcd = (C) ng.gcd(dg);
     if (debug) {
       logger.info("gcd = " + gcd);
     }
     // RingElem<C> gcd = ring.ring.getONE();
     if (gcd.isONE()) {
       num = n;
       den = d;
     } else {
       num = n.divide(gcd);
       den = d.divide(gcd);
     }
     // } else { // univariate polynomial?
   } else {
     logger.warn("gcd = ????");
     num = n;
     den = d;
   }
 }
Пример #2
0
 /**
  * Quotient negate.
  *
  * @return -this.
  * @see edu.jas.structure.RingElem#negate()
  */
 public Quotient<C> negate() {
   return new Quotient<C>(ring, num.negate(), den, true);
 }