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.

Attributes:

  • n (int)

    The length $n$ of the code.

  • d (int)

    The minimum distance $d$ of the code.

For more details, see HP03, Sec. 2.11.

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