Hamming Code

Given an integer \(r\) and a field \(F\), such that \(F=GF(q)\), the \([n, k, d]\) code with length \(n=\frac{q^{r}-1}{q-1}\), dimension \(k=\frac{q^{r}-1}{q-1} - r\) and minimum distance \(d=3\) is called the Hamming Code of order \(r\).

REFERENCES:

[R06]Ron Roth, Introduction to Coding Theory, Cambridge University Press, 2006
class sage.coding.hamming_code.HammingCode(base_field, order)

Bases: sage.coding.linear_code.AbstractLinearCode

Representation of a Hamming code.

INPUT:

  • base_field – the base field over which self is defined.
  • order – the order of self.

EXAMPLES:

sage: C = codes.HammingCode(GF(7), 3)
sage: C
[57, 54] Hamming Code over Finite Field of size 7
minimum_distance()

Returns the minimum distance of self. It is always 3 as self is a Hamming Code.

EXAMPLES:

sage: C = codes.HammingCode(GF(7), 3)
sage: C.minimum_distance()
3
parity_check_matrix()

Returns a parity check matrix of self.

The construction of the parity check matrix in case self is not a binary code is not really well documented. Regarding the choice of projective geometry, one might check:

  • the note over section 2.3 in [R06], pages 47-48
  • the dedicated paragraph in [HP], page 30

EXAMPLES:

sage: C = codes.HammingCode(GF(3), 3)
sage: C.parity_check_matrix()
[1 0 1 1 0 1 0 1 1 1 0 1 1]
[0 1 1 2 0 0 1 1 2 0 1 1 2]
[0 0 0 0 1 1 1 1 1 2 2 2 2]