Examples of ArrayToken


Examples of ptolemy.data.ArrayToken

            $ASSIGN$_estimatedErrorPowerCache(i, 0.0);
            if (i < _order) {
                $ASSIGN$_reflectionCoefficientsCache(i, 0.0);
            }
        }
        ArrayToken value = (ArrayToken)reflectionCoefficients.getToken();
        for (int i = 0; i < _order; i++) {
            _reflectionCoefficients[i] = ((DoubleToken)value.getElement(i)).doubleValue();
        }
    }
View Full Code Here

Examples of ptolemy.data.ArrayToken

            }
            outputArray[i - 1] = new DoubleToken(newCoefficient);
            $ASSIGN$_reflectionCoefficientsCache(i - 1, newCoefficient);
            $ASSIGN$_estimatedErrorPowerCache(i, newError);
        }
        adaptedReflectionCoefficients.send(0, new ArrayToken(BaseType.DOUBLE, outputArray));
    }
View Full Code Here

Examples of ptolemy.data.ArrayToken

        }
        Token[] values = new Token[_bins.length];
        for (int i = 0; i < _bins.length; i++) {
            values[i] = new IntToken(_bins[i]);
        }
        output.send(0, new ArrayToken(BaseType.INT, values));
    }
View Full Code Here

Examples of ptolemy.data.ArrayToken

            double mean = ((DoubleToken)meanTime.getToken()).doubleValue();
            if (mean <= 0.0) {
                throw new IllegalActionException(this, "meanTime is required to be positive.  meanTime given: " + mean);
            }
        } else if (attribute == values) {
            ArrayToken val = (ArrayToken)(values.getToken());
            $ASSIGN$_length(val.length());
        } else {
            super.attributeChanged(attribute);
        }
    }
View Full Code Here

Examples of ptolemy.data.ArrayToken

        }
        return super.postfire();
    }

    private Token _getValue(int index) throws IllegalActionException  {
        ArrayToken val = (ArrayToken)(values.getToken());
        if ((val == null) || (index >= _length)) {
            throw new IllegalActionException(this, "Index out of range of the values parameter.");
        }
        return val.getElement(index);
    }
View Full Code Here

