示例#1
0
 public void recomputeSize() {
   if (ineq != null) {
     size = 1;
   } else size = 0;
   if (left != null) {
     left.recomputeSize();
     size += left.size;
   }
   if (right != null) {
     right.recomputeSize();
     size += right.size;
   }
 }
示例#2
0
 public boolean updateCoef() {
   if (ineq != null) {
     ineq.updateCoef();
     // Application.debug(ineq.getType());
     return ineq.getType() != Inequality.INEQUALITY_INVALID;
   }
   if (left == null && right == null) return false;
   boolean b = true;
   if (left != null) b &= left.updateCoef();
   if (right != null) b &= right.updateCoef();
   // Application.debug("tree" + b);
   return b;
 }
示例#3
0
 public double[] getZeros(Set<Double> zeros) {
   if (ineq != null) {
     GeoPoint[] zeroPoints = ineq.getZeros();
     for (int i = 0; i < zeroPoints.length; i++) {
       zeros.add(zeroPoints[i].getX());
     }
   }
   if (left != null) {
     left.getZeros(zeros);
   }
   if (right != null) {
     right.getZeros(zeros);
   }
   return null;
 }
示例#4
0
 private boolean initIneqs(
     ExpressionNode fe, FunctionalNVar functional, IneqTree tree, boolean negate) {
   int op = fe.getOperation();
   ExpressionNode leftTree = fe.getLeftTree();
   ExpressionNode rightTree = fe.getRightTree();
   if (op == ExpressionNode.GREATER
       || op == ExpressionNode.GREATER_EQUAL
       || op == ExpressionNode.LESS
       || op == ExpressionNode.LESS_EQUAL) {
     Inequality newIneq =
         new Inequality(
             kernel,
             leftTree,
             rightTree,
             adjustOp(op, negate),
             getFunction().getFunctionVariables(),
             functional);
     if (newIneq.getType() != Inequality.INEQUALITY_INVALID) {
       if (newIneq.getType() != Inequality.INEQUALITY_1VAR_X
           && newIneq.getType() != Inequality.INEQUALITY_1VAR_Y)
         newIneq.getBorder().setInverseFill(newIneq.isAboveBorder());
       tree.setIneq(newIneq);
     }
     return newIneq.getType() != Inequality.INEQUALITY_INVALID;
   } else if (op == ExpressionNode.AND
       || op == ExpressionNode.OR
       || op == ExpressionNode.EQUAL_BOOLEAN
       || op == ExpressionNode.NOT_EQUAL) {
     tree.operation = adjustOp(op, negate);
     tree.left = new IneqTree();
     tree.right = new IneqTree();
     return initIneqs(leftTree, functional, tree.left, negate)
         && initIneqs(rightTree, functional, tree.right, negate);
   } else if (op == ExpressionNode.NOT) {
     return initIneqs(leftTree, functional, tree, !negate);
   } else if (op == ExpressionNode.FUNCTION_NVAR) {
     FunctionalNVar nv = (FunctionalNVar) leftTree.getLeft();
     IneqTree otherTree = nv.getIneqs();
     if (otherTree == null || otherTree.getSize() == 0) {
       return false;
     }
     tree.left = otherTree.left;
     tree.right = otherTree.right;
     tree.operation = otherTree.operation;
     tree.ineq = otherTree.ineq;
     return true;
   } else return false;
 }
示例#5
0
 /**
  * updates list of inequalities
  *
  * @return true iff all inequalities are drawable
  */
 public boolean updateIneqs() {
   if (ineqs == null) return false;
   return ineqs.updateCoef();
 }
示例#6
0
 /**
  * initializes inequalities
  *
  * @param fe expression node
  * @param functional function to which ineqs are associated
  * @return true if the functions consists of inequalities
  */
 public boolean initIneqs(ExpressionNode fe, FunctionalNVar functional) {
   if (ineqs == null || fe == getExpression()) ineqs = new IneqTree();
   boolean b = initIneqs(fe, functional, ineqs, false);
   ineqs.recomputeSize();
   return b;
 }
示例#7
0
 public Inequality get(int i) {
   if (ineq != null) return ineq;
   if (i < left.getSize()) return left.get(i);
   return right.get(i - left.getSize());
 }