This actor reads a sequence of input tokens of any type, and writes a
sequence of tokens constructed from the input sequence (possibly
supplemented with zeros). The number of input tokens consumed
is given by <i>numberToRead</i>, and the number of output tokens
produced is given by <i>numberToWrite</i>.
The <i>offset</i> parameter (default 0) specifies where in the output
block the first (oldest) input that is read should go.
If <i>offset</i> is positive and <i>usePastInputs</i> is true,
then the first few outputs will come from values read in previous iterations.
<p>
A simple use of this actor is to pad a block of inputs with zeros.
Set <i>offset</i> to zero and use <i>numberToWrite > numberToRead</i>.
<a name="zero padding"></a>
<a name="padding"></a></p>
<p>
Another simple use is to obtain overlapping windows from
an input stream.
Set <i>usePastInputs</i> to true, use <i>numberToWrite > numberToRead</i>,
and set <i>offset</i> equal to <i>numberToWrite - numberToRead</i>.
<a name="overlapping windows"></a>
<a name="windowing"></a></p>
<p>
The general operation is illustrated with the following examples.
If <i>offset</i> is positive,
there two possible scenarios, illustrated by the following examples:</p>
<p>
<pre>
iiiiii numberToRead = 6
\ \ offset = 2
ppiiiiii00 numberToWrite = 10
iiiiii numberToRead = 6
\ \ \ offset = 2
ppiii numberToWrite = 5
</pre></p>
<p>
The symbol "i" refers to any input token. The leftmost symbol
refers to the oldest input token of the ones consumed in a given
firing. The symbol "p" refers to a token that is either zero
(if <i>usePastInputs</i> is false) or is equal to a previously
consumed input token (if <i>usePastInputs</i> is true).
The symbol "0" refers to a zero-valued token.
In the first of the above examples, the entire input block is
copied to the output, and then filled out with zeros.
In the second example, only a portion of the input block fits.
The remaining input tokens are discarded, although they might
be used in subsequent firings if <i>usePastInputs</i> is true.</p>
<p>
When the <i>offset</i> is negative, this indicates that the
first <i>offset</i> input tokens that are read should be
discarded. The corresponding scenarios are shown below:</p>
<p>
<pre>
iiiiii numberToRead = 6
/ / / offset = -2
iiii000000 numberToWrite = 10
iiiiii numberToRead = 6
/ / // offset = -2
iii numberToWrite = 3
</pre>
</p>
<p>
In the first of these examples, the first two input tokens are
discarded. In the second example, the first two and the last input
token are discarded.</p>
<p>
The zero-valued tokens are constructed using the zero() method of
the first input token that is read in the firing. This returns
a zero-valued token with the same type as the input.</p>
Edward A. Lee
$Id: Chop.java 70398 2014-10-22 23:44:32Z cxh $
Ptolemy II 1.0
Green (eal)
Yellow (neuendor)
The number of input tokens to read.
This is an integer, with default 128.
The number of tokens to write to the output.
This is an integer, with default 64.
Start of output block relative to start of input block.
This is an integer, with default 0.
If offset is greater than 0, specify whether to use previously
read inputs (otherwise use zeros).
This is a boolean, with default true.