Examples of ptolemy.data.ArrayToken

    public void fire() throws IllegalActionException  {
        super.fire();
        startIndex.update();
        endIndex.update();
        if (input.hasToken(0)) {
            ArrayToken inputArray = (ArrayToken)input.get(0);
            Type inputElementType = inputArray.getElementType();
            int inputSize = inputArray.length();
            if (inputSize == 0) {
                peakValues.send(0, inputArray);
                peakIndices.send(0, inputArray);
                return;
            }
            int start = ((IntToken)startIndex.getToken()).intValue();
            int end = ((IntToken)endIndex.getToken()).intValue();
            int maxPeaks = ((IntToken)maximumNumberOfPeaks.getToken()).intValue();
            if (end >= inputSize) {
                end = inputSize - 1;
            }
            if (start >= inputSize) {
                start = inputSize - 1;
            }
            if (end < 0) {
                end = 0;
            }
            if (start < 0) {
                start = 0;
            }
            int increment = 1;
            if (end < start) {
                increment = -1;
            }
            boolean searchValley = false;
            boolean searchPeak = true;
            int localMaxIndex = start;
            double localMax = ((DoubleToken)inputArray.getElement(start)).doubleValue();
            double localMin = localMax;
            double dipValue = ((DoubleToken)dip.getToken()).doubleValue();
            double squelchValue = ((DoubleToken)squelch.getToken()).doubleValue();
            double dipThreshold = dipValue;
            double riseThreshold = dipValue;
            String scaleValue = scale.stringValue();
            int scaleIndicator = _ABSOLUTE;
            if (!scaleValue.equals("absolute")) {
                double maxValue = localMax;
                for (int i = 0; i <= (inputSize - 1); i = i + increment) {
                    double indata = ((DoubleToken)inputArray.getElement(i)).doubleValue();
                    if (indata > maxValue) {
                        maxValue = indata;
                    }
                }
                if (scaleValue.equals("relative amplitude decibels")) {
                    scaleIndicator = _RELATIVE_DB;
                    dipThreshold = localMax * Math.pow(10.0, (-dipValue / 20));
                    riseThreshold = localMin * Math.pow(10.0, (dipValue / 20));
                    squelchValue = maxValue * Math.pow(10.0, (-squelchValue / 20));
                } else if (scaleValue.equals("relative power decibels")) {
                    scaleIndicator = _RELATIVE_DB_POWER;
                    dipThreshold = localMax * Math.pow(10.0, (-dipValue / 10));
                    riseThreshold = localMin * Math.pow(10.0, (dipValue / 10));
                    squelchValue = maxValue * Math.pow(10.0, (-squelchValue / 10));
                } else if (scaleValue.equals("relative linear")) {
                    scaleIndicator = _RELATIVE_LINEAR;
                    dipThreshold = localMax - dipValue;
                    riseThreshold = localMin + dipValue;
                    squelchValue = maxValue - squelchValue;
                }
            }
            ArrayList resultIndices = new ArrayList();
            ArrayList resultPeaks = new ArrayList();
            for (int i = start; i <= end; i = i + increment) {
                double indata = ((DoubleToken)inputArray.getElement(i)).doubleValue();
                if (_debugging) {
                    _debug("-- Checking input with value " + indata+" at index "+i);
                }
                if (searchValley) {
                    if (indata < localMin) {
                        localMin = indata;
                        switch (scaleIndicator) {
                            case _RELATIVE_DB:
                                riseThreshold = localMin * Math.pow(10.0, (dipValue / 20));
                                break;
                            case _RELATIVE_DB_POWER:
                                riseThreshold = localMin * Math.pow(10.0, (dipValue / 10));
                                break;
                            case _RELATIVE_LINEAR:
                                riseThreshold = localMin + dipValue;
                                break;
                        }
                    }
                    if (_debugging) {
                        _debug("-- Looking for a value above " + riseThreshold);
                    }
                    if ((indata > riseThreshold) && (indata > squelchValue)) {
                        localMax = indata;
                        switch (scaleIndicator) {
                            case _RELATIVE_DB:
                                dipThreshold = localMax * Math.pow(10.0, (-dipValue / 20));
                                break;
                            case _RELATIVE_DB_POWER:
                                dipThreshold = localMax * Math.pow(10.0, (-dipValue / 10));
                                break;
                            case _RELATIVE_LINEAR:
                                dipThreshold = localMax - dipValue;
                                break;
                        }
                        localMaxIndex = i;
                        searchValley = false;
                        searchPeak = true;
                    }
                } else if (searchPeak) {
                    if ((indata > localMax) && (indata > squelchValue)) {
                        localMax = indata;
                        switch (scaleIndicator) {
                            case _RELATIVE_DB:
                                dipThreshold = localMax * Math.pow(10.0, (-dipValue / 20));
                                break;
                            case _RELATIVE_DB_POWER:
                                dipThreshold = localMax * Math.pow(10.0, (-dipValue / 10));
                                break;
                            case _RELATIVE_LINEAR:
                                dipThreshold = localMax - dipValue;
                                break;
                        }
                        localMaxIndex = i;
                    }
                    if (_debugging) {
                        _debug("-- Looking for a value below " + dipThreshold);
                    }
                    if ((indata < dipThreshold) && (localMax > squelchValue)) {
                        if (_debugging) {
                            _debug("** Found a peak with value " + localMax+" at index "+localMaxIndex);
                        }
                        resultIndices.add(new IntToken(localMaxIndex));
                        resultPeaks.add(new DoubleToken(localMax));
                        if (resultPeaks.size() > maxPeaks) {
                            break;
                        }
                        localMin = indata;
                        switch (scaleIndicator) {
                            case _RELATIVE_DB:
                                riseThreshold = localMin * Math.pow(10.0, (dipValue / 20));
                                break;
                            case _RELATIVE_DB_POWER:
                                riseThreshold = localMin * Math.pow(10.0, (dipValue / 10));
                                break;
                            case _RELATIVE_LINEAR:
                                riseThreshold = localMin + dipValue;
                                break;
                        }
                        searchValley = true;
                        searchPeak = false;
                    }
                }
            }
            if (resultPeaks.isEmpty()) {
                resultPeaks.add(inputArray.getElement(start));
                resultIndices.add(startIndex.getToken());
            }
            Token[] resultPeaksArray = (Token[])resultPeaks.toArray(new Token[resultPeaks.size()]);
            Token[] resultIndicesArray = (Token[])resultIndices.toArray(new Token[resultIndices.size()]);
            peakValues.send(0, new ArrayToken(inputElementType, resultPeaksArray));
            peakIndices.send(0, new ArrayToken(BaseType.INT, resultIndicesArray));
        }
    }
