@Override public void visit(Division node) { if (opstor.OperationShouldBeReplaced(node)) { nx = new Variable(opstor.getReplacementID(node)); System.out.println("Replacer: Node in Set: ( " + node.toString() + " ) ---> Replacing with " + opstor.getReplacementID(node)); } else { node.getLeft().accept(this); Expression lhs = nx; node.getRight().accept(this); Expression rhs = nx; nx = new Division(lhs, rhs); } } @Override
@Override protected Division create(Expression left, Expression right) { return new Division(left, right); } }
@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(Division node) { handlebinary(node); resultExpr = new Division(left, right); left=null; right=null; }
@Override public Expression visitDivision(MaximaParser.DivisionContext ctx) { return new Division(visit(ctx.left), visit(ctx.right)); }
@Override public Object visitDivision(CluCalcParser.DivisionContext ctx) { return new Division((Expression) visit(ctx.left), (Expression) visit(ctx.right)); }
@Override public void visit(Division node) { node.getLeft().accept(this); Expression left = resultExpr; node.getRight().accept(this); Expression right = resultExpr; if(left instanceof FloatConstant && ((FloatConstant)left).getValue() == 1.0) { resultExpr = new Division(left, right); } else { resultExpr = new Multiplication(left, new Division(new FloatConstant("1.0"), right)); } if ((left instanceof FloatConstant) && (right instanceof FloatConstant)) { FloatConstant leftc = (FloatConstant) left; FloatConstant rightc = (FloatConstant) right; resultExpr = new FloatConstant(leftc.getValue() / rightc.getValue()); } else if ((node.getRight() instanceof FloatConstant)) { /* division by 1 gets canceld */ FloatConstant floatConst = (FloatConstant) node.getRight(); if (floatConst.getValue() == 1.0) { resultExpr = left; } } }
/** * Returns the inverse of a MvExpressions object * @param mv The MvExpressions object to be inversed * @return The inverse */ private MvExpressions getInverse(MvExpressions mv) { MvExpressions revR = getReverse(mv); MvExpressions length = calculateUsingMultTable(Products.GEO, mv, revR); MvExpressions result = createNewMvExpressions(); for (int blade = 0; blade < bladeCount; blade++) { if (mv.bladeExpressions[blade] != null) { result.bladeExpressions[blade] = new Division(revR.bladeExpressions[blade].copy(), length.bladeExpressions[0]); } } return result; }
@Override public void visit(Division node) { node.getLeft().accept(this); Expression left = resultExpr; node.getRight().accept(this); Expression right = resultExpr; resultExpr = new Division(left, right); if (isConstant(left) && isConstant(right)) { FloatConstant leftc = (FloatConstant) left; FloatConstant rightc = (FloatConstant) right; resultExpr = new FloatConstant(leftc.getValue() / rightc.getValue()); setGraphModified(); } else if (isConstant(node.getRight())) { /* division by 1 gets canceled */ FloatConstant floatConst = (FloatConstant) node.getRight(); if (doubleEquals(floatConst.getValue(), 1.0f)) { resultExpr = left; setGraphModified(); } } }
result = new Multiplication(new Addition( new Multiplication(dv, new MathFunctionCall(node.getLeft().copy(), MathFunction.LOG)), new Division(new Multiplication(node.getRight().copy(), dLeft), node.getLeft().copy()) ), node.copy());
@Override public void visit(Division node) { node.getLeft().accept(this); Expression dLeft = result; node.getRight().accept(this); Expression dRight = result; } else { result = new Negation( new Division( new Multiplication( node.getLeft().copy(), dRight ), new Multiplication( node.getRight().copy(), node.getRight().copy() result = new Division( new Multiplication( dLeft, node.getRight().copy() ), new Multiplication( node.getRight().copy(), node.getRight().copy() result = new Division( new Subtraction( new Multiplication(dLeft, node.getRight().copy()),