comnum.NrLdpc#
- class comnum.NrLdpc(k, e, *, base_graph=None, rv=0, qm=1, rule=Ellipsis, alpha=Ellipsis, max_iterations=Ellipsis, layered=Ellipsis)#
The LDPC code of the data channels of 5G NR (3GPP TS 38.212, Sec. 5.3.2, 5.4.2): one code block of
kinformation bits rate-matched tonbits; base graph 1 or 2 chosen as the shared channels do (or forced), the smallest lifting sizeZwithK_b Z ≥ k, filler bits, the first2Zbits punctured, the circular buffer read from the start of redundancy versionrv, the bit interleaver ofqmbits per symbol; decoded by belief propagation.- Parameters:
k (int) – information bits per block (at most 8448 for base graph 1, 3840 for 2).
e (int) – transmitted bits per block
E(the rate-matched length).base_graph (int, optional) – 1 or 2 (default: the rule of Sec. 7.2.2).
rv (int) – the redundancy version, 0 to 3.
qm (int) – bits per modulation symbol of the bit interleaver (1: none).
rule (str) – the check-node rule (as
LdpcCode.set_decoder).alpha (float) – the scale or the offset of the min-sum rules.
max_iterations (int) – the maximum number of iterations.
layered (bool) – the layered schedule (default), or flooding (
False); both stop early on a codeword.
- Raises:
ValueError – for an invalid parameter (the message names it).
Examples
>>> import comnum, numpy as np >>> code = comnum.NrLdpc(100, 300) >>> code.base_graph, code.lifting_size (2, 18) >>> b = comnum.bits(100, comnum.Rng(1)) >>> bool(np.array_equal(code.decode(4.0 - 8.0 * code.encode(b)), b)) True
- decode(llr)#
Decode whole blocks of LLRs.
- Parameters:
llr (array_like) – a multiple of
nLLRs (positive for a 0).- Returns:
kbits per block (uint8).- Return type:
- 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
kbits.- Returns:
nbits per block (uint8).- Return type:
- Raises:
ValueError – for an input that is not an array of numbers of the expected shape.