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

Commit

Permalink
Merged with latest beta (7.5.beta1).
Browse files Browse the repository at this point in the history
  • Loading branch information
jlavauzelle committed Nov 1, 2016
2 parents de71261 + 4d65268 commit a3b2b66
Show file tree
Hide file tree
Showing 12 changed files with 315 additions and 262 deletions.
10 changes: 5 additions & 5 deletions src/doc/en/thematic_tutorials/coding_theory.rst
Expand Up @@ -87,7 +87,7 @@ By just typing the name of our code, we get a sentence which briefly
describes it and gives its parameters::

sage: C
Linear code of length 7, dimension 3 over Finite Field of size 3
[7, 3] linear code over GF(3)

As the aim of this tutorial is not to give a comprehensive view of the methods,
we won't describe any other methods.
Expand Down Expand Up @@ -189,7 +189,7 @@ All these parameters are summarized inside the string representation
of our code::

sage: C
[12, 6, 7] Generalized Reed-Solomon Code over Finite Field of size 13
[12, 6, 7] Generalized Reed-Solomon Code over GF(13)

.. NOTE::

Expand Down Expand Up @@ -313,14 +313,14 @@ we can now ask for specific encoder and decoder::

sage: Evect = C.encoder("EvaluationVector")
sage: Evect
Evaluation vector-style encoder for [40, 12, 29] Generalized Reed-Solomon Code over Finite Field of size 59
Evaluation vector-style encoder for [40, 12, 29] Generalized Reed-Solomon Code over GF(59)
sage: type(Evect)
<class 'sage.coding.grs.GRSEvaluationVectorEncoder'>
sage: msg = random_vector(GF(59), C.dimension()) #random
sage: c = Evect.encode(msg)
sage: NN = C.decoder("NearestNeighbor")
sage: NN
Nearest neighbor decoder for [40, 12, 29] Generalized Reed-Solomon Code over Finite Field of size 59
Nearest neighbor decoder for [40, 12, 29] Generalized Reed-Solomon Code over GF(59)

Calling::

Expand Down Expand Up @@ -359,7 +359,7 @@ let us investigate the one we left behind in the part just before::

