Example #1
0
 /**
  * Bi-section point.
  *
  * @param iv interval with f(left) * f(right) != 0.
  * @param f univariate polynomial, non-zero.
  * @return a point c in the interval iv such that f(c) != 0.
  */
 public C bisectionPoint(Interval<C> iv, GenPolynomial<C> f) {
   if (f == null) {
     return null;
   }
   RingFactory<C> cfac = f.ring.coFac;
   C two = cfac.fromInteger(2);
   C c = iv.left.sum(iv.right);
   c = c.divide(two);
   if (f.isZERO() || f.isConstant()) {
     return c;
   }
   C m = PolyUtil.<C>evaluateMain(cfac, f, c);
   while (m.isZERO()) {
     C d = iv.left.sum(c);
     d = d.divide(two);
     if (d.equals(c)) {
       d = iv.right.sum(c);
       d = d.divide(two);
       if (d.equals(c)) {
         throw new RuntimeException("should not happen " + iv);
       }
     }
     c = d;
     m = PolyUtil.<C>evaluateMain(cfac, f, c);
     // System.out.println("c = " + c);
   }
   // System.out.println("c = " + c);
   return c;
 }
Example #2
0
 public boolean equals(Object o) {
   if (o instanceof Triple) {
     Triple t = (Triple) o;
     return first.equals(t.first) && second.equals(t.second) && third.equals(t.third);
   }
   return false;
 }
Example #3
0
 @Override
 @SuppressWarnings("rawtypes")
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (getClass() != obj.getClass()) {
     return false;
   }
   InstanceContextHolder other = (InstanceContextHolder) obj;
   if (context == null) {
     if (other.context != null) {
       return false;
     }
   } else if (!context.equals(other.context)) {
     return false;
   }
   if (instance == null) {
     if (other.instance != null) {
       return false;
     }
   } else if (!instance.equals(other.instance)) {
     return false;
   }
   return true;
 }
Example #4
0
 @Override
 public boolean equals(Object o) {
   if (o instanceof Block<?>) {
     Block<?> c = (Block<?>) o;
     return x == c.x && y == c.y && content.equals(c.content);
   }
   return false;
 }
Example #5
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (obj == null) {
      return false;
    }

    if (getClass() != obj.getClass()) {
      return false;
    }

    final ThreeTuple<?, ?, ?> t = (ThreeTuple<?, ?, ?>) obj;

    if (a.equals(t.a) && b.equals(t.b) && c.equals(t.c)) {
      return true;
    }

    return false;
  }
Example #6
0
 /**
  * Is Quotient one.
  *
  * @return If this is 1 then true is returned, else false.
  * @see edu.jas.structure.RingElem#isONE()
  */
 public boolean isONE() {
   return num.equals(den);
 }