Golay code

Golay codes are a set of four specific codes (binary Golay code, extended binary Golay code, ternary Golay and extended ternary Golay code), known to have some very interesting properties: for example, binary and ternary Golay codes are perfect codes, while their extended versions are self-dual codes.

REFERENCES:

class sage.coding.golay_code.GolayCode(base_field, extended=True)[source]

Bases: AbstractLinearCode

Representation of a Golay Code.

INPUT:

  • base_field – the base field over which the code is defined; can only be GF(2) or GF(3)

  • extended – boolean (default: True); if set to True, creates an extended Golay code

EXAMPLES:

sage: codes.GolayCode(GF(2))
[24, 12, 8] Extended Golay code over GF(2)
>>> from sage.all import *
>>> codes.GolayCode(GF(Integer(2)))
[24, 12, 8] Extended Golay code over GF(2)

Another example with the perfect binary Golay code:

sage: codes.GolayCode(GF(2), False)
[23, 12, 7]  Golay code over GF(2)
>>> from sage.all import *
>>> codes.GolayCode(GF(Integer(2)), False)
[23, 12, 7]  Golay code over GF(2)
covering_radius()[source]

Return the covering radius of self.

The covering radius of a linear code \(C\) is the smallest integer \(r\) s.t. any element of the ambient space of \(C\) is at most at distance \(r\) to \(C\).

The covering radii of all Golay codes are known, and are thus returned by this method without performing any computation

EXAMPLES:

sage: C = codes.GolayCode(GF(2))
sage: C.covering_radius()
4
sage: C = codes.GolayCode(GF(2),False)
sage: C.covering_radius()
3
sage: C = codes.GolayCode(GF(3))
sage: C.covering_radius()
3
sage: C = codes.GolayCode(GF(3),False)
sage: C.covering_radius()
2
>>> from sage.all import *
>>> C = codes.GolayCode(GF(Integer(2)))
>>> C.covering_radius()
4
>>> C = codes.GolayCode(GF(Integer(2)),False)
>>> C.covering_radius()
3
>>> C = codes.GolayCode(GF(Integer(3)))
>>> C.covering_radius()
3
>>> C = codes.GolayCode(GF(Integer(3)),False)
>>> C.covering_radius()
2
dual_code()[source]

Return the dual code of self.

If self is an extended Golay code, self is returned. Otherwise, it returns the output of sage.coding.linear_code_no_metric.AbstractLinearCodeNoMetric.dual_code()

EXAMPLES:

sage: C = codes.GolayCode(GF(2), extended=True)
sage: Cd = C.dual_code(); Cd
[24, 12, 8] Extended Golay code over GF(2)

sage: Cd == C
True
>>> from sage.all import *
>>> C = codes.GolayCode(GF(Integer(2)), extended=True)
>>> Cd = C.dual_code(); Cd
[24, 12, 8] Extended Golay code over GF(2)

>>> Cd == C
True
generator_matrix()[source]

Return a generator matrix of self.

Generator matrices of all Golay codes are known, and are thus returned by this method without performing any computation

EXAMPLES:

sage: C = codes.GolayCode(GF(2), extended=True)
sage: C.generator_matrix()
[1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1]
[0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 1 0]
[0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0 1 0 1 1]
[0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0]
[0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 0 0 1]
[0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 0 1]
[0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 1]
[0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0 0]
[0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0]
[0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0]
[0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1 0 1]
[0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1 1]
>>> from sage.all import *
>>> C = codes.GolayCode(GF(Integer(2)), extended=True)
>>> C.generator_matrix()
[1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1]
[0 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 0 0 1 0]
[0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0 1 0 1 1]
[0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0]
[0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 0 0 1]
[0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 0 1]
[0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 1]
[0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0 0]
[0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0]
[0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0]
[0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1 0 1]
[0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 0 1 1 1]
minimum_distance()[source]

Return the minimum distance of self.

The minimum distance of Golay codes is already known, and is thus returned immediately without computing anything.

EXAMPLES:

sage: C = codes.GolayCode(GF(2))
sage: C.minimum_distance()
8
>>> from sage.all import *
>>> C = codes.GolayCode(GF(Integer(2)))
>>> C.minimum_distance()
8
parity_check_matrix()[source]

Return the parity check matrix of self.

The parity check matrix of a linear code \(C\) corresponds to the generator matrix of the dual code of \(C\).

Parity check matrices of all Golay codes are known, and are thus returned by this method without performing any computation.

EXAMPLES:

sage: C = codes.GolayCode(GF(3), extended=False)
sage: C.parity_check_matrix()
[1 0 0 0 0 1 2 2 2 1 0]
[0 1 0 0 0 0 1 2 2 2 1]
[0 0 1 0 0 2 1 2 0 1 2]
[0 0 0 1 0 1 1 0 1 1 1]
[0 0 0 0 1 2 2 2 1 0 1]
>>> from sage.all import *
>>> C = codes.GolayCode(GF(Integer(3)), extended=False)
>>> C.parity_check_matrix()
[1 0 0 0 0 1 2 2 2 1 0]
[0 1 0 0 0 0 1 2 2 2 1]
[0 0 1 0 0 2 1 2 0 1 2]
[0 0 0 1 0 1 1 0 1 1 1]
[0 0 0 0 1 2 2 2 1 0 1]
weight_distribution()[source]

Return the list whose \(i\)-th entry is the number of words of weight \(i\) in self.

The weight distribution of all Golay codes are known, and are thus returned by this method without performing any computation MWS (67, 69)

EXAMPLES:

sage: C = codes.GolayCode(GF(3))
sage: C.weight_distribution()
[1, 0, 0, 0, 0, 0, 264, 0, 0, 440, 0, 0, 24]
>>> from sage.all import *
>>> C = codes.GolayCode(GF(Integer(3)))
>>> C.weight_distribution()
[1, 0, 0, 0, 0, 0, 264, 0, 0, 440, 0, 0, 24]