Package ptolemy.math

Examples of ptolemy.math.FixPointQuantization


     *   is invalid.
     */
    public FixToken(double value, Precision precision)
            throws IllegalArgumentException {
        try {
            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


     */
    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

                        .getType()) == CPO.HIGHER)) {

            // The overflow and rounding modes could be anything here,
            // since the above check should ensure that rounding and
            // overflow will never occur.
            return ((FixToken) token).quantize(new FixPointQuantization(
                    getPrecision(), Overflow.GROW, Rounding.HALF_EVEN));
        }

        throw new IllegalActionException(Token.notSupportedConversionMessage(
                token, toString()));
View Full Code Here

        //FIXME: what do we do if input is negative?
        //bits = bits.replace('-', '1');

        FixPoint result = new FixPoint(new BigDecimal(new BigInteger(bits
                .toString(), 2)), new FixPointQuantization(precision, overflow,
                rounding));

        sendOutput(output, 0, new FixToken(result));
    }
View Full Code Here

                        .getName(((Parameter) getAttribute("outputRounding"))
                                .getExpression().toLowerCase());

                FixPoint result = new FixPoint(((ScalarToken) valuesArray
                        .getElement(_currentIndex)).doubleValue(),
                        new FixPointQuantization(precision, overflow, rounding));
                sendOutput(output, 0, new FixToken(result));
                _outputProduced = true;
            }
        }
    }
View Full Code Here

                Rounding rounding = Rounding
                        .getName(((Parameter) getAttribute("outputRounding"))
                                .getExpression().toLowerCase());
                FixPoint result = new FixPoint(intResult.doubleValue(),
                        new FixPointQuantization(precision, overflow, rounding));
                sendOutput(output, 0, new FixToken(result));
            }
        } else {
            output.resend(0);
        }
View Full Code Here

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

        FixPoint result = new FixPoint(((ScalarToken) value.getToken())
                .doubleValue(), new FixPointQuantization(precision, overflow,
                rounding));

        sendOutput(output, 0, new FixToken(result));
    }
View Full Code Here

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

            Quantization quantization = new FixPointQuantization(precision,
                    overflow, rounding);

            token = ((FixToken) token).quantize(quantization);
        }
View Full Code Here

            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"))
                            .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));
        }
    }
View Full Code Here

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

        FixPoint result = new FixPoint(((ScalarToken) initialValue.getToken())
                .doubleValue(), new FixPointQuantization(precision, overflow,
                rounding));
        int latencyValue = ((ScalarToken) latency.getToken()).intValue();
        output.setSize(latencyValue, new FixToken(result));
    }
View Full Code Here

TOP

Related Classes of ptolemy.math.FixPointQuantization

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.