Hi Frank,

The CVS version of Ptolemy II includes an ArraySum actor 
that was written by Edward A. Lee and Christine Avanessians.

To get access to the CVS version, see
http://chess.eecs.berkele.edu/ptexternal.

_Christopher


"=?KOI8-R?B?8MXU0s/XIOHMxcvTwc7E0g==?=" <[EMAIL PROTECTED]> writes:
--------

    Hello,
    
    I think you should Expression actor. There is "sum" function for
    arrays in Ptolemy II expression  language:
    
    $PTII$/doc/expressionsa12.html
    
    sum  {type} or [type]->type
    
    Sum the elements of the specified array or matrix. This throws an
    exception if the elements do not support addition or if the array is
    empty (an empty matrix will return zero).
    
    IMHO, It is more convinient to implement workflow like yours using Expressi
   on.
    
    Alexander Petrov
--------

> From: Frank Steinmann <[EMAIL PROTECTED]>
> To: Ptolemy-Hackers Mailinglist <ptolemy-hackers@bennett.EECS.Berkeley.EDU>
> Subject: Loop / building a sum
> Date: Wed, 24 Oct 2007 10:38:18 +0200
> 
> Hi,
> 
> I'm designing a CompositeActor which has to build a sum from the values 
> of an array. My plan was to use a Ramp to fetch the values one after 
> another and put them into an accumulator. My problem now is that I only 
> want the final sum, not all the interim results. The final sum has to be 
> the output of the CompisiteActor.
> 
> I tried the following: I set the vectorizationFactor of the SDF Director 
> to the size of the array. Because I want only the last output token of 
> the Accumulator I put a Boolean Switch between the Accumulator and the 
> output port of the CompositeActor to send all interim result to nowhere 
> and only the last result to the output port. And I set the 
> _tokenProductionRate of the output port to 1. It seems to work, because 
> I get one token and it has the right value but I also get an exception 
> saying: "Port should produce 1 token, but there where only 0 token 
> available".
> 
> So this might not be the right way to do it. Hence my question is: How 
> to model the following code segment in a workflow:
> 
> double sum = 0;
> for (int i=0; i<size; i++)
> {
>       sum += getValue(i);
> }
> return sum;
> 
> 
> Regards,
> Frank
> 
> -- 
> Dipl.-Inf. Frank Steinmann
> Knowledge Management Department
> DFKI GmbH
> 
> Tel.:    +49 (0)631 20575 - 114
> Sekr.:   +49 (0)631 20575 - 101
> Fax:     +49 (0)631 20575 - 103
> E-Mail: [EMAIL PROTECTED]
> -----------------------------------------------------------
> Deutsches Forschungszentrum für Künstliche Intelligenz GmbH
> Trippstadter Straße 122, D-67663 Kaiserslautern, Germany
> 
> Geschäftsführung:
> Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster (Vorsitzender)
> Dr. Walter Olthoff
> 
> Vorsitzender des Aufsichtsrats:
> Prof. Dr. h.c. Hans A. Aukes
> 
> Amtsgericht Kaiserslautern, HRB 2313
> -----------------------------------------------------------
> 
> ----------------------------------------------------------------------------
> 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