# Nonlinear primitives

Primitives that compute transcendental functions, such as logarithm, cosine, sine, and exponential functions, as well as quantizer and table lookup primitives.

## Quantizers

Quantize the input to one of possible output levels. The high and low output levels are anti-symmetrically arranged around zero and their magnitudes are determined by .
The steps between levels are uniformly spaced at the step size given by the inStep input. The linear quantizer can be made adaptive by feeding back past information such as quantization level, quantization value, and step size into the current step size.
LinQuantIdx
Quantize the input to the number of levels given by the levels parameter. The quantization levels are uniformly spaced between low and high inclusive. Rounding down is performed, so that output level will equal high only if the input level equals or exceeds high. If the input is below low, then the quantized output will equal low. The quantized value is output to the amplitude port, while the index of the quantization level is output to the stepNumber port.
Quant
Quantize the input value to one of N+1 possible output levels using N thresholds. For an input less than or equal to the n-th threshold, but larger than all previous thresholds, the output will be the n-th level. If the input is greater than all thresholds, the output is the N+1-th level. If the levels parameter is specified, there must be one more level than thresholds; the default value for levels is 0, 1, 2, ... N. This primitive is much slower than LinQuantIdx, so if possible, that one should be used instead.
QuantIdx
Quantize the input value to one of N+1 possible output levels using N thresholds, and output both the quantized result and the quantization level. See the Quant primitive for more information.
Quantizer
This primitive quantizes the input value to the nearest output value in the given codebook. The nearest value is found by a full search of the codebook, so the primitive will be significantly slower than either Quant or LinQuantIdx. The absolute value of the difference is used as a distance measure.

## Math functions

Cos
Compute the cosine of its input, assumed to be an angle in radians.
Dirichlet
Compute the normalized Dirichlet kernel (also called the aliased sinc function):

The value of the normalized Dirichlet kernel at x = 0 is always 1, and the normalized Dirichlet kernel oscillates between -1 and +1. The normalized Dirichlet kernel is periodic in x with a period of either when N is odd or when N is even.

Limit
The output of this primitive is the value of the input limited to the range between bottom and top inclusive.
MaxMin
Finds maximum or minimum, value or magnitude, of a fixed number of data values on its input. If you want to use this primitive to operate over multiple data streams, then precede this primitive with a Commutator and set the parameter N accordingly.
OrderTwoInt
Takes two inputs and outputs the greater and lesser of the two integers.
Sgn
Compute the signum of its input. The output is . Note that 0.0 maps into 1.
Sin
Computes the sine of its input, assumed to be an angle in radians.
Sinc
Computes the sinc of its input given in radians. The sinc function is defined as , with value 1.0 when .

## Other nonlinear functions

PcwzLinear

This primitive implements a piecewise linear mapping from the list of (x,y) pairs, which specify the breakpoints in the function.

The sequence of x values must be increasing. The function implemented by the primitive can be represented by drawing straight lines between the (x,y) pairs, in sequence.

The default mapping is the tent map, in which inputs between -1.0 and 0.0 are linearly mapped into the range -1.0 to 1.0. Inputs between 0.0 and 1.0 are mapped into the same range, but with the opposite slope, 1.0 to -1.0.

If the input is outside the range specified in the x values of the breakpoints, then the appropriate extreme value will be used for the output. Thus, for the default map, if the input is -2.0, the output will be -1.0. If the input is +2.0, the output will again be -1.0.

Table
This primitive implements a float-valued lookup table indexed by an integer-valued input. The input must lie between 0 and N − 1, inclusive, where N is the size of the table. The values parameter specifies the table. Its first element is indexed by a zero-valued input. An error occurs if the input value is out-of-bounds.
TableCx
Table lookup for complex values.
TableInt
Table lookup for integer values.