@Override public void visit(FloatConstant node) { result = null; double multiplicator = Math.pow(10, numberOfDigits); result = new FloatConstant(Math.round(node.getValue() * multiplicator) / multiplicator); }
/** * 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 void visit(FloatConstant floatConstant) { addNode(floatConstant, floatConstant.toString()); }
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 void visit(FloatConstant node) { result = node.getValue(); }
@Override public void visit(FloatConstant fcnode) { System.out.println("MyFloatConstantVisit"); // VerilogFloatNode newnode =new VerilogFloatNode(dfg); // FPValue fpv = new FPValue(fcnode.getValue(),32,16); // ConstantOperation co = new // ConstantOperation(Integer.toString((int)fpv.getBinaryvalue())); // VerilogFloatNode newnode =new VerilogFloatNode(dfg); // ConstantOperation co = new ConstantOperation(Float.toString(fcnode // .getValue())); FloatValue value = new FloatValue(); value.setValue(new Float(fcnode.getValue()).floatValue()); ConstantOperation co = new ConstantOperation(value, fcnode.toString()); co.setOutputBitsize(32); // newnode.setValue(fcnode.getValue()); toappend = co; addToGraph(toappend); }
@Override public Expression copy() { return new FloatConstant(value, valueString); // FIXME: improve by returning this (immutable)? }
@Override public void visit(FloatConstant node) { resultValue = node.getValue(); }
@Override public void visit(Negation node) { node.getOperand().accept(this); Expression previousExpr = resultExpr; resultExpr = new Negation(resultExpr); if ((previousExpr instanceof FloatConstant)) { FloatConstant operand = (FloatConstant) previousExpr; if(operand.getValue() == 0.0) { resultExpr = new FloatConstant(0.0f); } else { resultExpr = new FloatConstant(-operand.getValue()); } } else if (previousExpr instanceof Negation) { Negation operand = (Negation) previousExpr; resultExpr = operand.getOperand(); } }
private ColorNode getRBGColor(double r, double g, double b) { return new ColorNode(graph, new FloatConstant(r), new FloatConstant(g), new FloatConstant(b)); }
public boolean isPowerOf2(Expression node) { double f; int fi; if (node instanceof FloatConstant) { f = ((FloatConstant) node).getValue(); fi = (int) ((FloatConstant) node).getValue(); if ((fi >=2) &&(f == fi) && (Integer.bitCount(fi) == 1 )) { return true; } else { return false; } } else { return false; } }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
@Override public void visit(Addition node) { node.getLeft().accept(this); Expression left = resultExpr; node.getRight().accept(this); Expression right = resultExpr; resultExpr = new Addition(left, 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(left instanceof FloatConstant) { FloatConstant leftc = (FloatConstant) left; if(leftc.getValue() == 0.0) { resultExpr = right; } } else if (right instanceof FloatConstant) { FloatConstant rightc = (FloatConstant) right; if(rightc.getValue() == 0.0) { resultExpr = left; } } }
@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 floatConstant) { if (Double.isNaN(floatConstant.getValue())) code.append("undefined"); else if (compare(floatConstant.getValue(), Math.floor(floatConstant.getValue())) == 0) { code.append((int) floatConstant.getValue()); } else { code.append(Double.toString(floatConstant.getValue())); } }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }
resultExpr = (leftc.getValue() > rightc.getValue()) ? new FloatConstant(1.0f) : new FloatConstant(0.0f); break; case GREATER_OR_EQUAL: resultExpr = (leftc.getValue() >= rightc.getValue()) ? new FloatConstant(1.0f) : new FloatConstant(0.0f); break; case LESS: resultExpr = (leftc.getValue() < rightc.getValue()) ? new FloatConstant(1.0f) : new FloatConstant(0.0f); break; case LESS_OR_EQUAL: resultExpr = (leftc.getValue() <= rightc.getValue()) ? new FloatConstant(1.0f) : new FloatConstant(0.0f); break; default:
@Override public void visit(MultivectorComponent node) { result = (node.equals(diffVar)) ? new FloatConstant(1) : zero; }
@Override public void visit(FloatConstant floatConstant) { code.append(Double.toString(floatConstant.getValue())); //code.append('d'); }
private boolean isSquare(Exponentiation exponentiation) { final FloatConstant two = new FloatConstant(2.0f); return two.equals(exponentiation.getRight()); }