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 selfdual codes.
REFERENCES:
 [HP2003] pp. 3133 for a definition of Golay codes.
[WS]  F. J. MacWilliams, N. J. A. Sloane, The Theory of ErrorCorrecting Codes, NorthHolland, Amsterdam, 1977 

class
sage.coding.golay_code.
GolayCode
(base_field, extended=True)¶ Bases:
sage.coding.linear_code.AbstractLinearCode
Representation of a Golay Code.
INPUT:
base_field
– The base field over which the code is defined. Can only beGF(2)
orGF(3)
.extended
– (default:True
) if set toTrue
, creates an extended Golay code.
EXAMPLES:
sage: codes.GolayCode(GF(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)

covering_radius
()¶ 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

dual_code
()¶ Return the dual code of
self
.If
self
is an extended Golay code,self
is returned. Otherwise, it returns the output ofsage.coding.linear_code.AbstractLinearCode.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

generator_matrix
()¶ 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]

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

parity_check_matrix
()¶ 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]

weight_distribution
()¶ 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]