public ColorNode(ControlFlowGraph graph, Expression r, Expression g, Expression b) { super(graph); this.r = r; this.g = g; this.b = b; this.alpha = new FloatConstant(1f); }
@Override public Expression copy() { return new FloatConstant(value, valueString); // FIXME: improve by returning this (immutable)? }
private ColorNode getRBGColor(double r, double g, double b) { return new ColorNode(graph, new FloatConstant(r), new FloatConstant(g), new FloatConstant(b)); }
@Override public Expression visitConstant(MaximaParser.ConstantContext ctx) { String text = ctx.getText(); if ("%pi".equals(text)) return new FloatConstant(Math.PI); if ("%i".equals(text)) return new MathFunctionCall(new FloatConstant(-1), MathFunction.SQRT); return new FloatConstant(Double.parseDouble(text)); }
@Override public void visit(FloatConstant node) { result = null; double multiplicator = Math.pow(10, numberOfDigits); result = new FloatConstant(Math.round(node.getValue() * multiplicator) / multiplicator); }
@Override public void visit(MultivectorComponent node) { result = (node.equals(diffVar)) ? new FloatConstant(1) : zero; }
/** * Converts a string into either an BaseVector or FloatConstant * @param string The string * @return The converted string */ private Expression getBaseVector(String string) { if (string.equals("1")) { return new FloatConstant(1); } else { return new BaseVector(string.substring(1)); } }
@Override public Object visitConstant(CluCalcParser.ConstantContext ctx) { return new FloatConstant(Double.parseDouble(ctx.getText())); }
/** * Creates an expression from this blade * @return The expression */ public Expression toExpression() { if (base.length == 1 && base[0].equals("1")) return new FloatConstant(1); Expression[] exprArr = new Expression[base.length]; for (int i=0;i<exprArr.length;i++) exprArr[i] = new BaseVector(base[i].substring(1)); return exprArrToOuterProduct(exprArr); }
@Override public void visit(MultivectorComponent node) { if (oneset.containsKey(node.toString())) { resultExpr = new FloatConstant(oneset.get(node.toString())); replacements++; } else { resultExpr = node; } }
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; }
/** * 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()); }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
protected boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
@Override public void visit(BaseVector node) { MvExpressions result = createNewMvExpressions(); result.bladeExpressions[alFile.getIndex(node.toString())] = new FloatConstant(1); expressions.put(node, result); }
@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(Division node) { if (node.getRight() instanceof FloatConstant) { FloatConstant newLeft = new FloatConstant(1/((FloatConstant) node.getRight()).getValue()); replaceWith = new Multiplication(newLeft, node.getLeft()); } }