Esempio n. 1
0
 /**
  * Get an atomic element.
  *
  * @param i index.
  * @return e_i as Product.
  */
 public Product<C> getAtomic(int i) {
   if (i < 0 || i >= length()) {
     throw new RuntimeException("index out of bounds " + i);
   }
   SortedMap<Integer, C> elem = new TreeMap<Integer, C>();
   if (nCopies != 0) {
     elem.put(i, ring.getONE());
   } else {
     RingFactory<C> f = ringList.get(i);
     elem.put(i, f.getONE());
   }
   return new Product<C>(this, elem, 1);
 }
Esempio n. 2
0
 /**
  * Get the one element.
  *
  * @return 1 as Product.
  */
 public Product<C> getONE() {
   SortedMap<Integer, C> elem = new TreeMap<Integer, C>();
   if (nCopies != 0) {
     for (int i = 0; i < nCopies; i++) {
       elem.put(i, ring.getONE());
     }
   } else {
     int i = 0;
     for (RingFactory<C> f : ringList) {
       elem.put(i, f.getONE());
       i++;
     }
   }
   return new Product<C>(this, elem, 1);
 }
Esempio n. 3
0
 /**
  * Real root bound. With f(M) * f(-M) != 0.
  *
  * @param f univariate polynomial.
  * @return M such that -M &lt; root(f) &lt; M.
  */
 public C realRootBound(GenPolynomial<C> f) {
   if (f == null) {
     return null;
   }
   RingFactory<C> cfac = f.ring.coFac;
   C M = cfac.getONE();
   if (f.isZERO() || f.isConstant()) {
     return M;
   }
   C a = f.leadingBaseCoefficient().abs();
   for (C c : f.getMap().values()) {
     C d = c.abs().divide(a);
     if (M.compareTo(d) < 0) {
       M = d;
     }
   }
   // works also without this case, only for optimization
   // to use rational number interval end points
   // can fail if real root is in interval [r,r+1]
   // for too low precision or too big r, since r is approximation
   if ((Object) M instanceof RealAlgebraicNumber) {
     RealAlgebraicNumber Mr = (RealAlgebraicNumber) M;
     BigRational r = Mr.magnitude();
     M = cfac.fromInteger(r.numerator()).divide(cfac.fromInteger(r.denominator()));
   }
   M = M.sum(f.ring.coFac.getONE());
   // System.out.println("M = " + M);
   return M;
 }