Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
rebased over 7.5.rc1, fixed typo
Browse files Browse the repository at this point in the history
  • Loading branch information
dimpase committed Dec 30, 2016
2 parents e82c80c + 2db3057 commit 4ad7107
Show file tree
Hide file tree
Showing 9 changed files with 438 additions and 149 deletions.
4 changes: 2 additions & 2 deletions src/doc/en/constructions/linear_codes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ the four Golay codes

::

sage: C = codes.ExtendedTernaryGolayCode()
sage: C = codes.GolayCode(GF(3))
sage: C
[12, 6] linear code over GF(3)
[12, 6, 6] Extended Golay code over Finite Field of size 3
sage: C.minimum_distance()
6
sage: C.generator_matrix()
Expand Down
1 change: 1 addition & 0 deletions src/doc/en/reference/coding/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Linear codes and related constructions
sage/coding/guruswami_sudan/gs_decoder
sage/coding/guruswami_sudan/interpolation
sage/coding/guruswami_sudan/utils
sage/coding/golay_code
sage/coding/subfield_subcode
sage/coding/code_constructions
sage/coding/punctured_code
Expand Down
6 changes: 3 additions & 3 deletions src/sage/coding/binary_code.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ cdef class BinaryCode:
EXAMPLE::
sage: from sage.coding.binary_code import *
sage: B = BinaryCode(codes.ExtendedBinaryGolayCode().generator_matrix())
sage: B = BinaryCode(codes.GolayCode(GF(2)).generator_matrix())
sage: B
Binary [24,12] linear code, generator matrix
[100000000000101011100011]
Expand Down Expand Up @@ -3807,8 +3807,8 @@ cdef class BinaryCodeClassifier:
sage: from sage.coding.binary_code import *
sage: BC = BinaryCodeClassifier()
sage: B = BinaryCode(codes.ExtendedBinaryGolayCode().generator_matrix())
sage: B.apply_permutation(list(range(24,-1,-1)))
sage: B = BinaryCode(codes.GolayCode(GF(2)).generator_matrix())
sage: B.apply_permutation(range(24,-1,-1))
sage: B
Binary [24,12] linear code, generator matrix
[011000111010100000000000]
Expand Down
149 changes: 26 additions & 123 deletions src/sage/coding/code_constructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,45 +454,14 @@ def BCHCode(n,delta,F,b=0):


def BinaryGolayCode():
r"""
BinaryGolayCode() returns a binary Golay code. This is a perfect
[23,12,7] code. It is also (equivalent to) a cyclic code, with
generator polynomial
`g(x)=1+x^2+x^4+x^5+x^6+x^{10}+x^{11}`. Extending it yields
the extended Golay code (see ExtendedBinaryGolayCode).
EXAMPLE::
sage: C = codes.BinaryGolayCode()
sage: C
[23, 12] linear code over GF(2)
sage: C.minimum_distance()
7
sage: C.minimum_distance(algorithm='gap') # long time, check d=7
7
AUTHORS:
- David Joyner (2007-05)
"""
F = GF(2)
B = [[1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\
[0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\
[0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],\
[0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],\
[0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0],\
[0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],\
[0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0],\
[0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0],\
[0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0],\
[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0],\
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0],\
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1]]
# MS = MatrixSpace(F,12,23)
# V = VectorSpace(F,23)
V = span(B, F)
return LinearCode(V, d=7)

This method is now deprecated.
Please use :class:`sage.coding.golay_code.GolayCode` instead.
"""
from sage.misc.superseded import deprecation
from .golay_code import GolayCode
deprecation(20787, "codes.TernaryGolayCode is now deprecated. Please use codes.GolayCode instead.")
return GolayCode(GF(2), False)

def CyclicCodeFromGeneratingPolynomial(n,g,ignore=True):
r"""
Expand Down Expand Up @@ -709,39 +678,13 @@ def DuadicCodeOddPair(F,S1,S2):

def ExtendedBinaryGolayCode():
"""
ExtendedBinaryGolayCode() returns the extended binary Golay code.
This is a perfect [24,12,8] code. This code is self-dual.
EXAMPLES::
sage: C = codes.ExtendedBinaryGolayCode()
sage: C
[24, 12] linear code over GF(2)
sage: C.minimum_distance()
8
sage: C.minimum_distance(algorithm='gap') # long time, check d=8
8
AUTHORS:
- David Joyner (2007-05)
This method is now deprecated.
Please use :class:`sage.coding.golay_code.GolayCode` instead.
"""
B = [[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]]
V = span(B, GF(2))
return LinearCode(V, d=8)
# C = BinaryGolayCode()
# return C.extended_code()
from sage.misc.superseded import deprecation
from .golay_code import GolayCode
deprecation(20787, "codes.ExtendedBinaryGolayCode is now deprecated. Please use codes.GolayCode instead.")
return GolayCode(GF(2))


