comnum.NrPolar#

class comnum.NrPolar(k, e, *, link='uplink', list_size=8)#

The polar code of the control channels of 5G NR (3GPP TS 38.212, Sec. 5.3.1, 5.4.1): k payload bits with their CRC rate-matched to n bits (puncturing, shortening or repetition by the sub-block interleaver), the frozen set of the polar sequence of Table 5.3.1.2-1; decoded by CRC-aided SC list.

"uplink": the uplink control information (CRC6 and 3 parity-check bits for 12 ≤ k ≤ 19, CRC11 above, the triangular interleaver of the coded bits). "downlink": the downlink control information and the broadcast channel (CRC24C, the input interleaver; the RNTI masking of a DCI is left to the caller).

Parameters:
  • k (int) – payload bits per block.

  • e (int) – transmitted bits per block E (the rate-matched length).

  • link (str) – "uplink" or "downlink".

  • list_size (int) – the list size L.

Raises:

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

Examples

>>> import comnum, numpy as np
>>> code = comnum.NrPolar(30, 100, list_size=8)
>>> code.mother_length
128
>>> b = comnum.bits(30, comnum.Rng(1))
>>> bool(np.array_equal(code.decode(3.0 - 6.0 * code.encode(b)), b))
True
decode(llr)#

Decode whole blocks of LLRs (CRC-aided SC list).

Parameters:

llr (array_like) – a multiple of n LLRs (positive for a 0).

Returns:

k bits per block (uint8).

Return type:

numpy.ndarray

Raises:

ValueError – for an input that is not an array of numbers of the expected shape.

encode(bits)#

Encode whole blocks.

Parameters:

bits (array_like) – a multiple of k bits.

Returns:

n bits per block (uint8).

Return type:

numpy.ndarray

Raises:

ValueError – for an input that is not an array of numbers of the expected shape.

k#

Payload bits per block.

Type:

int

mother_length#

The mother code length N.

Type:

int

n#

Transmitted bits per block.

Type:

int

rate#

Code rate k / n.

Type:

float