Hi Adriana,
Thanks for the bug report.  I updated Minimum and Maximum
so that when they receive Complex inputs, they store the input
and use the absolute value of the input for comparison purposes.
The stored input is then used for output later.

    public void fire() throws IllegalActionException {
        super.fire();
        ScalarToken result = null;
        ScalarToken resultMagnitude = null;
        ScalarToken inMagnitude = null;
        int channelNum = -1;

        for (int i = 0; i < input.getWidth(); i++) {
            if (input.hasToken(i)) {
                ScalarToken in = (ScalarToken) input.get(i);

                if (in.getType() == BaseType.COMPLEX) {
                    // If we have a complex, we use the absolute value
                    // for comparison, but save output the initial input
                    // for output at the end.
                    inMagnitude = in.absolute();
                } else {
                    inMagnitude = in;
                }
                       
                if (result == null) {
                    result = in;
                    resultMagnitude = inMagnitude;
                    channelNum = i;
                } else {
                    if 
(inMagnitude.isGreaterThan(resultMagnitude).booleanValue()
                            == true) {
                        result = in;
                        resultMagnitude = inMagnitude;
                        channelNum = i;
                    }
                }
            }
        }

        if (result != null) {
            maximumValue.broadcast(result);
            channelNumber.broadcast(new IntToken(channelNum));
        }
    }
}

_Christopher

--------

    Hi all,
    I have some problem with the Maximum and Minimum actors. Infact, when
    these actors receive a ComplexToken on the input port, a warning occurs.
    Actors documentation says: "For ComplexToken, the output is
    the one with the maximum magnitude".
    
    This problem will be resolved replacing this code:
    
      public void fire() throws IllegalActionException {
             ScalarToken result = null;
             int channelNum = -1;
    
             for (int i = 0; i < input.getWidth(); i++) {
                 if (input.hasToken(i)) {
                     ScalarToken in = (ScalarToken) input.get(i);
    
                     if (result == null) {
                         result = in;
                         channelNum = i;
                     } else {
                         if (result.isLessThan(in).booleanValue() == true) {
                             result = in;
                             channelNum = i;
                         }
                     }
                 }
             }
    
             if (result != null) {
                 maximumValue.broadcast(result);
                 channelNumber.broadcast(new IntToken(channelNum));
             }
         }
    with the following code:
    
    public void fire() throws IllegalActionException {
            ScalarToken result = null;
            int channelNum = -1;
    
            for (int i = 0; i < input.getWidth(); i++) {
                if (input.hasToken(i)) {
                    ScalarToken in = (ScalarToken) input.get(i);
    
                    if (in.getType() == BaseType.COMPLEX) {
                        in = in.absolute();
                    }
                                   if (result == null) {
                        result = in;
                        channelNum = i;
                    } else {
                        if (result.isLessThan(in).booleanValue() == true) {
                            result = in;
                            channelNum = i;
                        }
                    }
                }
            }
    
            if (result != null) {
                maximumValue.broadcast(result);
                channelNumber.broadcast(new IntToken(channelNum));
            }
        }
    
    Adriana
    
    
    ---------------------------------------------------------------------------
   -
    Posted to the ptolemy-hackers mailing list.  Please send administrative
    mail for this list to: [EMAIL PROTECTED]
--------

----------------------------------------------------------------------------
Posted to the ptolemy-hackers mailing list.  Please send administrative
mail for this list to: [EMAIL PROTECTED]

Reply via email to