Produce an output token on each firing with a value that is a quantized version of the input. The input and output types are both double.
The levels parameter contains an array of doubles specifying the quantization levels. The elements must be in an increasing order, or an exception will be thrown. The default value of levels is {-1.0, 1.0}.
Suppose u is the input, and levels = {a, b, c}, where a < b < c, then the output of the actor will be:
y = a, for u <= (b+a)/2;
y = b, for (b+a)/2 <
u <= (c+b)/2;
y = c, for u > (c+b)/2;
Thus, for the default levels, the output is (almost) the signum function of the input, or +1.0 if the input is positive, and -1.0 otherwise. This is almost the signum function because it outputs -1.0 if the input is zero.
This actor does not require that the quantization intervals be equal, i.e. we allow that (c-b) != (b-a).
@author Jie Liu @version $Id: Quantizer.java,v 1.45 2007/03/26 03:45:06 celaine Exp $ @since Ptolemy II 0.3 @Pt.ProposedRating Yellow (liuj) @Pt.AcceptedRating Yellow (yuhong)
|
|