Polar Codes#

The Polar code module supports 5G-compliant Polar codes and includes successive cancellation (SC), successive cancellation list (SCL), and belief propagation (BP) decoding. The module supports rate-matching and CRC-aided decoding. Further, Reed-Muller (RM) code design is available and can be used in combination with the Polar encoding/decoding algorithms.

The following code snippets show how to setup and run a rate-matched 5G compliant Polar encoder and a corresponding successive cancellation list (SCL) decoder.

First, we need to create instances of Polar5GEncoder and Polar5GDecoder:

encoder = Polar5GEncoder(k          = 100, # number of information bits (input)
                         n          = 200) # number of codeword bits (output)


decoder = Polar5GDecoder(encoder    = encoder, # connect the Polar decoder to the encoder
                         dec_type   = "SCL", # can be also "SC" or "BP"
                         list_size  = 8)

Now, the encoder and decoder can be used by:

# --- encoder ---
# u contains the information bits to be encoded and has shape [...,k].
# c contains the polar encoded codewords and has shape [...,n].
c = encoder(u)

# --- decoder ---
# llr contains the log-likelihood ratios from the demapper and has shape [...,n].
# u_hat contains the estimated information bits and has shape [...,k].
u_hat = decoder(llr)

Polar5GEncoder(k, n[, channel_type, ...])

5G compliant Polar encoder including rate-matching following [3GPPTS38212] for the uplink scenario (UCI) and downlink scenario (DCI).

PolarEncoder(frozen_pos, n, *[, precision, ...])

Polar encoder for given code parameters.

Polar5GDecoder(enc_polar[, dec_type, ...])

Wrapper for 5G compliant decoding including rate-recovery and CRC removal.

PolarSCDecoder(frozen_pos, n, *[, ...])

Successive cancellation (SC) decoder [Arikan_Polar] for Polar codes and Polar-like codes.

PolarSCLDecoder(frozen_pos, n[, list_size, ...])

Successive cancellation list (SCL) decoder [Tal_SCL] for Polar codes and Polar-like codes.

PolarBPDecoder(frozen_pos, n[, num_iter, ...])

Belief propagation (BP) decoder for Polar codes [Arikan_Polar] and Polar-like codes based on [Arikan_BP] and [Forney_Graphs].