Package ptolemy.math

Examples of ptolemy.math.Precision$ExpressionLanguagePrecisionFormat


     @param numberOfBits The total number of bits.
     *  @param integerBits The number of bits used for the integer part.
     *  @return A fixed point representation of the value.
     */
    public static FixPoint fix(double value, int numberOfBits, int integerBits) {
        Precision precision = new Precision(numberOfBits, integerBits);
        return Quantizer.round(value, precision);
    }
View Full Code Here


     @param integerBits The number of bits used for the integer part.
     *  @return a double with value that is quantized.
     */
    public static double quantize(double value, int numberOfBits,
            int integerBits) {
        FixPoint fixValue = Quantizer.round(value, new Precision(numberOfBits,
                integerBits));
        return fixValue.doubleValue();
    }
View Full Code Here

                ptolemy.data.Token length = parseTreeEvaluator
                        .evaluateParseTree(lengthNode, _scope);

                ptolemy.data.Token integerBits = parseTreeEvaluator
                        .evaluateParseTree(integerBitsNode, _scope);
                _setType(node, new FixType(new Precision(((ScalarToken) length)
                        .intValue(), ((ScalarToken) integerBits).intValue())));
                return;
            } catch (Throwable throwable) {
                // Do nothing... rely on the regular method resolution
                // to generate the right type.
View Full Code Here

        if (A.isKnown() && A.hasToken(0)) {
            FixPoint valueA = ((FixToken) A.get(0)).fixValue();
            bitsInResult = valueA.getPrecision().getNumberOfBits();
            BigInteger bigIntA = valueA.getUnscaledValue();
            intResult = bigIntA.not();
            Precision precision = new Precision(1, bitsInResult, 0);
            FixToken result = new FixToken(intResult.doubleValue(), precision);
            sendOutput(output, 0, result);
        } else {
            output.resend(0);
        }
View Full Code Here

            if (trigger.hasToken(i)) {
                trigger.get(i);
            }
        }

        Precision precision = new Precision(
                ((Parameter) getAttribute("outputPrecision")).getExpression());

        Overflow overflow = Overflow
                .getName(((Parameter) getAttribute("outputOverflow"))
                        .getExpression().toLowerCase());
View Full Code Here

            if ((token.getRowCount() != 1) || (token.getColumnCount() != 2)) {
                throw new IllegalActionException(this,
                        "Invalid precision (not a 1 by 2 matrix).");
            }

            Precision precision = new Precision(token.getElementAt(0, 0), token
                    .getElementAt(0, 1));
            output.setTypeEquals(new FixType(precision));
            _quantization = _quantization.setPrecision(precision);
        } else if (attribute == rounding) {
            Rounding r = Rounding.getName(rounding.getExpression());
View Full Code Here

            if ((token.getRowCount() != 1) || (token.getColumnCount() != 2)) {
                throw new IllegalActionException(this,
                        "Invalid precision (not a 1 by 2 matrix).");
            }

            Precision precision = new Precision(token.getElementAt(0, 0), token
                    .getElementAt(0, 1));
            _quantization = _quantization.setPrecision(precision);
            if (_quantization.getOverflow() == Overflow.GROW) {
                output.setTypeEquals(BaseType.UNSIZED_FIX);
            } else {
View Full Code Here

                }
            } catch (NameDuplicationException ex) {
                throw new IllegalActionException(this, ex,
                        "Fail to set the initialValue parameter.");
            }
            Precision precision = new Precision(
                    ((Parameter) getAttribute("outputPrecision"))
                            .getExpression());

            Overflow overflow = Overflow
                    .getName(((Parameter) getAttribute("outputOverflow"))
                            .getExpression().toLowerCase());

            Rounding rounding = Rounding
                    .getName(((Parameter) getAttribute("outputRounding"))
                            .getExpression().toLowerCase());

            FixPoint result = new FixPoint(((ScalarToken) initialValue
                    .getToken()).doubleValue(), new FixPointQuantization(
                    precision, overflow, rounding));
            output.setInitToken(new FixToken(result));
        }
        if (attribute == initialValue) {
            Precision precision = new Precision(
                    ((Parameter) getAttribute("outputPrecision"))
                            .getExpression());

            Overflow overflow = Overflow
                    .getName(((Parameter) getAttribute("outputOverflow"))
View Full Code Here

    /** Initialize the state of the actor.
     *  @exception IllegalActionException If there is no director.
     */
    public void initialize() throws IllegalActionException {
        Precision precision = new Precision(
                ((Parameter) getAttribute("outputPrecision")).getExpression());

        Overflow overflow = Overflow
                .getName(((Parameter) getAttribute("outputOverflow"))
                        .getExpression().toLowerCase());
View Full Code Here

            Arrays.fill(mask, newStartValue, newEndValue, '1');

            BigDecimal value = new BigDecimal(in.fixValue().getUnscaledValue()
                    .and(new BigInteger(new String(mask), 2)).shiftRight(
                            shiftBits));
            Precision precision = new Precision(
                    ((Parameter) getAttribute("outputPrecision"))
                            .getExpression());
            if ((newEndValue - newStartValue) != precision.getNumberOfBits()) {
                throw new IllegalActionException(this, "Bit width of "
                        + (newEndValue - newStartValue)
                        + " is not equal to precision " + precision);
            }
View Full Code Here

TOP

Related Classes of ptolemy.math.Precision$ExpressionLanguagePrecisionFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.