Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

udecode

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 2^{n}-level quantization. n must be between 2 and 32

v

Limit on the range of u to the range from -v to v before saturating them. Default 1.

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}/2 to (2^{n}/2) - 1

  • Unsigned 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 u whose values are outside of the range -2^{n}/2 to (2^{n}/2) – 1 are assigned the value determined by the closest endpoint of this interval.

    • Entries in unsigned inputs u whose values are outside of the range 0 to 2^{n}-1 are assigned the value determined by the closest endpoint of this interval.

  • FALSE Wrap all overflows according to the following:

    • Entries in signed inputs u whose values are outside of the range -2^{n}/2 to (2^{n}/2) – 1 are wrapped back into that range using modulo 2^{n} arithmetic (calculated using u = mod(u+2^{n}/2, 2^{n})-(2^{n}/2)).

    • Entries in unsigned inputs u whose values are outside of the range 0 to 2^{n}-1 are wrapped back into the required range before decoding using modulo 2^{n} arithmetic (calculated using u = 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)

gsignal

Signal Processing

v0.3-1
GPL-3
Authors
Geert van Boxtel [aut, cre] (Maintainer), Tom Short [aut] (Author of 'signal' package), Paul Kienzle [aut] (Majority of the original sources), Ben Abbott [ctb], Juan Aguado [ctb], Muthiah Annamalai [ctb], Leonardo Araujo [ctb], William Asquith [ctb], David Bateman [ctb], David Billinghurst [ctb], Juan Pablo Carbajal [ctb], André Carezia [ctb], Vincent Cautaerts [ctb], Eric Chassande-Mottin [ctb], Luca Citi [ctb], Dave Cogdell [ctb], Carlo de Falco [ctb], Carne Draug [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], R.G.H Eschauzier [ctb], Andrew Fitting [ctb], Alan J. Greenberger [ctb], Mike Gross [ctb], Daniel Gunyan [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Jake Janovetz [ctb], Alexander Klein [ctb], Peter V. Lanspeary [ctb], Bill Lash [ctb], Friedrich Leissh [ctb], Laurent S. Mazet [ctb], Mike Miller [ctb], Petr Mikulik [ctb], Paolo Neis [ctb], Georgios Ouzounis [ctb], Sylvain Pelissier [ctb], Francesco Potortì [ctb], Charles Praplan [ctb], Lukas F. Reichlin [ctb], Tony Richardson [ctb], Asbjorn Sabo [ctb], Thomas Sailer [ctb], Rolf Schirmacher [ctb], Rolf Schirmacher [ctb], Ivan Selesnick [ctb], Julius O. Smith III [ctb], Peter L. Soendergaard [ctb], Quentin Spencer [ctb], Doug Stewart [ctb], P. Sudeepam [ctb], Stefan van der Walt [ctb], Andreas Weber [ctb], P. Sudeepam [ctb], Andreas Weingessel [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.