[kepler-dev] Re: SequenceToArray in PN

Edward A. Lee eal at eecs.berkeley.edu
Tue Dec 14 21:42:50 PST 2004

Thanks Neil for tracking this down!
Xiaowen's fix works... However, I think it would be better to fix
this deeper in the actor package.  I believe it was a "premature
optimization" for get(channel, arrayLength) to be allowed to return
an array longer than the requested array. We have no evidence that
this enhances performance measurably (and I seriously doubt it does).
So rather than fixing the one actor that fell victim to exercising
this "feature," I'm checking in a change to remove the "feature."
Now, get(channel, arrayLength) will return an array of length


At 11:20 AM 12/14/2004 -0800, xiaowen wrote:
>Ahh!  You're right--good catch!
>So if I made the following change to SequenceToArray, then it works:
>$ cvs diff ptolemy/domains/sdf/lib/SequenceToArray.java
>Index: ptolemy/domains/sdf/lib/SequenceToArray.java
>RCS file:
>retrieving revision 1.47
>diff -r1.47 SequenceToArray.java
><         Token[] valueArray = input.get(0, length);
> >
> >         Token[] valueArray = new Token[length];
> >         System.arraycopy(input.get(0, length), 0, valueArray,
>If this looks OK, will someone from Ptolemy please commit such a change
>to CVS, so that it will make it into the next release?
>On 13.12.2004, at 22:44, Neil E. Turner wrote:
>>I found this in the JavaDocs for IOPort.get(int channelIndex, int
>>"Get an array of tokens from the specified channel. The parameter
>>channelIndex specifies the channel and the parameter vectorLength
>>the number of valid tokens to get in the returned array. The length of
>>returned array can be greater than the specified vector length, in
>>case, only the first vectorLength elements are guaranteed to be valid."
>>If you "look inside" the SequenceToArray actor you will see the Java
>>go to the fire() method.  You will see in the code
>>         Token[] valueArray = input.get(0, length);
>>I put a print statement to see the length of 'valueArray'.  It indeed
>>longer than the PortParameter 'arrayLength'.
>>----- Original Message -----
>>From: "xiaowen" <xin2 at llnl.gov>
>>To: <ptolemy-hackers at eecs.berkeley.edu>
>>Cc: "xiaowen Xin" <xin2 at llnl.gov>; "Kepler-Dev"
>><kepler-dev at ecoinformatics.org>
>>Sent: Monday, December 13, 2004 8:13 PM
>>Subject: SequenceToArray in PN
>>>Hi Everyone,
>>>Is the SequenceToArray actor meant to be used in the PN domain?  I've
>>>attached a workflow that demonstrates behavior that I don't
>>>A SequenceToArray actor has two ports: input and arrayLength.  It
>>>should package up arrayLength number of input tokens into an array and
>>>send that out along its output port.
>>>In the attached workflow, I send 7, then 2 to the arrayLength port.
>>>However, the output consists of two array tokens both with length 7.
>>>Can someone please explain to me why the second output isn't an array
>>>of length 2?
>>>I'm using Ptolemy 4.0.1.
>>>Thanks in advance!
>>----------------------------------------------------------------------- -----
>>Posted to the ptolemy-hackers mailing list.  Please send administrative
>>mail for this list to:
>>ptolemy-hackers-request at ptolemy.eecs.berkeley.edu
>Posted to the ptolemy-hackers mailing list.  Please send administrative
>mail for this list to: ptolemy-hackers-request at ptolemy.eecs.berkeley.edu

Edward A. Lee, Professor
518 Cory Hall, UC Berkeley, Berkeley, CA 94720
phone: 510-642-0455, fax: 510-642-2718
eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal

More information about the Kepler-dev mailing list