Package ptolemy.data

Examples of ptolemy.data.MatrixToken


            // Check the argument lengths.
            for (int i = 0; i < argValues.length; i++) {
                if (_reducedArgs[i]) {
                    if (argValues[i] instanceof MatrixToken) {
                        MatrixToken matrixToken = (MatrixToken) argValues[i];

                        if ((xdim != 0)
                                && (ydim != 0)
                                && ((matrixToken.getRowCount() != ydim) || (matrixToken
                                        .getColumnCount() != xdim))) {
                            throw new IllegalActionException("Argument " + i
                                    + " is a reducible matrixToken that "
                                    + "does not have compatible size!");
                        } else {
                            ydim = matrixToken.getRowCount();
                            xdim = matrixToken.getColumnCount();
                        }
                    } else {
                        throw new IllegalActionException("Argument " + i
                                + " is not an instance of " + "MatrixToken!");
                    }
View Full Code Here


        }
        int[] rowsValue = new int[rows.length()];
        for (int i = 0; i < rowsValue.length; i++) {
            rowsValue[i] = ((IntToken) rows.getElement(i)).intValue();
        }
        MatrixToken inputValue = (MatrixToken) input.get(0);
        MatrixToken[][] result = inputValue.split(rowsValue, columnsValue);
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[i].length; j++) {
                output.send(0, result[i][j]);
            }
        }
View Full Code Here

     *  the dot product.
     *  @exception IllegalActionException If the input matrices have
     *  unequal sizes.
     */
    private void _matrixFire() throws IllegalActionException {
        MatrixToken token1 = (MatrixToken) input1.get(0);
        MatrixToken token2 = (MatrixToken) input2.get(0);

        int columnCount1 = token1.getColumnCount();
        int rowCount1 = token1.getRowCount();
        int columnCount2 = token2.getColumnCount();
        int rowCount2 = token2.getRowCount();

        Token element1;
        Token element2;
        Token sum;

        if ((columnCount1 == columnCount2) && (rowCount1 == rowCount2)) {
            sum = token1.getElementAsToken(0, 0).zero();

            for (int i = 0; i < rowCount1; i += 1) {
                for (int j = 0; j < columnCount1; j += 1) {
                    element1 = token1.getElementAsToken(i, j);
                    element2 = token2.getElementAsToken(i, j);
                    sum = sum.add(element1.multiply(element2));
                }
            }

            output.send(0, sum);
View Full Code Here

        if (!input.hasToken(0)) {
            return;
        }

        MatrixToken token = (MatrixToken) input.get(0);
        int actualRowCount = token.getRowCount();
        int actualColumnCount = token.getColumnCount();
        boolean enforce = ((BooleanToken) enforceMatrixSize.getToken())
                .booleanValue();

        if (enforce) {
            int rowsValue = ((IntToken) rows.getToken()).intValue();
            int columnsValue = ((IntToken) columns.getToken()).intValue();

            if ((actualRowCount != rowsValue)
                    || (actualColumnCount != columnsValue)) {
                throw new IllegalActionException(this, "The input matrix size "
                        + actualRowCount + "x" + actualColumnCount
                        + " does not match what the actor requires, "
                        + rowsValue + "x" + columnsValue);
            }
        }

        for (int i = 0; i < actualRowCount; i++) {
            for (int j = 0; j < actualColumnCount; j++) {
                output.send(0, token.getElementAsToken(i, j));
            }
        }
    }
View Full Code Here

        int columnSpanValue = ((IntToken) columnSpan.getToken()).intValue();
        int rowSpanValue = ((IntToken) rowSpan.getToken()).intValue();

        // FIXME: We are not enforcing that the input is a matrix.
        // How to do this?
        MatrixToken inputValue = (MatrixToken) input.get(0);
        output.send(0, inputValue.crop(rowValue, columnValue, rowSpanValue,
                columnSpanValue));
    }
View Full Code Here

TOP

Related Classes of ptolemy.data.MatrixToken

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.