Package ptolemy.math

Examples of ptolemy.math.Precision


    protected StructuredType _greatestLowerBound(StructuredType type) {
        if (!(type instanceof FixType)) {
            throw new IllegalArgumentException("FixType._greatestLowerBound: "
                    + "The argument is not a FixType.");
        }
        Precision precision = ((FixType) type).getPrecision();
        int fractionBits = Math.min(precision.getFractionBitLength(),
                _precision.getFractionBitLength());
        int integerBits = Math.min(precision.getIntegerBitLength(), _precision
                .getIntegerBitLength());
        return new FixType(new Precision(fractionBits + integerBits,
                integerBits));
    }
View Full Code Here


    protected StructuredType _leastUpperBound(StructuredType type) {
        if (!(type instanceof FixType)) {
            throw new IllegalArgumentException("FixType._greatestLowerBound: "
                    + "The argument is not a FixType.");
        }
        Precision precision = ((FixType) type).getPrecision();
        int fractionBits = Math.max(precision.getFractionBitLength(),
                _precision.getFractionBitLength());
        int integerBits = Math.max(precision.getIntegerBitLength(), _precision
                .getIntegerBitLength());
        FixType returnType = new FixType(new Precision(fractionBits
                + integerBits, integerBits));
        returnType._checkPrecision();
        return returnType;
    }
View Full Code Here

            _capacity = ((ScalarToken) capacity.getToken()).intValue();

            _addressWidth = (int) Math.floor(Math.log(_capacity) / Math.log(2));

        } else if (attribute.getName().equals("outputPrecision")) {
            _dataWidth = new Precision(getPortPrecision(output))
                    .getNumberOfBits();
        }
    }
View Full Code Here

     @exception IllegalActionException If there is no director.
     */
    public void fire() throws IllegalActionException {
        super.fire();
        FixToken result = null;
        Precision precision = new Precision(0, 1, 0);

        if (A.isKnown() && B.isKnown()) {
            result = new FixToken(0, precision);
            FixToken inputA = new FixToken();
            FixToken inputB = new FixToken();
View Full Code Here

     * @exception NoRoomException If there is no room in the receiver.
     */
    public void sendOutput(TypedIOPort port, int channel, Token token)
            throws NoRoomException, IllegalActionException {
        if (port.getType() == BaseType.FIX && token instanceof FixToken) {
            Precision precision = new Precision(((Parameter) getAttribute(port
                    .getName()
                    + "Precision")).getExpression());

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

     @exception IllegalActionException If there is no director.
     */
    public void fire() throws IllegalActionException {
        super.fire();

        Precision precision = new Precision(getPortPrecision(output));

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

View Full Code Here

                || (enable.hasToken(0) && ((BooleanToken) enable.get(0))
                        .booleanValue())) {
            ArrayToken valuesArray = (ArrayToken) values.getToken();

            if (_currentIndex < valuesArray.length()) {
                Precision precision = new Precision(
                        ((Parameter) getAttribute("outputPrecision"))
                                .getExpression());

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

                _checkFixTokenWidth(channel, 1);

                _channel = channel.fixValue().getUnscaledValue().intValue();
            }

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

            FixToken tokenA = null;
            FixToken tokenB = null;

            if (A.hasToken(0)) {
                tokenA = (FixToken) A.get(0);
                if (tokenA.fixValue().getPrecision().getNumberOfBits() != outputPrecision
                        .getNumberOfBits()) {

                    throw new IllegalActionException(this,
                            "Input A has different width than the output port");
                }
            }
            if (B.hasToken(0)) {
                tokenB = (FixToken) B.get(0);
                if (tokenB.fixValue().getPrecision().getNumberOfBits() != outputPrecision
                        .getNumberOfBits()) {

                    throw new IllegalActionException(this,
                            "Input B has different width than the output port");
                }
View Full Code Here

    public void fire() throws IllegalActionException {
        super.fire();

        if (A.isKnown() && B.isKnown()) {
            BigInteger intResult = null;
            Precision precision = new Precision(
                    ((Parameter) getAttribute("outputPrecision"))
                            .getExpression());
            if (A.hasToken(0) && B.hasToken(0)) {
                FixPoint valueA = ((FixToken) A.get(0)).fixValue();
                FixPoint valueB = ((FixToken) B.get(0)).fixValue();
                if (valueA.getPrecision().getNumberOfBits() != precision
                        .getNumberOfBits()) {
                    throw new IllegalActionException(this,
                            "Input A has different width than the output port");
                }
                if (valueB.getPrecision().getNumberOfBits() != precision
                        .getNumberOfBits()) {
                    throw new IllegalActionException(this,
                            "Input B has different width than the output port");
                }
                BigInteger bigIntA = valueA.getUnscaledValue();
View Full Code Here

     @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(int value, int numberOfBits, int integerBits) {
        Precision precision = new Precision(numberOfBits, integerBits);
        return Quantizer.round(value, precision);
    }
View Full Code Here

TOP

Related Classes of ptolemy.math.Precision

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.