Package ptolemy.data

Examples of ptolemy.data.DoubleMatrixToken


     *   of the input matrix does not match the declared parameter values.
     */
    public final void fire() throws IllegalActionException {
        super.fire();

        DoubleMatrixToken matrix = (DoubleMatrixToken) input.get(0);
        int inputRows = matrix.getRowCount();
        int inputColumns = matrix.getColumnCount();

        // If the director is an SDFDirector, check the dimensions
        // of the matrix.
        Director director = getDirector();

        if (director instanceof SDFDirector) {
            if ((inputRows * inputColumns) != (_rows * _columns)) {
                throw new IllegalActionException(this,
                        "Received a matrix whose dimension does not "
                                + "match the declared dimensions.");
            }
        }

        int totalSize = inputRows * inputColumns;
        DoubleToken[] result = new DoubleToken[totalSize];
        int k = 0;

        for (int i = 0; i < inputRows; i++) {
            for (int j = 0; j < inputColumns; j++) {
                result[k++] = (DoubleToken) matrix.getElementAsToken(i, j);
            }
        }

        output.send(0, result, totalSize);
    }
View Full Code Here


     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute == initialStates) {
            // The initialStates parameter should be a row vector.
            DoubleMatrixToken token = (DoubleMatrixToken) initialStates
                    .getToken();

            if (token == null) {
                return;
            }

            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

        angle.setTypeEquals(BaseType.DOUBLE);
        initialAngle = new Parameter(this, "initialAngle", new DoubleToken(0.0));

        axisDirection = new Parameter(this, "axisDirection",
                new DoubleMatrixToken(new double[][] { { 0.0, 1.0, 0.0 } }));

        pivotLocation = new Parameter(this, "pivotLocation",
                new DoubleMatrixToken(new double[][] { { 0.0, 0.0, 0.0 } }));
    }
View Full Code Here

            if (angle.hasToken(0)) {
                double in = ((DoubleToken) angle.get(0)).doubleValue();
                double originalAngle = ((DoubleToken) initialAngle.getToken())
                        .doubleValue();

                DoubleMatrixToken axis = (DoubleMatrixToken) axisDirection
                        .getToken();

                _xAxis = (float) axis.getElementAt(0, 0);
                _yAxis = (float) axis.getElementAt(0, 1);
                _zAxis = (float) axis.getElementAt(0, 2);

                Quat4d quat = new Quat4d();

                if (_isAccumulating()) {
                    _accumulatedAngle = in + _accumulatedAngle;
View Full Code Here

    /** Setup the initial rotation.
     *  @exception IllegalActionException If the value of some parameters can't
     *   be obtained
     */
    public void initialize() throws IllegalActionException {
        DoubleMatrixToken axis = (DoubleMatrixToken) axisDirection.getToken();

        _xAxis = (float) axis.getElementAt(0, 0);
        _yAxis = (float) axis.getElementAt(0, 1);
        _zAxis = (float) axis.getElementAt(0, 2);

        DoubleMatrixToken pivot = (DoubleMatrixToken) pivotLocation.getToken();

        _baseX = (float) pivot.getElementAt(0, 0);
        _baseY = (float) pivot.getElementAt(0, 1);
        _baseZ = (float) pivot.getElementAt(0, 2);

        double originalAngle = ((DoubleToken) initialAngle.getToken())
                .doubleValue();

        _accumulatedAngle = originalAngle;
View Full Code Here

     @return The location.
     *  @see #setLocation(double [])
     */
    public double[] getLocation() {
        try {
            DoubleMatrixToken token = (DoubleMatrixToken) getToken();
            double[][] value = token.doubleMatrix();
            return value[0];
        } catch (IllegalActionException ex) {
            // Should not occur.
            throw new InternalErrorException(ex);
        }
View Full Code Here

     */
    public void setLocation(double[] location) throws IllegalActionException {
        double[][] value = new double[1][2];
        value[0][0] = location[0];
        value[0][1] = location[1];
        setToken(new DoubleMatrixToken(value, MatrixToken.DO_NOT_COPY));
        propagateValue();
    }
View Full Code Here

                            }
                        }

                        retval = new IntMatrixToken(tmp);
                    } else {
                        retval = new DoubleMatrixToken(a);
                    }
                }
            }
        } else if (maClassStr.equals("logical")) {
            int[][] a = ptmatlabGetLogicalMatrix(ma, nRows, nCols);
View Full Code Here

        eng.setDebugging((byte) 0);

        long[] engineHandle = eng.open();
        eng.evalString(engineHandle, "clear");

        DoubleMatrixToken tx = new DoubleMatrixToken(
                new double[][] { { 1, 2, 3 } });
        System.out.println("\nNote: All data output is via "
                + "Token.toString() on tokens");
        System.out.println("that are put/get from the matlab engineHandle.");
        System.out.println("\nCreate 1x3 double matrix x:");
        eng.put(engineHandle, "x", tx);
        System.out.println("x = " + tx.toString());
        System.out.println("Eval: y = x.*x;");
        eng.evalString(engineHandle, "y = x.*x;");

        DoubleMatrixToken ty = (DoubleMatrixToken) eng.get(engineHandle, "y");
        System.out.println("y = " + ty.toString());

        System.out.println("\nCreate 2x3 double matrix x:");
        tx = new DoubleMatrixToken(new double[][] { { 1, 2, 3 }, { 4, 5, 6 } });
        eng.put(engineHandle, "x", tx);
        System.out.println("x = " + tx.toString());
        System.out.println("Eval: y = x.*x;");
        eng.evalString(engineHandle, "y = x.*x;");
        ty = (DoubleMatrixToken) eng.get(engineHandle, "y");
        System.out.println("y = " + ty.toString());

        System.out.println("\nEval: z = exp(j*pi/2*x);");
        eng.evalString(engineHandle, "z = exp(j*pi/2*x);");

        ComplexMatrixToken tz = (ComplexMatrixToken) eng.get(engineHandle, "z");
View Full Code Here

            }

            runL++;
        }

        output.broadcast(new DoubleMatrixToken(image));
    }
View Full Code Here

TOP

Related Classes of ptolemy.data.DoubleMatrixToken

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.