| udecode {gsignal} | R Documentation |
Uniform decoder
Description
Decode 2^n-level quantized integer inputs to floating-point outputs.
Usage
udecode(u, n, v = 1, saturate = TRUE)
Arguments
u |
Input, a multidimensional array of integer numbers (can be complex). |
n |
Number of levels used in |
v |
Limit on the range of |
saturate |
Logical indicating to saturate (TRUE, default) or to wrap (FALSE) overflows. See Details. |
Details
y <- udecode(u, n) inverts the operation of uencode and
reconstructs quantized floating-point values from an encoded multidimensional
array of integers u. The input argument n must be an integer
between 2 and 32. The integer n specifies that there are 2^{n}
quantization levels for the inputs, so that entries in u must be
either:
Signed integers in the range
-2^{n}/2to(2^{n}/2) - 1Unsigned integers in the range 0 to
2^{n} - 1
Inputs can be real or complex values of any integer data type. Overflows
(entries in u outside of the ranges specified above) are saturated to the
endpoints of the range interval. The output has the same dimensions as the
input u. Its entries have values in the range -1 to 1.
y <- udecode(u, n, v) decodes u such that the output has values
in the range -v to v, where the default value for v is
1.
y <- udecode(u, n, v, saturate) decodes u and treats input
overflows (entries in u outside of the range -v to v
according to saturate, which can be set to one of the following:
TRUE (default). Saturate overflows.
Entries in signed inputs
uwhose values are outside of the range-2^{n}/2to(2^{n}/2) – 1are assigned the value determined by the closest endpoint of this interval.Entries in unsigned inputs
uwhose values are outside of the range 0 to2^{n}-1are assigned the value determined by the closest endpoint of this interval.
FALSE Wrap all overflows according to the following:
Entries in signed inputs
uwhose values are outside of the range-2^{n}/2to(2^{n}/2) – 1are wrapped back into that range using modulo2^{n}arithmetic (calculated usingu = mod(u+2^{n}/2, 2^{n})-(2^{n}/2)).Entries in unsigned inputs
uwhose values are outside of the range 0 to2^{n}-1are wrapped back into the required range before decoding using modulo2^{n}arithmetic (calculated usingu = mod(u,2^{n})).
Value
Multidimensional array of the same size as u containing
floating point numbers.
Note
The real and imaginary components of complex inputs are decoded independently.
Author(s)
Georgios Ouzounis, ouzounis_georgios@hotmail.com.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.
Examples
u <- c(-1, 1, 2, -5)
ysat <- udecode(u, 3)
# Notice the last entry in u saturates to 1, the default peak input
# magnitude. Change the peak input magnitude to 6.
ysatv <- udecode(u, 3, 6)
# The last input entry still saturates. Wrap the overflows.
ywrap = udecode(u, 3, 6, FALSE)
# Add more quantization levels.
yprec <- udecode(u, 5)