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

Commit

Permalink
Merged latest version of #20835 and fixed conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lucas committed Jun 29, 2016
2 parents 83cb47a + 6d01e05 commit bb41e21
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/doc/en/thematic_tutorials/coding_theory.rst
Expand Up @@ -297,7 +297,7 @@ Let us see how one can explore this::

sage: C = codes.GeneralizedReedSolomonCode(GF(59).list()[:40], 12, GF(59).list()[1:41])
sage: C.encoders_available()
['EvaluationPolynomial', 'EvaluationVector', 'Systematic', 'ParityCheck']
['EvaluationPolynomial', 'EvaluationVector', 'Systematic']
sage: C.decoders_available()
['Syndrome',
'NearestNeighbor',
Expand Down
4 changes: 1 addition & 3 deletions src/sage/coding/grs.py
Expand Up @@ -38,9 +38,7 @@
from sage.rings.integer import Integer
from sage.misc.cachefunc import cached_method
from copy import copy
from linear_code import (AbstractLinearCode,
LinearCodeSyndromeDecoder,
LinearCodeNearestNeighborDecoder)
from linear_code import AbstractLinearCode
from encoder import Encoder
from decoder import Decoder, DecodingError
from sage.rings.arith import xgcd
Expand Down
9 changes: 6 additions & 3 deletions src/sage/coding/hamming_code.py
Expand Up @@ -22,9 +22,7 @@
#*****************************************************************************

from linear_code import (AbstractLinearCode,
LinearCodeParityCheckEncoder,
LinearCodeSyndromeDecoder,
LinearCodeNearestNeighborDecoder)
LinearCodeParityCheckEncoder)
from sage.matrix.matrix_space import MatrixSpace
from sage.schemes.projective.projective_space import ProjectiveSpace
from sage.rings.integer import Integer
Expand Down Expand Up @@ -169,3 +167,8 @@ def minimum_distance(self):
3
"""
return 3


####################### registration ###############################

HammingCode._registered_encoders["ParityCheck"] = LinearCodeParityCheckEncoder
18 changes: 12 additions & 6 deletions src/sage/coding/linear_code.py
Expand Up @@ -806,7 +806,6 @@ def __init__(self, base_field, length, default_encoder_name, default_decoder_nam
### Add here any generic encoder/decoder ###
#This allows any class which inherits from AbstractLinearCode
#to use generic decoders/encoders
self._registered_encoders["ParityCheck"] = LinearCodeParityCheckEncoder
self._registered_encoders["Systematic"] = LinearCodeSystematicEncoder
self._registered_decoders["Syndrome"] = LinearCodeSyndromeDecoder
self._registered_decoders["NearestNeighbor"] = LinearCodeNearestNeighborDecoder
Expand Down Expand Up @@ -1912,7 +1911,7 @@ def encode(self, word, encoder_name=None, **kwargs):
It is possible to manually choose the encoder amongst the list of the available ones::
sage: C.encoders_available()
['GeneratorMatrix', 'Systematic', 'ParityCheck']
['GeneratorMatrix', 'Systematic']
sage: word = vector((0, 1, 1, 0))
sage: C.encode(word, 'GeneratorMatrix')
(1, 1, 0, 0, 1, 1, 0)
Expand Down Expand Up @@ -1965,7 +1964,7 @@ def encoder(self, encoder_name=None, **kwargs):
an exception will be raised::
sage: C.encoders_available()
['GeneratorMatrix', 'Systematic', 'ParityCheck']
['GeneratorMatrix', 'Systematic']
sage: C.encoder('NonExistingEncoder')
Traceback (most recent call last):
...
Expand Down Expand Up @@ -1994,10 +1993,9 @@ def encoders_available(self, classes=False):
sage: G = Matrix(GF(2), [[1,1,1,0,0,0,0],[1,0,0,1,1,0,0],[0,1,0,1,0,1,0],[1,1,0,1,0,0,1]])
sage: C = LinearCode(G)
sage: C.encoders_available()
['GeneratorMatrix', 'Systematic', 'ParityCheck']
['GeneratorMatrix', 'Systematic']
sage: C.encoders_available(True)
{'GeneratorMatrix': <class 'sage.coding.linear_code.LinearCodeGeneratorMatrixEncoder'>,
'ParityCheck': <class 'sage.coding.linear_code.LinearCodeParityCheckEncoder'>,
'Systematic': <class 'sage.coding.linear_code.LinearCodeSystematicEncoder'>}
"""
if classes == True:
Expand Down Expand Up @@ -4006,6 +4004,8 @@ def __init__(self, code):
sage: G = Matrix(GF(2), [[1,1,1,0,0,0,0],[1,0,0,1,1,0,0],[0,1,0,1,0,1,0],[1,1,0,1,0,0,1]])
sage: C = LinearCode(G)
sage: E = codes.encoders.LinearCodeParityCheckEncoder(C)
doctest:...: DeprecationWarning: LinearCodeParityCheckEncoder is now deprecated. Please use LinearCodeSystematicEncoder instead.
See http://trac.sagemath.org/20835 for details.
sage: E
Parity check matrix-based encoder for Linear code of length 7, dimension 4 over Finite Field of size 2
"""
Expand All @@ -4022,6 +4022,8 @@ def _repr_(self):
sage: G = Matrix(GF(2), [[1,1,1,0,0,0,0],[1,0,0,1,1,0,0],[0,1,0,1,0,1,0],[1,1,0,1,0,0,1]])
sage: C = LinearCode(G)
sage: E = codes.encoders.LinearCodeParityCheckEncoder(C)
doctest:...: DeprecationWarning: LinearCodeParityCheckEncoder is now deprecated. Please use LinearCodeSystematicEncoder instead.
See http://trac.sagemath.org/20835 for details.
sage: E
Parity check matrix-based encoder for Linear code of length 7, dimension 4 over Finite Field of size 2
"""
Expand All @@ -4036,6 +4038,8 @@ def _latex_(self):
sage: G = Matrix(GF(2), [[1,1,1,0,0,0,0],[1,0,0,1,1,0,0],[0,1,0,1,0,1,0],[1,1,0,1,0,0,1]])
sage: C = LinearCode(G)
sage: E = codes.encoders.LinearCodeParityCheckEncoder(C)
doctest:...: DeprecationWarning: LinearCodeParityCheckEncoder is now deprecated. Please use LinearCodeSystematicEncoder instead.
See http://trac.sagemath.org/20835 for details.
sage: latex(E)
\textnormal{Parity check matrix-based encoder for }[7, 4]\textnormal{ Linear code over }\Bold{F}_{2}
"""
Expand All @@ -4051,6 +4055,8 @@ def generator_matrix(self):
sage: G = Matrix(GF(2), [[1,1,1,0,0,0,0],[1,0,0,1,1,0,0],[0,1,0,1,0,1,0],[1,1,0,1,0,0,1]])
sage: C = LinearCode(G)
sage: E = codes.encoders.LinearCodeParityCheckEncoder(C)
doctest:...: DeprecationWarning: LinearCodeParityCheckEncoder is now deprecated. Please use LinearCodeSystematicEncoder instead.
See http://trac.sagemath.org/20835 for details.
sage: E.generator_matrix()
[1 0 0 0 0 1 1]
[0 1 0 0 1 0 1]
Expand Down Expand Up @@ -4164,7 +4170,7 @@ def generator_matrix(self):
"""
C = self.code()
if hasattr(self, "_use_pc_matrix"):
return C.parity_check_matrix()
return C.parity_check_matrix().right_kernel_matrix()
else:
self._use_pc_matrix = True
M = C.generator_matrix()
Expand Down
4 changes: 1 addition & 3 deletions src/sage/coding/punctured_code.py
Expand Up @@ -16,9 +16,7 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from linear_code import (AbstractLinearCode,
LinearCodeSyndromeDecoder,
LinearCodeNearestNeighborDecoder)
from linear_code import AbstractLinearCode
from encoder import Encoder
from decoder import Decoder, DecodingError
from sage.misc.cachefunc import cached_method
Expand Down

0 comments on commit bb41e21

Please sign in to comment.