sage: Epoly = C.encoder("EvaluationPolynomial")
sage: Epoly
Evaluation polynomial-style encoder for [40, 12, 29] Generalized Reed-Solomon Code over Finite Field of size 59
Evaluation polynomial-style encoder for [40, 12, 29] Generalized Reed-Solomon Code over GF(59)
sage: Epoly.message_space()
Univariate Polynomial Ring in x over Finite Field of size 59
sage: msg_p = Epoly.message_space().random_element(degree=C.dimension()-1); msg_p #random
Expand Down
92 changes: 46 additions & 46 deletions src/sage/coding/code_constructions.py
Expand Up @@ -13,7 +13,7 @@
All codes available here can be accessed through the ``codes`` object::
sage: codes.BinaryGolayCode()
Linear code of length 23, dimension 12 over Finite Field of size 2
[23, 12] linear code over GF(2)
REFERENCES:
Expand Down Expand Up @@ -362,7 +362,7 @@ def walsh_matrix(m0):
[0 0 1 1 0 0 1 1]
[0 1 0 1 0 1 0 1]
sage: C = LinearCode(walsh_matrix(4)); C
Linear code of length 16, dimension 4 over Finite Field of size 2
[16, 4] linear code over GF(2)
sage: C.spectrum()
[1, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0]
Expand Down Expand Up @@ -419,19 +419,19 @@ def BCHCode(n,delta,F,b=0):
sage: g.divides(f)
True
sage: C = codes.CyclicCode(8,g); C
Linear code of length 8, dimension 4 over Finite Field of size 3
[8, 4] linear code over GF(3)
sage: C.minimum_distance()
4
sage: C = codes.BCHCode(8,3,GF(3),1); C
Linear code of length 8, dimension 4 over Finite Field of size 3
[8, 4] linear code over GF(3)
sage: C.minimum_distance()
4
sage: C = codes.BCHCode(8,3,GF(3)); C
Linear code of length 8, dimension 5 over Finite Field of size 3
[8, 5] linear code over GF(3)
sage: C.minimum_distance()
3
sage: C = codes.BCHCode(26, 5, GF(5), b=1); C
Linear code of length 26, dimension 10 over Finite Field of size 5
[26, 10] linear code over GF(5)
"""
q = F.order()
Expand Down Expand Up @@ -465,7 +465,7 @@ def BinaryGolayCode():
sage: C = codes.BinaryGolayCode()
sage: C
Linear code of length 23, dimension 12 over Finite Field of size 2
[23, 12] linear code over GF(2)
sage: C.minimum_distance()
7
sage: C.minimum_distance(algorithm='gap') # long time, check d=7
Expand Down Expand Up @@ -512,23 +512,23 @@ def CyclicCodeFromGeneratingPolynomial(n,g,ignore=True):
sage: P.<x> = PolynomialRing(GF(3),"x")
sage: g = x-1
sage: C = codes.CyclicCodeFromGeneratingPolynomial(4,g); C
Linear code of length 4, dimension 3 over Finite Field of size 3
[4, 3] linear code over GF(3)
sage: P.<x> = PolynomialRing(GF(4,"a"),"x")
sage: g = x^3+1
sage: C = codes.CyclicCodeFromGeneratingPolynomial(9,g); C
Linear code of length 9, dimension 6 over Finite Field in a of size 2^2
[9, 6] linear code over GF(4)
sage: P.<x> = PolynomialRing(GF(2),"x")
sage: g = x^3+x+1
sage: C = codes.CyclicCodeFromGeneratingPolynomial(7,g); C
Linear code of length 7, dimension 4 over Finite Field of size 2
[7, 4] linear code over GF(2)
sage: C.generator_matrix()
[1 1 0 1 0 0 0]
[0 1 1 0 1 0 0]
[0 0 1 1 0 1 0]
[0 0 0 1 1 0 1]
sage: g = x+1
sage: C = codes.CyclicCodeFromGeneratingPolynomial(4,g); C
Linear code of length 4, dimension 3 over Finite Field of size 2
[4, 3] linear code over GF(2)
sage: C.generator_matrix()
[1 1 0 0]
[0 1 1 0]
Expand All @@ -552,7 +552,7 @@ def CyclicCodeFromGeneratingPolynomial(n,g,ignore=True):
sage: P.<x> = PolynomialRing(GF(3),"x")
sage: g = x^2-1
sage: C = codes.CyclicCodeFromGeneratingPolynomial(5,g); C
Linear code of length 5, dimension 4 over Finite Field of size 3
[5, 4] linear code over GF(3)
followed by C = CyclicCodeFromGeneratingPolynomial(5,g,False), with
a traceback message including "`x^2 + 2` must divide
Expand Down Expand Up @@ -592,9 +592,9 @@ def CyclicCodeFromCheckPolynomial(n,h,ignore=True):
sage: P.<x> = PolynomialRing(GF(3),"x")
sage: C = codes.CyclicCodeFromCheckPolynomial(4,x + 1); C
Linear code of length 4, dimension 1 over Finite Field of size 3
[4, 1] linear code over GF(3)
sage: C = codes.CyclicCodeFromCheckPolynomial(4,x^3 + x^2 + x + 1); C
Linear code of length 4, dimension 3 over Finite Field of size 3
[4, 3] linear code over GF(3)
sage: C.generator_matrix()
[2 1 0 0]
[0 2 1 0]
Expand Down Expand Up @@ -634,8 +634,8 @@ def DuadicCodeEvenPair(F,S1,S2):
sage: _is_a_splitting(S1,S2,11)
True
sage: codes.DuadicCodeEvenPair(GF(q),S1,S2)
(Linear code of length 11, dimension 5 over Finite Field of size 3,
Linear code of length 11, dimension 5 over Finite Field of size 3)
([11, 5] linear code over GF(3),
[11, 5] linear code over GF(3))
"""
n = len(S1) + len(S2) + 1
if not _is_a_splitting(S1,S2,n):
Expand Down Expand Up @@ -678,8 +678,8 @@ def DuadicCodeOddPair(F,S1,S2):
sage: _is_a_splitting(S1,S2,11)
True
sage: codes.DuadicCodeOddPair(GF(q),S1,S2)
(Linear code of length 11, dimension 6 over Finite Field of size 3,
Linear code of length 11, dimension 6 over Finite Field of size 3)
([11, 6] linear code over GF(3),
[11, 6] linear code over GF(3))
This is consistent with Theorem 6.1.3 in [HP2003]_.
"""
Expand Down Expand Up @@ -716,7 +716,7 @@ def ExtendedBinaryGolayCode():
sage: C = codes.ExtendedBinaryGolayCode()
sage: C
Linear code of length 24, dimension 12 over Finite Field of size 2
[24, 12] linear code over GF(2)
sage: C.minimum_distance()
8
sage: C.minimum_distance(algorithm='gap') # long time, check d=8
Expand Down Expand Up @@ -767,12 +767,12 @@ def ExtendedQuadraticResidueCode(n,F):
sage: C1 = codes.QuadraticResidueCode(7,GF(2))
sage: C2 = C1.extended_code()
sage: C3 = codes.ExtendedQuadraticResidueCode(7,GF(2)); C3
Extended code coming from Linear code of length 7, dimension 4 over Finite Field of size 2
Extension of [7, 4] linear code over GF(2)
sage: C2 == C3
True
sage: C = codes.ExtendedQuadraticResidueCode(17,GF(2))
sage: C
Extended code coming from Linear code of length 17, dimension 9 over Finite Field of size 2
Extension of [17, 9] linear code over GF(2)
sage: C3 = codes.QuadraticResidueCodeOddPair(7,GF(2))[0]
sage: C3x = C3.extended_code()
sage: C4 = codes.ExtendedQuadraticResidueCode(7,GF(2))
Expand All @@ -795,7 +795,7 @@ def ExtendedTernaryGolayCode():
sage: C = codes.ExtendedTernaryGolayCode()
sage: C
Linear code of length 12, dimension 6 over Finite Field of size 3
[12, 6] linear code over GF(3)
sage: C.minimum_distance()
6
sage: C.minimum_distance(algorithm='gap') # long time, check d=6
Expand Down Expand Up @@ -826,13 +826,13 @@ def from_parity_check_matrix(H):
EXAMPLES::
sage: C = codes.HammingCode(GF(2), 3); C
[7, 4] Hamming Code over Finite Field of size 2
[7, 4] Hamming Code over GF(2)
sage: H = C.parity_check_matrix(); H
[1 0 1 0 1 0 1]
[0 1 1 0 0 1 1]
[0 0 0 1 1 1 1]
sage: C2 = codes.from_parity_check_matrix(H); C2
Linear code of length 7, dimension 4 over Finite Field of size 2
[7, 4] linear code over GF(2)
sage: C2.systematic_generator_matrix() == C.systematic_generator_matrix()
True
"""
Expand Down Expand Up @@ -868,10 +868,10 @@ def QuadraticResidueCode(n,F):
sage: C = codes.QuadraticResidueCode(7,GF(2))
sage: C
Linear code of length 7, dimension 4 over Finite Field of size 2
[7, 4] linear code over GF(2)
sage: C = codes.QuadraticResidueCode(17,GF(2))
sage: C
Linear code of length 17, dimension 9 over Finite Field of size 2
[17, 9] linear code over GF(2)
sage: C1 = codes.QuadraticResidueCodeOddPair(7,GF(2))[0]
sage: C2 = codes.QuadraticResidueCode(7,GF(2))
sage: C1 == C2
Expand Down Expand Up @@ -902,14 +902,14 @@ def QuadraticResidueCodeEvenPair(n,F):
EXAMPLES::
sage: codes.QuadraticResidueCodeEvenPair(17,GF(13))
(Linear code of length 17, dimension 8 over Finite Field of size 13,
Linear code of length 17, dimension 8 over Finite Field of size 13)
([17, 8] linear code over GF(13),
[17, 8] linear code over GF(13))
sage: codes.QuadraticResidueCodeEvenPair(17,GF(2))
(Linear code of length 17, dimension 8 over Finite Field of size 2,
Linear code of length 17, dimension 8 over Finite Field of size 2)
([17, 8] linear code over GF(2),
[17, 8] linear code over GF(2))
sage: codes.QuadraticResidueCodeEvenPair(13,GF(9,"z"))
(Linear code of length 13, dimension 6 over Finite Field in z of size 3^2,
Linear code of length 13, dimension 6 over Finite Field in z of size 3^2)
([13, 6] linear code over GF(9),
[13, 6] linear code over GF(9))
sage: C1,C2 = codes.QuadraticResidueCodeEvenPair(7,GF(2))
sage: C1.is_self_orthogonal()
True
Expand Down Expand Up @@ -966,14 +966,14 @@ def QuadraticResidueCodeOddPair(n,F):
EXAMPLES::
sage: codes.QuadraticResidueCodeOddPair(17,GF(13))
(Linear code of length 17, dimension 9 over Finite Field of size 13,
Linear code of length 17, dimension 9 over Finite Field of size 13)
([17, 9] linear code over GF(13),
[17, 9] linear code over GF(13))
sage: codes.QuadraticResidueCodeOddPair(17,GF(2))
(Linear code of length 17, dimension 9 over Finite Field of size 2,
Linear code of length 17, dimension 9 over Finite Field of size 2)
([17, 9] linear code over GF(2),
[17, 9] linear code over GF(2))
sage: codes.QuadraticResidueCodeOddPair(13,GF(9,"z"))
(Linear code of length 13, dimension 7 over Finite Field in z of size 3^2,
Linear code of length 13, dimension 7 over Finite Field in z of size 3^2)
([13, 7] linear code over GF(9),
[13, 7] linear code over GF(9))
sage: C1 = codes.QuadraticResidueCodeOddPair(17,GF(2))[1]
sage: C1x = C1.extended_code()
sage: C2 = codes.QuadraticResidueCodeOddPair(17,GF(2))[0]
Expand Down Expand Up @@ -1025,7 +1025,7 @@ def random_linear_code(F, length, dimension):
sage: C = codes.random_linear_code(GF(2), 10, 3)
sage: C
Linear code of length 10, dimension 3 over Finite Field of size 2
[10, 3] linear code over GF(2)
sage: C.generator_matrix().rank()
3
"""
Expand All @@ -1044,7 +1044,7 @@ def RandomLinearCode(n, k, F):
doctest:...: DeprecationWarning: codes.RandomLinearCode(n, k, F) is deprecated. Please use codes.random_linear_code(F, n, k) instead
See http://trac.sagemath.org/21165 for details.
sage: C
Linear code of length 10, dimension 3 over Finite Field of size 2
[10, 3] linear code over GF(2)
sage: C.generator_matrix().rank()
3
"""
Expand Down Expand Up @@ -1079,7 +1079,7 @@ def TernaryGolayCode():
sage: C = codes.TernaryGolayCode()
sage: C
Linear code of length 11, dimension 6 over Finite Field of size 3
[11, 6] linear code over GF(3)
sage: C.minimum_distance()
5
sage: C.minimum_distance(algorithm='gap') # long time, check d=5
Expand Down Expand Up @@ -1137,17 +1137,17 @@ def ToricCode(P,F):
sage: C = codes.ToricCode([[0,0],[1,0],[2,0],[0,1],[1,1]],GF(7))
sage: C
Linear code of length 36, dimension 5 over Finite Field of size 7
[36, 5] linear code over GF(7)
sage: C.minimum_distance()
24
sage: C = codes.ToricCode([[-2,-2],[-1,-2],[-1,-1],[-1,0],[0,-1],[0,0],[0,1],[1,-1],[1,0]],GF(5))
sage: C
Linear code of length 16, dimension 9 over Finite Field of size 5
[16, 9] linear code over GF(5)
sage: C.minimum_distance()
6
sage: C = codes.ToricCode([ [0,0],[1,1],[1,2],[1,3],[1,4],[2,1],[2,2],[2,3],[3,1],[3,2],[4,1]],GF(8,"a"))
sage: C
Linear code of length 49, dimension 11 over Finite Field in a of size 2^3
[49, 11] linear code over GF(8)
This is in fact a [49,11,28] code over GF(8). If you type next
``C.minimum_distance()`` and wait overnight (!), you
Expand Down Expand Up @@ -1182,9 +1182,9 @@ def WalshCode(m):
EXAMPLES::
sage: C = codes.WalshCode(4); C
Linear code of length 16, dimension 4 over Finite Field of size 2
[16, 4] linear code over GF(2)
sage: C = codes.WalshCode(3); C
Linear code of length 8, dimension 3 over Finite Field of size 2
[8, 3] linear code over GF(2)
sage: C.spectrum()
[1, 0, 0, 0, 7, 0, 0, 0, 0]
sage: C.minimum_distance()
Expand Down

0 comments on commit a3b2b66

Please sign in to comment.