comnum.PolarCode#
- class comnum.PolarCode(n, k, *, design_ebn0_db=2.0, crc=None, list_size=1)#
A polar code of length
n(a power of two) andkinformation bits, built by the Gaussian approximation atdesign_ebn0_db(Trifonov 2012); decoded by SC (Arıkan 2009), or SC list of sizelist_size(Tal & Vardy 2015) with the CRCcrcchoosing the path (CA-SCL).- Parameters:
- Raises:
ValueError – for an invalid parameter (the message names it).
Examples
>>> import comnum, numpy as np >>> code = comnum.PolarCode(128, 64, crc="crc6", list_size=8) >>> b = comnum.bits(64, comnum.Rng(2)) >>> llr = 4.0 * (1.0 - 2.0 * code.encode(b)) >>> bool(np.array_equal(code.decode(llr), b)) True
- decode(llr)#
Decode whole blocks of LLRs (SC or CA-SCL).
- 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.
Examples
>>> import comnum, numpy as np >>> code = comnum.PolarCode(64, 32) >>> b = comnum.bits(32, comnum.Rng(1)) >>> bool(np.array_equal(code.decode(2.0 - 4.0 * code.encode(b)), b)) True
- encode(bits)#
Encode whole blocks.
- Parameters:
bits (array_like) – a multiple of
kbits.- Returns:
ncoded bits per block (uint8).- Return type:
- Raises:
ValueError – for an input that is not an array of numbers of the expected shape.
Examples
>>> import comnum >>> comnum.PolarCode(64, 32).encode(comnum.bits(64, comnum.Rng(1))).size 128
- info_positions#
The positions of the information and CRC bits (int64).
- Type: