@Override public void visit(Negation node) { node.getOperand().accept(this); if (result != zero) result = new Negation(result); }
/** * Converts this negation node into a human readable representation. * * @return The string "<code>-(operand)</code>" where operand has been converted to a string using its toString * method. */ public String toString() { return "-(" + getOperand() + ")"; } }
/** * Creates an expression node that negates the given expression. * * @param value The expression that should be negated. A deep copy will be created. * @return A Negation object that negates the given expression. */ public static Negation negate(Expression value) { return new Negation(value.copy()); }
@Override public void visit(Multiplication multiplication) { if (multiplication.getLeft().equals(HALF)) { ONE_HALF.accept(this); multiplication.getRight().accept(this); } else if (multiplication.getRight().equals(HALF)) { ONE_HALF.accept(this); multiplication.getLeft().accept(this); } else if (multiplication.getLeft().equals(MINUS_HALF)) { MINUS_ONE_HALF.accept(this); multiplication.getRight().accept(this); } else if (multiplication.getRight().equals(MINUS_HALF)) { MINUS_ONE_HALF.accept(this); multiplication.getLeft().accept(this); } else { addBinaryInfix(multiplication, "*"); } }
@Override public void visit(Negation node) { // just do nothing, because only MulitvectorComponent is important node.getOperand().accept(this); }
@Override public Expression visitNegation(MaximaParser.NegationContext ctx) { return new Negation(visit(ctx.operand)); }
@Override public void visit(Negation node) { node.getOperand().accept(this); nx= new Negation(nx); }
@Override public void visit(Negation node) { node.getOperand().accept(this); result = -result; }
@Override public Expression visitNegationBracket(MaximaParser.NegationBracketContext ctx) { return new Negation(visit(ctx.operand)); }
@Override public void visit(Negation node) { result = null; node.getOperand().accept(this); if (result != null) result = new Negation(result); }
@Override public void visit(Negation negation) { code.append('-'); addChild(negation, negation.getOperand()); }
@Override public Object visitNegationBracket(CluCalcParser.NegationBracketContext ctx) { return new Negation((Expression) visit(ctx.operand)); }
@Override //dfg public void visit(Negation node) { node .getOperand().accept(this); // gefixt ...war schrott: nx = node; nx = new Negation(nx); }
@Override public void visit(Negation negation) { code.append('('); code.append('-'); addChild(negation, negation.getOperand()); code.append(')'); }
@Override public Object visitNegation(CluCalcParser.NegationContext ctx) { return new Negation((Expression) visit(ctx.operand)); }
@Override public Expression copy() { return new Negation(getOperand().copy()); }
@Override public void visit(Negation negation) { code.append('-'); negation.getOperand().accept(this); }
@Override public Object visitNegationFunction(CluCalcParser.NegationFunctionContext ctx) { LinkedList<Expression> args = (ctx.args != null) ? (LinkedList<Expression>) visit(ctx.args) : new LinkedList<Expression>(); return new Negation(graphBuilder.processFunction(ctx.name.getText(), args)); }
@Override public void visit(Negation node) { node.getOperand().accept(this); if (node.getOperand() instanceof MultivectorComponent && oneset.containsKey(((MultivectorComponent) node.getOperand()).toString())) { System.out.println("Assignment: "+ currAssignString+ " - Replaceable Negation Operand: " + ((MultivectorComponent) node.getOperand()).toString()+ "with: "+ oneset.get(((MultivectorComponent)node.getOperand()).toString())); resultExpr = new FloatConstant(oneset.get(((MultivectorComponent)node.getOperand()).toString())); replacements++; } resultExpr = new Negation(resultExpr); }
@Override public void visit(Negation negation) { code.append('('); code.append('-'); addChild(negation, negation.getOperand()); code.append(')'); }