Package ptolemy.math

Examples of ptolemy.math.FixPoint


    /** Return the value in the token as a fixpoint.
     *  @return The value contained in this token as a fixpoint.
     */
    public FixPoint fixValue() {
        return new FixPoint(_value);
    }
View Full Code Here


     *  token.
     *  @return A new FixMatrixToken containing the additive identity.
     */
    public Token zero() {
        FixPoint[][] result = new FixPoint[_rowCount][_columnCount];
        FixPoint zero = Quantizer.round(0.0, _precision);

        for (int i = 0; i < _rowCount; i++) {
            for (int j = 0; j < _columnCount; j++) {
                result[i][j] = zero;
            }
View Full Code Here

     *  supported by the derived class.
     *  @return A new Token containing the result.
     */
    protected MatrixToken _addElement(Token rightArgument)
            throws IllegalActionException {
        FixPoint scalar;
        if (rightArgument instanceof FixMatrixToken) {
            if (((FixMatrixToken) rightArgument).getRowCount() != 1
                    || ((FixMatrixToken) rightArgument).getColumnCount() != 1) {
                // Throw an exception.
                return super._moduloElement(rightArgument);
View Full Code Here

        FixPoint[][] result = new FixPoint[_rowCount][convertedArgument._columnCount];

        for (int i = 0; i < _rowCount; i++) {
            for (int j = 0; j < convertedArgument._columnCount; j++) {
                FixPoint sum = _value[i][0]
                        .multiply(convertedArgument._value[0][j]);

                for (int k = 1; k < _columnCount; k++) {
                    sum = sum.add(_value[i][k]
                            .multiply(convertedArgument._value[k][j]));
                }

                result[i][j] = sum;
            }
View Full Code Here

     *  supported by the derived class.
     *  @return A new Token containing the result.
     */
    protected MatrixToken _multiplyElement(Token rightArgument)
            throws IllegalActionException {
        FixPoint scalar;
        if (rightArgument instanceof FixMatrixToken) {
            if (((FixMatrixToken) rightArgument).getRowCount() != 1
                    || ((FixMatrixToken) rightArgument).getColumnCount() != 1) {
                // Throw an exception.
                return super._moduloElement(rightArgument);
View Full Code Here

     *  supported by the derived class.
     *  @return A new Token containing the result.
     */
    protected MatrixToken _subtractElement(Token rightArgument)
            throws IllegalActionException {
        FixPoint scalar;
        if (rightArgument instanceof FixMatrixToken) {
            if (((FixMatrixToken) rightArgument).getRowCount() != 1
                    || ((FixMatrixToken) rightArgument).getColumnCount() != 1) {
                // Throw an exception.
                return super._moduloElement(rightArgument);
View Full Code Here

     *  supported by the derived class.
     *  @return A new Token containing the result.
     */
    protected MatrixToken _subtractElementReverse(Token rightArgument)
            throws IllegalActionException {
        FixPoint scalar;
        if (rightArgument instanceof FixMatrixToken) {
            if (((FixMatrixToken) rightArgument).getRowCount() != 1
                    || ((FixMatrixToken) rightArgument).getColumnCount() != 1) {
                // Throw an exception.
                return super._moduloElement(rightArgument);
            }
            scalar = ((FixMatrixToken) rightArgument).getElementAt(0, 0);
        } else {
            scalar = ((FixToken) rightArgument).fixValue();
        }
        FixPoint[][] result = fixMatrix();

        for (int i = 0; i < _rowCount; i++) {
            for (int j = 0; j < _columnCount; j++) {
                result[i][j] = scalar.subtract(result[i][j]);
            }
        }

        return new FixMatrixToken(result);
    }
View Full Code Here

     *  This method calls the {@link ptolemy.math.FixPoint#FixPoint(int)}
     *  constructor, so the precision and quantization are the what ever
     *  is defined for that constructor
     */
    public FixToken() {
        _value = new FixPoint(0);
    }
View Full Code Here

    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

            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

TOP

Related Classes of ptolemy.math.FixPoint

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.