Hamming codes

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:

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 GF(7)
minimum_distance()

Return 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()

Return 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 [Rot2006], pages 47-48
  • the dedicated paragraph in [HP2003], 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]