comnum.Ostbc#

class comnum.Ostbc#

An orthogonal space-time block code (Alamouti, or the rate-3/4 codes for 3 and 4 antennas), with linear maximum-likelihood decoding.

A block sends n_symbols symbols over n_slots channel uses from n_tx antennas, with a unit average transmitted energy per channel use. Decoding turns the block into one scalar channel per symbol of noise variance σ²/(c² ‖H‖_F²), a diversity of n_tx · n_rx. Build it with Ostbc.alamouti() or Ostbc.rate_3_4(n_tx).

Examples

>>> import comnum, numpy as np
>>> code = comnum.Ostbc.alamouti()
>>> s = np.array([1 + 1j, -1 + 1j]) / np.sqrt(2)
>>> h = comnum.mimo_channel(1, 2, comnum.Rng(2))
>>> est, var = code.decode(h, h @ code.encode(s), 0.01)
>>> np.allclose(est, s)
True
static alamouti()#

Alamouti’s code: two antennas, rate one.

Returns:

the code.

Return type:

Ostbc

static rate_3_4(n_tx)#

The rate-3/4 code for 3 or 4 antennas.

Parameters:

n_tx (int) – 3 or 4.

Returns:

the code.

Return type:

Ostbc

Raises:

ValueError – for an invalid parameter (the message names it).

decode(h, y, noise_var)#

Decode the received blocks (linear maximum likelihood).

Parameters:
  • h (array_like) – the channel, (n_rx, n_tx), or (blocks, n_rx, n_tx).

  • y (array_like) – the received blocks, (n_rx, n_slots · blocks).

  • noise_var (float) – noise variance per receive antenna.

Returns:

the symbol estimates and their noise variances.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

Raises:

ValueError – for an invalid parameter or input (the message names it).

encode(symbols)#

The signal of the antennas.

Parameters:

symbols (array_like) – a multiple of n_symbols symbols.

Returns:

(n_tx, n_slots · blocks) (complex128).

Return type:

numpy.ndarray

Raises:

ValueError – for an invalid parameter or input (the message names it).

n_slots#

Channel uses per block.

Type:

int

n_symbols#

Symbols per block.

Type:

int

n_tx#

Transmit antennas.

Type:

int

name#

Name of the code.

Type:

str

rate#

Symbols per channel use.

Type:

float