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; }
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; }
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; }