Examples of DoubleMatrixToken


Examples of ptolemy.data.DoubleMatrixToken

        double[][] zero =  {
             {
                0.0
            }
        };
        $ASSIGN$_x(new DoubleMatrixToken(zero));
        $ASSIGN$_initialStateChanged(true);
        _attachText("_iconDescription", "<svg>\n" + "<rect x=\"-75\" y=\"-30\" "+"width=\"150\" height=\"60\" "+"style=\"fill:white\"/>\n"+"<text x=\"-70\" y=\"-10\" "+"style=\"font-size:14\">\n"+"x(k+1) = Ax(k) + Bu(k) "+"</text>\n"+"<text x=\"-70\" y=\"10\" "+"style=\"font-size:14\">\n"+"    y(k) = Cx(k) + Du(k)"+"</text>\n"+"</svg>\n");
    }
View Full Code Here

Examples of ptolemy.data.DoubleMatrixToken

     * @exception IllegalActionException If the numerator and the
     * denominator matrix is not a row vector.
     */
    public void attributeChanged(Attribute attribute) throws IllegalActionException  {
        if (attribute == A) {
            DoubleMatrixToken token = (DoubleMatrixToken)A.getToken();
            if ((token.getRowCount() == 0) || (token.getColumnCount() == 0)||(token.getRowCount() != token.getColumnCount())) {
                throw new IllegalActionException(this, "The A matrix must be a nonempty square matrix.");
            }
        } else if (attribute == B) {
            DoubleMatrixToken token = (DoubleMatrixToken)B.getToken();
            if ((token.getRowCount() == 0) || (token.getColumnCount() == 0)) {
                throw new IllegalActionException(this, "The B matrix must be a nonempty matrix.");
            }
        } else if (attribute == C) {
            DoubleMatrixToken token = (DoubleMatrixToken)C.getToken();
            if ((token.getRowCount() == 0) || (token.getColumnCount() == 0)) {
                throw new IllegalActionException(this, "The C matrix must be a nonempty matrix.");
            }
        } else if (attribute == D) {
            DoubleMatrixToken token = (DoubleMatrixToken)D.getToken();
            if ((token.getRowCount() == 0) || (token.getColumnCount() == 0)) {
                throw new IllegalActionException(this, "The D matrix must be a nonempty matrix.");
            }
        } else if (attribute == initialStates) {
            DoubleMatrixToken token = (DoubleMatrixToken)initialStates.getToken();
            if ((token.getColumnCount() != 1) || (token.getRowCount() < 1)) {
                throw new IllegalActionException(this, "The initialStates must be a column vector.");
            }
            $ASSIGN$_initialStateChanged(true);
        } else {
            super.attributeChanged(attribute);
View Full Code Here

Examples of ptolemy.data.DoubleMatrixToken

     * @exception IllegalActionException If the dimensions do not
     * match.
     */
    public void preinitialize() throws IllegalActionException  {
        super.preinitialize();
        DoubleMatrixToken a = (DoubleMatrixToken)A.getToken();
        int n = a.getRowCount();
        DoubleMatrixToken b = (DoubleMatrixToken)B.getToken();
        if (b.getRowCount() != n) {
            throw new IllegalActionException(this, "The number of rows of the B matrix should equal to " + "the number of rows of the A matrix.");
        }
        if (n == 1) {
            $ASSIGN$_singleState(true);
            state.setTypeEquals(BaseType.DOUBLE);
        } else {
            $ASSIGN$_singleState(false);
            state.setTypeEquals(BaseType.DOUBLE_MATRIX);
        }
        int m = b.getColumnCount();
        if (m == 1) {
            input.setTypeEquals(BaseType.DOUBLE);
        } else {
            input.setTypeEquals(BaseType.DOUBLE_MATRIX);
        }
        DoubleMatrixToken c = (DoubleMatrixToken)C.getToken();
        if (c.getColumnCount() != n) {
            throw new IllegalActionException(this, "The number of columns of the C matrix should equal to " + "the number of rows of the A matrix.");
        }
        int r = c.getRowCount();
        if (r == 1) {
            $ASSIGN$_singleOutput(true);
            output.setTypeEquals(BaseType.DOUBLE);
        } else {
            $ASSIGN$_singleOutput(false);
            output.setTypeEquals(BaseType.DOUBLE_MATRIX);
        }
        DoubleMatrixToken d = (DoubleMatrixToken)D.getToken();
        if (c.getRowCount() != d.getRowCount()) {
            throw new IllegalActionException(this, "The number of rows of the D matrix should equal to " + "the number of rows of the C matrix.");
        }
        DoubleMatrixToken x0 = (DoubleMatrixToken)initialStates.getToken();
        if (x0.getRowCount() != n) {
            throw new IllegalActionException(this, "The number of initial states should equal to " + "the number of columns of the A matrix.");
        }
        $ASSIGN$_initialStateChanged(true);
    }
View Full Code Here

Examples of ptolemy.data.DoubleMatrixToken

    public JAIAffineTransform(CompositeEntity container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);

        affineMatrix = new Parameter(this, "affineMatrix",
                new DoubleMatrixToken(_initialMatrix));

        interpolationType = new StringAttribute(this, "interpolationType");
        interpolationType.setExpression("bilinear");
        _interpolationType = _BILINEAR;
View Full Code Here

Examples of ptolemy.data.DoubleMatrixToken

                        "Unrecognized interpolation type: " + typeName);
            }
        } else if (attribute == subSampleBits) {
            _subSampleBits = ((IntToken) subSampleBits.getToken()).intValue();
        } else if (attribute == affineMatrix) {
            DoubleMatrixToken affineMatrixToken = (DoubleMatrixToken) affineMatrix
                    .getToken();

            if ((affineMatrixToken.getColumnCount() == 3)
                    && (affineMatrixToken.getRowCount() == 2)) {
                _matrixValue = affineMatrixToken.doubleMatrix();
                _affineTransform = new AffineTransform(_matrixValue[0][0],
                        _matrixValue[1][0], _matrixValue[0][1],
                        _matrixValue[1][1], _matrixValue[0][2],
                        _matrixValue[1][2]);
            } else {
View Full Code Here

Examples of ptolemy.data.DoubleMatrixToken

     *  or writing a token.
     */
    public void fire() throws IllegalActionException {
        super.fire();

        DoubleMatrixToken doubleMatrixToken = (DoubleMatrixToken) input.get(0);
        double[][] data = doubleMatrixToken.doubleMatrix();
        int width = doubleMatrixToken.getRowCount();
        int height = doubleMatrixToken.getColumnCount();

        for (int i = 0; i < width; i++) {
            for (int j = 0; j < height; j++) {
                double value = Math.random();

                if (value < _probability) {
                    if (value < (_probability / 2)) {
                        data[i][j] = 0.0F;
                    } else {
                        data[i][j] = 255.0F;
                    }
                }
            }
        }

        output.send(0, new DoubleMatrixToken(data));
    }
View Full Code Here

Examples of ptolemy.data.DoubleMatrixToken

        _requestInitialization = true;

        double[][] one = { { 1.0 } };
        double[][] zero = { { 0.0 } };

        A = new Parameter(this, "A", new DoubleMatrixToken(one));
        A.setTypeEquals(BaseType.DOUBLE_MATRIX);

        B = new Parameter(this, "B", new DoubleMatrixToken(one));
        B.setTypeEquals(BaseType.DOUBLE_MATRIX);

        C = new Parameter(this, "C", new DoubleMatrixToken(one));
        C.setTypeEquals(BaseType.DOUBLE_MATRIX);

        D = new Parameter(this, "D", new DoubleMatrixToken(zero));
        D.setTypeEquals(BaseType.DOUBLE_MATRIX);

        initialStates = new Parameter(this, "initialStates",
                new DoubleMatrixToken(zero));
        initialStates.setTypeEquals(BaseType.DOUBLE_MATRIX);
        setClassName("ptolemy.domains.ct.lib.LinearStateSpace");

        // icon
        _attachText("_iconDescription", "<svg>\n"
View Full Code Here

Examples of ptolemy.data.DoubleMatrixToken

     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute == A) {
            // Check that it is a square matrix.
            DoubleMatrixToken token = (DoubleMatrixToken) A.getToken();

            if ((token.getRowCount() == 0) || (token.getColumnCount() == 0)
                    || (token.getRowCount() != token.getColumnCount())) {
                throw new IllegalActionException(this,
                        "The A matrix must be a nonempty square matrix.");
            }

            _requestInitialization = true;
        } else if (attribute == B) {
            // Check that B is a matrix.
            DoubleMatrixToken token = (DoubleMatrixToken) B.getToken();

            if ((token.getRowCount() == 0) || (token.getColumnCount() == 0)) {
                throw new IllegalActionException(this,
                        "The B matrix must be a nonempty matrix.");
            }

            _requestInitialization = true;
        } else if (attribute == C) {
            // Check that C is a matrix.
            DoubleMatrixToken token = (DoubleMatrixToken) C.getToken();

            if ((token.getRowCount() == 0) || (token.getColumnCount() == 0)) {
                throw new IllegalActionException(this,
                        "The C matrix must be a nonempty matrix.");
            }

            _requestInitialization = true;
        } else if (attribute == D) {
            DoubleMatrixToken token = (DoubleMatrixToken) D.getToken();

            if ((token.getRowCount() == 0) || (token.getColumnCount() == 0)) {
                throw new IllegalActionException(this,
                        "The D matrix must be a nonempty matrix.");
            }

            _requestInitialization = true;
        } else if (attribute == initialStates) {
            // The initialStates parameter should be a row vector.
            DoubleMatrixToken token = (DoubleMatrixToken) initialStates
                    .getToken();

            if ((token.getRowCount() != 1) || (token.getColumnCount() < 1)) {
                throw new IllegalActionException(this,
                        "The initialStates must be a row vector.");
            }

            // Changes of the initialStates parameter are ignored after
View Full Code Here

Examples of ptolemy.data.DoubleMatrixToken

    public void preinitialize() throws IllegalActionException {
        // Check parameters.
        _checkParameters();

        // We work at the token level with out copying the matrices.
        DoubleMatrixToken a = (DoubleMatrixToken) A.getToken();
        int n = a.getRowCount();
        DoubleMatrixToken b = (DoubleMatrixToken) B.getToken();
        int m = b.getColumnCount();
        DoubleMatrixToken c = (DoubleMatrixToken) C.getToken();
        int r = c.getRowCount();

        /* DoubleMatrixToken d = (DoubleMatrixToken)*/D.getToken();

        /* DoubleMatrixToken x0 = (DoubleMatrixToken)*/initialStates
                .getToken();
View Full Code Here

Examples of ptolemy.data.DoubleMatrixToken

    /** Check the dimensions of all parameters and ports.
     *  @exception IllegalActionException If the dimensions are illegal.
     */
    private void _checkParameters() throws IllegalActionException {
        DoubleMatrixToken a = (DoubleMatrixToken) A.getToken();
        int n = a.getRowCount();
        DoubleMatrixToken b = (DoubleMatrixToken) B.getToken();

        if (b.getRowCount() != n) {
            throw new IllegalActionException(this,
                    "The number of rows of the B matrix (" + b.getRowCount()
                            + ") should be equal to "
                            + "the number of rows of the A matrix (" + n + ").");
        }

        int m = b.getColumnCount();

        if (input.getWidth() != m) {
            throw new IllegalActionException(this,
                    "The number of columns of the B matrix ("
                            + b.getColumnCount() + ") should be equal to "
                            + "the width of the input port ("
                            + input.getWidth() + ").");
        }

        DoubleMatrixToken c = (DoubleMatrixToken) C.getToken();

        if (c.getColumnCount() != n) {
            throw new IllegalActionException(this,
                    "The number of columns of the C matrix ("
                            + c.getColumnCount() + ") should be equal to "
                            + "the number of rows of the A matrix (" + n + ").");
        }

        // The output width is not checked, since we may only want
        // to use some of the outputs
        DoubleMatrixToken d = (DoubleMatrixToken) D.getToken();

        if (c.getRowCount() != d.getRowCount()) {
            throw new IllegalActionException(this,
                    "The number of rows of the D matrix (" + d.getRowCount()
                            + ") should be equal to "
                            + "the number of rows of the C matrix ("
                            + c.getRowCount() + ").");
        }

        if (d.getColumnCount() != input.getWidth()) {
            throw new IllegalActionException(this,
                    "The number of columns of the D matrix ("
                            + d.getColumnCount() + ") should be equal to "
                            + "the width of the input port ("
                            + input.getWidth() + ").");
        }

        DoubleMatrixToken x0 = (DoubleMatrixToken) initialStates.getToken();

        if (x0.getColumnCount() != n) {
            throw new IllegalActionException(this,
                    "The number of initial states (" + x0.getColumnCount()
                            + ") should equal to "
                            + "the number of columns of the A matrix (" + n
                            + ").");
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.