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

uencode

Uniform encoder


Description

Quantize and encode floating-point inputs to integer outputs.

Usage

uencode(u, n, v = 1, signed = FALSE)

Arguments

u

Input, a multidimensional array of numbers, real or complex, single or double precision.

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.

signed

Logical indicating signed or unsigned output. See Details. Default: FALSE.

Details

y <- uencode(u, n) quantizes the entries in a multidimensional array of floating-point numbers u and encodes them as integers using 2^{n}-level quantization. n must be an integer between 2 and 32 (inclusive). Inputs can be real or complex, double- or single-precision. The output y and the input u are arrays of the same size. The elements of the output y are unsigned integers with magnitudes in the range 0 to 2^{n} - 1. Elements of the input u outside of the range -1 to 1 are treated as overflows and are saturated.

  • For entries in the input u that are less than -1, the value of the output of uencode is 0.

  • For entries in the input u that are greater than 1, the value of the output of uencode is 2^{n}-1.

y <- uencode(u, n, v) allows the input u to have entries with floating-point values in the range -v to v before saturating them (the default value for v is 1). Elements of the input u outside of the range -v to v are treated as overflows and are saturated:

  • For input entries less than -v, the value of the output of uencode is 0.

  • For input entries greater than v, the value of the output of uencode is 2^{n} - 1.

y <- uencode(u, n, v, signed) maps entries in a multidimensional array of floating-point numbers u whose entries have values in the range -v to v to an integer output y. Input entries outside this range are saturated. The integer type of the output depends on the number of quantization levels 2^{n} and the value of signed, which can be one of the following:

  • TRUE: Outputs are signed integers with magnitudes in the range -2^{n} / 2 to (2^{n} / 2) - 1.

  • FALSE (default): Outputs are unsigned integers with magnitudes in the range 0 to 2^{n} - 1.

Value

Multidimensional array of the same size as u containing signed or unsigned integers.

Author(s)

Georgios Ouzounis, ouzounis_georgios@hotmail.com.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

Examples

u <- seq(-1, 1, 0.01)
y <- uencode(u, 3)
plot(u, y)

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.