Package ptolemy.math

Examples of ptolemy.math.Precision$LengthExponentPrecisionFormat


     *  fractional part.
     */
    public FixMatrixToken() {
        _rowCount = 1;
        _columnCount = 1;
        _precision = new Precision(32, 32);
        _value = new FixPoint[1][1];
        _value[0][0] = Quantizer.round(0.0, _precision);
    }
View Full Code Here


     *   is invalid.
     */
    public FixToken(double value, int numberOfBits, int integerBits)
            throws IllegalArgumentException {
        try {
            Precision precision = new Precision(numberOfBits, integerBits);
            FixPointQuantization q = new FixPointQuantization(precision,
                    Overflow.SATURATE, Rounding.NEAREST);
            _value = new FixPoint(value, q);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException(e.getMessage());
View Full Code Here

        if (!_isUnitless()) {
            unitString = " * " + unitsString();
        }

        Precision precision = _value.getPrecision();
        return "fix(" + _value.toString() + "," + precision.getNumberOfBits()
                + "," + precision.getIntegerBitLength() + ")" + unitString;
    }
View Full Code Here

    /** Construct a new fix type, with no integer bits and no
     * fractional bits.  This (rather useless) type represents the
     * bottom of the FixPoint type lattice.
     */
    public FixType() {
        _precision = new Precision(0, 0);
    }
View Full Code Here

     @return A new type, or BaseType.GENERAL, if the operation does
     *  not make sense for the given types.
     */
    public Type add(Type rightArgumentType) {
        if (rightArgumentType instanceof FixType) {
            Precision rPrecision = ((FixType) rightArgumentType).getPrecision();
            Precision newPrecision = FixPoint.addPrecision(rPrecision,
                    _precision);
            FixType returnType = new FixType(newPrecision);
            return returnType;
        } else {
            return TypeLattice.leastUpperBound(this, rightArgumentType);
View Full Code Here

     *  not make sense for the given types.
     */
    public Type divide(Type rightArgumentType) {
        if (rightArgumentType instanceof FixType) {
            if (rightArgumentType instanceof FixType) {
                Precision rPrecision = ((FixType) rightArgumentType)
                        .getPrecision();
                Precision newPrecision = FixPoint.dividePrecision(rPrecision,
                        _precision);
                FixType returnType = new FixType(newPrecision);
                return returnType;
            } else {
                return TypeLattice.leastUpperBound(this, rightArgumentType);
View Full Code Here

     */
    public boolean equals(Object object) {
        if (!(object instanceof FixType)) {
            return false;
        }
        Precision precision = ((FixType) object).getPrecision();
        if (!(precision.equals(_precision))) {
            return false;
        }

        return true;
    }
View Full Code Here

     @return A new type, or BaseType.GENERAL, if the operation does
     *  not make sense for the given types.
     */
    public Type multiply(Type rightArgumentType) {
        if (rightArgumentType instanceof FixType) {
            Precision rPrecision = ((FixType) rightArgumentType).getPrecision();
            Precision newPrecision = FixPoint.multiplyPrecision(rPrecision,
                    _precision);
            FixType returnType = new FixType(newPrecision);
            return returnType;
        } else {
            return TypeLattice.leastUpperBound(this, rightArgumentType);
View Full Code Here

     @return A new type, or BaseType.GENERAL, if the operation does
     *  not make sense for the given types.
     */
    public Type subtract(Type rightArgumentType) {
        if (rightArgumentType instanceof FixType) {
            Precision rPrecision = ((FixType) rightArgumentType).getPrecision();
            Precision newPrecision = FixPoint.subtractPrecision(rPrecision,
                    _precision);
            FixType returnType = new FixType(newPrecision);
            return returnType;
        } else {
            return TypeLattice.leastUpperBound(this, rightArgumentType);
View Full Code Here

        if (!(type instanceof FixType)) {
            throw new IllegalArgumentException("FixType._compare: "
                    + "The argument is not a FixType.");
        }

        Precision precision = ((FixType) type).getPrecision();

        int fractionBits1 = _precision.getFractionBitLength();
        int fractionBits2 = precision.getFractionBitLength();
        int integerBits1 = _precision.getFractionBitLength();
        int integerBits2 = precision.getFractionBitLength();
        boolean signBit1 = _precision.isSigned();
        boolean signBit2 = precision.isSigned();
        int compareBits1, compareBits2;

        if (_precision.equals(precision)) {
            return CPO.SAME;
        } else if (signBit1 == signBit2) {
View Full Code Here

TOP

Related Classes of ptolemy.math.Precision$LengthExponentPrecisionFormat

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.