def ExtendedQuadraticResidueCode(n,F):
Expand Down Expand Up @@ -788,33 +731,13 @@ def ExtendedQuadraticResidueCode(n,F):

def ExtendedTernaryGolayCode():
"""
ExtendedTernaryGolayCode returns a ternary Golay code. This is a
self-dual perfect [12,6,6] code.
EXAMPLES::
sage: C = codes.ExtendedTernaryGolayCode()
sage: C
[12, 6] linear code over GF(3)
sage: C.minimum_distance()
6
sage: C.minimum_distance(algorithm='gap') # long time, check d=6
6
AUTHORS:
- David Joyner (11-2005)
This method is now deprecated.
Please use :class:`sage.coding.golay_code.GolayCode` instead.
"""
B = [[1, 0, 0, 0, 0, 0, 2, 0, 1, 2, 1, 2],\
[0, 1, 0, 0, 0, 0, 1, 2, 2, 2, 1, 0],\
[0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1],\
[0, 0, 0, 1, 0, 0, 1, 1, 0, 2, 2, 2],\
[0, 0, 0, 0, 1, 0, 2, 1, 2, 2, 0, 1],\
[0, 0, 0, 0, 0, 1, 0, 2, 1, 2, 2, 1]]
V = span(B, GF(3))
return LinearCode(V, d=6)
# C = TernaryGolayCode()
# return C.extended_code()
from sage.misc.superseded import deprecation
from .golay_code import GolayCode
deprecation(20787, "codes.ExtendedTernayGolayCode is now deprecated. Please use codes.GolayCode instead.")
return GolayCode(GF(3))

def from_parity_check_matrix(H):
r"""
Expand Down Expand Up @@ -1070,34 +993,14 @@ def ReedSolomonCode(n,k,F,pts = None):


def TernaryGolayCode():
r"""
TernaryGolayCode returns a ternary Golay code. This is a perfect
[11,6,5] code. It is also equivalent to a cyclic code, with
generator polynomial `g(x)=2+x^2+2x^3+x^4+x^5`.
EXAMPLES::
sage: C = codes.TernaryGolayCode()
sage: C
[11, 6] linear code over GF(3)
sage: C.minimum_distance()
5
sage: C.minimum_distance(algorithm='gap') # long time, check d=5
5
AUTHORS:
- David Joyner (2007-5)
"""
F = GF(3)
B = [[2, 0, 1, 2, 1, 1, 0, 0, 0, 0, 0],\
[0, 2, 0, 1, 2, 1, 1, 0, 0, 0, 0],\
[0, 0, 2, 0, 1, 2, 1, 1, 0, 0, 0],\
[0, 0, 0, 2, 0, 1, 2, 1, 1, 0, 0],\
[0, 0, 0, 0, 2, 0, 1, 2, 1, 1, 0],\
[0, 0, 0, 0, 0, 2, 0, 1, 2, 1, 1]]
V = span(B, F)
return LinearCode(V, d=5)
This method is now deprecated.
Please use :class:`sage.coding.golay_code.GolayCode` instead.
"""
from sage.misc.superseded import deprecation
from .golay_code import GolayCode
deprecation(20787, "codes.TernayGolayCode is now deprecated. Please use codes.GolayCode instead.")
return GolayCode(GF(3), False)

def ToricCode(P,F):
r"""
Expand Down
2 changes: 2 additions & 0 deletions src/sage/coding/codes_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@
from .reed_muller_code import ReedMullerCode, BinaryReedMullerCode
from .extended_code import ExtendedCode
from .subfield_subcode import SubfieldSubcode
from .golay_code import GolayCode

from .guava import QuasiQuadraticResidueCode, RandomLinearCodeGuava
_lazy_import('sage.coding.punctured_code', 'PuncturedCode')
from .hamming_code import HammingCode
from .golay_code import GolayCode
from . import decoders_catalog as decoders
from . import encoders_catalog as encoders
from . import bounds_catalog as bounds
Expand Down
Loading

0 comments on commit 4ad7107

Please sign in to comment.