View Full Code Here

Examples of ptolemy.data.ArrayToken

     * negative; or the argument is the <i>order</i> parameter and the order
     * is not supported by the Interpolation class.
     */
    public void attributeChanged(Attribute attribute) throws IllegalActionException  {
        if (attribute == values) {
            ArrayToken valuesValue = (ArrayToken)values.getToken();
            $ASSIGN$_values(new double[valuesValue.length()]);
            for (int i = 0; i < valuesValue.length(); i++) {
                $ASSIGN$_values(i, ((DoubleToken)valuesValue.getElement(i)).doubleValue());
            }
            _interpolation.setValues($BACKUP$_values());
        } else if (attribute == indexes) {
            ArrayToken indexesValue = (ArrayToken)indexes.getToken();
            $ASSIGN$_indexes(new int[indexesValue.length()]);
            int previous = 0;
            for (int i = 0; i < indexesValue.length(); i++) {
                $ASSIGN$_indexes(i, ((IntToken)indexesValue.getElement(i)).intValue());
                if (_indexes[i] < previous) {
                    throw new IllegalActionException(this, "Value of indexes is not nondecreasing " + "and nonnegative.");
                }
                previous = _indexes[i];
            }
View Full Code Here

Examples of ptolemy.data.ArrayToken

            }

            int i = 0;
            int j = 0;
            LinkedList list = new LinkedList();
            ArrayToken array = (ArrayToken) inputArray.get(0);

            while ((i < _outputLength) && (j < array.length())) {
                Token t = array.getElement(j);
                _updateParameter(t);

                if (_debugging) {
                    _debug("** Executing filter model.");
                }

                try {
                    _manager.execute();
                } catch (KernelException ex) {
                    throw new IllegalActionException(this, ex,
                            "Execution failed.");
                }

                if (_getResult()) {
                    i++;
                    list.add(t);
                }

                j++;
            }

            Token[] result = new Token[list.size()];

            for (i = 0; i < list.size(); i++) {
                result[i] = (Token) list.get(i);
            }

            outputArray.send(0, new ArrayToken(array.getElementType(), result));
        }
    }
View Full Code Here

Examples of ptolemy.data.ArrayToken

     *   nondecreasing and nonnegative, or it is not a row vector.
     */
    public void attributeChanged(Attribute attribute)
            throws IllegalActionException {
        if (attribute == offsets) {
            ArrayToken offsetsValue = (ArrayToken) offsets.getToken();
            _offsets = new double[offsetsValue.length()];

            double previous = 0.0;

            for (int i = 0; i < offsetsValue.length(); i++) {
                _offsets[i] = ((DoubleToken) offsetsValue.getElement(i))
                        .doubleValue();

                // Check nondecreasing property.
                if (_offsets[i] < previous) {
                    throw new IllegalActionException(this,
View Full Code Here

Examples of ptolemy.data.ArrayToken

                for (int j = 0; j < bytesAvailable; j++) {
                    dataTokens[j] = new UnsignedByteToken(dataBytes[j]);
                }

                _outputToken = new ArrayToken(BaseType.UNSIGNED_BYTE,
                        dataTokens);
            }

            _syncFireAndThread.notifyAll();
        } // sync
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.