@Override public void visit(Exponentiation node) { result = null; node.getLeft().accept(this); Expression leftResult = result; node.getRight().accept(this); Expression rightResult = result; if (leftResult != null || rightResult != null) result = new Exponentiation(leftResult, rightResult); }
@Override public void visit(Exponentiation node) { Multiplication nodeMul; if (isSquare(node)) { nodeMul = new Multiplication(node.getLeft(), node.getLeft()); nx = nodeMul; if (opstor.OperationShouldBeReplaced(nodeMul)) { nx = new Variable(opstor.getReplacementID(nodeMul)); } } else { 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 Exponentiation(lhs, rhs); } } }
@Override public void visit(Exponentiation node) { node.getLeft().accept(this); Expression dLeft = result; node.getRight().accept(this); Expression dRight = result; node.getRight().copy(), new Exponentiation( node.getLeft().copy(), new Subtraction(node.getRight().copy(), new FloatConstant(1)) node.getRight().accept(this); Expression dv = result; result = new Multiplication( new Multiplication(dv, new MathFunctionCall(node.getLeft().copy(), MathFunction.LOG)), node.copy() ); } else { node.getRight().accept(this); Expression dv = result; 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());
private boolean isSqrt(Exponentiation exp) { final FloatConstant one = new FloatConstant(1.0f); final FloatConstant two = new FloatConstant(2.0f); final FloatConstant half = new FloatConstant(0.5f); if(exp.getRight() instanceof FloatConstant) { return exp.getRight().equals(half); } if(exp.getRight() instanceof Division) { Division div = (Division)exp.getRight(); if(div.getLeft().equals(one) && div.getRight().equals(two)) return true; } return false; }
@Override public void visit(Exponentiation node) { handlebinary(node); resultExpr = new Exponentiation(left, right); }
/** * Returns if the exponentiation has an exponent which is equal to 2 * @param exponentiation The exponentiation * @return <value>true</value> if the exponent is equal to 2, <value>false</value> otherwise */ protected boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
@Override public Expression visitExponentiation(MaximaParser.ExponentiationContext ctx) { return new Exponentiation(visit(ctx.left), visit(ctx.right)); }
@Override public Expression copy() { return new Exponentiation(getLeft().copy(), getRight().copy()); }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
Expression square = new Exponentiation(node.getValue(), new FloatConstant(2));
@Override public void visit(Exponentiation node) { traverseBinary(node); MvExpressions l = expressions.get(node.getLeft()); MvExpressions r = expressions.get(node.getRight()); MvExpressions result = createNewMvExpressions(); result.bladeExpressions[0] = new Exponentiation(l.bladeExpressions[0], r.bladeExpressions[0]); expressions.put(node, result); System.err.println("Warning: Exponentiation is only implemented for scalars!"); }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
Expression square = new Exponentiation(node.getValue(), new FloatConstant(2));
@Override//dfg public void visit(Exponentiation node) { if (isSquare(node) && (node.getLeft() instanceof Variable)) { String varname = null; if(node.getLeft() instanceof MultivectorComponent){ varname = ((MultivectorComponent)node.getLeft()).getName() + ((MultivectorComponent)node.getLeft()).getBladeIndex(); } else varname= ((Variable)node.getLeft()).getName(); if (!myHashmap.containsKey(varname)){ myHashmap.put(varname, ( varname + "_quad")); AddedExponentiationBang = new AssignmentNode(cfg, new Variable(varname+"_quad"), new Multiplication(node.getLeft(), node.getLeft())); //new AssignmentNode(cfg,new Variable(varname+"_quad"),node.copy()); currentAssignment.insertBefore(AddedExponentiationBang); } nx = new Variable(myHashmap.get(varname)); } else // left is novariable or node is no square { node.getLeft().accept(this); Expression lhs =nx; node.getRight().accept(this); Expression rhs =nx; nx = new Exponentiation(lhs, rhs); } }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }