Skip to content

komm.Lexicode

Lexicographic code (lexicode). For a given length $n$ and minimum distance $d$, it is the linear block code obtained by starting with the all-zero codeword and adding all binary $n$-tuples (in lexicographic order) that are at least at distance $d$ from all codewords already in the code. For more details, see HP03, Sec. 2.11 and EC Zoo: Lexicographic code.

Notes
  • For $d = 2$ it reduces to the single parity-check code of length $n$.
  • For $d = n$ it reduces to the repetition code of length $n$.
  • For $n = 2^\mu - 1$ and $d = 3$ it is equivalent to the Hamming code; for $n = 2^\mu$ and $d = 4$, to its extended version.
  • For $n = 23$ and $d = 7$ it is equivalent to the Golay code; for $n = 24$ and $d = 8$, to its extended version.

Parameters:

  • n (int) –

    The length $n$ of the code.

  • d (int) –

    The minimum distance $d$ of the code. Must satisfy $1 \leq d \leq n$.

Tables:

Examples:

>>> code = komm.Lexicode(7, 3)  # Hamming (7, 4)
>>> (code.length, code.dimension, code.redundancy)
(7, 4, 3)
>>> code.generator_matrix
array([[0, 0, 0, 0, 1, 1, 1],
       [0, 0, 1, 1, 0, 0, 1],
       [0, 1, 0, 1, 0, 1, 0],
       [1, 0, 0, 1, 0, 1, 1]])
>>> code.minimum_distance()
3