Linear Codes Modules

Classical Codes

class HammingCode(r, extended=False)

Bases: lpdec.codes.BinaryLinearBlockCode

A class for Hamming codes, both standard and extended.

For given r2, creates the Hamming code of block length 2r1 or the extended Hamming code of block length 2r; the information length of both types ist 2rr1.

Parameters:
  • r (int) – determines the size of the code
  • extended (bool) – set to True to create the extended Hamming code instead of the “normal” one.
class ReedMullerCode(m, r=None, infolength=None)

Bases: lpdec.codes.BinaryLinearBlockCode

Reed-Muller code using the “polar code like” construction with F2 as generator matrix.

Parameters:
  • r (int) – Order of the RM code.
  • m (int) – 2-logarithm of the code’s length: the code’s length will be 2m.

LDPC Codes

class ArrayLDPCCode(q, m)

Bases: lpdec.codes.BinaryLinearBlockCode

An array LDPC code is defined by an odd prime q and a number mq.

For the formal definition see: J. L. Fan, “Array codes as low-density parity-check codes”, in Proc. 2nd Int. Symp. Turbo Codes & Rel. Topics, Brest, France, Sep. 2000, pp. 543–546.

Factor Graphs

The lpdec.codes.factorgraph module contains classes for defining a factor graph of a parity-check matrix.

class FactorGraph(varNodes, checkNodes, x=None)

Bases: object

Factor graph main class.

varNodes

List of variable nodes of the graph.

checkNodes

List of check nodes of the graph.

classmethod fromLinearCode(code)

Creates the factor graph according to the parity-check matrix of code.

class FactorNode(identifier)

Bases: object

Base class for nodes of a factor graph.

Parameters:identifier – A free-form identifier for this node.
neighbors

List of neighboring nodes.

connect(other)

Connect other to this node by updating the neighbors lists of both nodes.

degree

The degree of this node, i.e. number of connected nodes.

class VariableNode(identifier)

Bases: lpdec.codes.factorgraph.FactorNode

FactorNode subclass for variables.

merge(other)

Merge other into this node. Afterwards, other will be isolated and all of its neighbors connected to self.

class CheckNode(identifier)

Bases: lpdec.codes.factorgraph.FactorNode

FactorNode subclass for checks.

Non-Binary Codes

This module contains classes and helper functions for non-binary codes. Currently, the contents are not well integrated with the rest of the lpdec package.

class NonbinaryLinearBlockCode(name=None, parityCheckMatrix=None, q=None)

Bases: lpdec.codes.LinearBlockCode

Base class for non-binary linear block codes over GF(q).

name is a string uniquely describing the code. When storing results into a database, there must not be two different codes with the same name. If the parity-check matrix is given by a file, the code’s name defaults to the name of that file.

The class can be instanciated directly by providing a parity check matrix; the argument parityCheckMatrix must be either the path of a file containig the matrix, or a two-dimensional list or a np.ndarray representation of the matrix. Subclasses using a different code representation should leave the default value of None.

binaryEmbedding(vector, q)

Return the binary embedding of a q-ary vector GF(q)n into GF(2)(q1)imesn using the map

0 -> 0 ... 0 1 -> 1 ... 0 2 -> 0 1...0 .. q-1 -> 0 0.. 1