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

Commit

Permalink
Remove relative_finite_field_extension
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed May 28, 2021
1 parent 6aa4ece commit 0a05cd4
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 627 deletions.
7 changes: 0 additions & 7 deletions src/doc/en/reference/coding/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,4 @@ There is at least one module in Sage for source coding in communications theory:

sage/coding/source_coding/huffman

Finally an experimental module used for code constructions:

.. toctree::
:maxdepth: 1

sage/coding/relative_finite_field_extension

.. include:: ../footer.txt
28 changes: 4 additions & 24 deletions src/sage/coding/bch_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,6 @@
codewords `c(x) \in F[x]` satisfy `c(\alpha^{a}) = 0`, for all integers `a` in
the arithmetic sequence `b, b + \ell, b + 2 \times \ell, \dots, b + (\delta -
2) \times \ell`.
TESTS:
This class uses the following experimental feature:
:class:`sage.coding.relative_finite_field_extension.RelativeFiniteFieldExtension`.
This test block is here only to trigger the experimental warning so it does not
interferes with doctests::
sage: from sage.coding.relative_finite_field_extension import *
sage: Fqm.<aa> = GF(16)
sage: Fq.<a> = GF(4)
sage: RelativeFiniteFieldExtension(Fqm, Fq)
doctest:...: FutureWarning: This class/method/function is marked as
experimental. It, its functionality or its interface might change without a
formal deprecation.
See http://trac.sagemath.org/20284 for details.
Relative field extension between Finite Field in aa of size 2^4 and Finite
Field in a of size 2^2
"""
# *****************************************************************************
# Copyright (C) 2016 David Lucas <[email protected]>
Expand Down Expand Up @@ -411,9 +393,8 @@ def bch_word_to_grs(self, c):
sage: y in D.grs_code()
True
"""
mapping = self.code().field_embedding().embedding()
a = map(mapping, c)
return vector(a)
phi = self.code().field_embedding()
return vector([phi(x) for x in c])

def grs_word_to_bch(self, c):
r"""
Expand All @@ -431,9 +412,8 @@ def grs_word_to_bch(self, c):
(0, a, 1, a, 0, 1, 1, 1, a, 0, 0, a + 1, a, 0, 1)
"""
C = self.code()
FE = C.field_embedding()
a = map(FE.cast_into_relative_field, c)
return vector(a)
sec = C.field_embedding().section()
return vector([sec(x) for x in c])

def decode_to_code(self, y):
r"""
Expand Down
45 changes: 15 additions & 30 deletions src/sage/coding/cyclic_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@
For now, only single-root cyclic codes (i.e. whose length `n` and field order
`q` are coprimes) are implemented.
TESTS:
This class uses the following experimental feature:
:class:`sage.coding.relative_finite_field_extension.RelativeFiniteFieldExtension`.
This test block is here only to trigger the experimental warning so it does not
interferes with doctests::
sage: from sage.coding.relative_finite_field_extension import *
sage: Fqm.<aa> = GF(16)
sage: Fq.<a> = GF(4)
sage: RelativeFiniteFieldExtension(Fqm, Fq)
doctest:...: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation.
See http://trac.sagemath.org/20284 for details.
Relative field extension between Finite Field in aa of size 2^4 and Finite Field in a of size 2^2
"""

# *****************************************************************************
Expand All @@ -55,13 +40,12 @@
from .decoder import Decoder
from copy import copy
from sage.rings.integer import Integer
from sage.categories.homset import Hom
from sage.arith.all import gcd
from sage.modules.free_module_element import vector
from sage.matrix.constructor import matrix
from sage.misc.cachefunc import cached_method
from sage.rings.all import Zmod
from .relative_finite_field_extension import RelativeFiniteFieldExtension


def find_generator_polynomial(code, check=True):
r"""
Expand Down Expand Up @@ -437,19 +421,18 @@ def __init__(self, generator_pol=None, length=None, code=None, check=True,
if primitive_root is not None:
Fsplit = primitive_root.parent()
try:
FE = RelativeFiniteFieldExtension(Fsplit, F)
FE = Hom(F, Fsplit)[0]
except Exception:
raise ValueError("primitive_root must belong to an "
"extension of the base field")
if (FE.extension_degree() != s or
extension_degree = Fsplit.degree() // F.degree()
if (extension_degree != s or
primitive_root.multiplicative_order() != n):
raise ValueError("primitive_root must be a primitive "
"n-th root of unity")
alpha = primitive_root
else:
Fsplit, F_to_Fsplit = F.extension(Integer(s), map=True)
FE = RelativeFiniteFieldExtension(Fsplit, F,
embedding=F_to_Fsplit)
Fsplit, FE = F.extension(Integer(s), map=True)
alpha = Fsplit.zeta(n)

Rsplit = Fsplit['xx']
Expand All @@ -458,12 +441,13 @@ def __init__(self, generator_pol=None, length=None, code=None, check=True,
cosets = Zmod(n).cyclotomic_cosets(q, D)
pows = [item for l in cosets for item in l]

sec = FE.section()
g = R.one()
for J in cosets:
pol = Rsplit.one()
for j in J:
pol *= xx - alpha**j
g *= R([FE.cast_into_relative_field(coeff) for coeff in pol])
g *= R([sec(coeff) for coeff in pol])

# we set class variables
self._field_embedding = FE
Expand Down Expand Up @@ -587,7 +571,10 @@ def field_embedding(self):
sage: g = x ** 3 + x + 1
sage: C = codes.CyclicCode(generator_pol=g, length=n)
sage: C.field_embedding()
Relative field extension between Finite Field in z3 of size 2^3 and Finite Field of size 2
Ring morphism:
From: Finite Field of size 2
To: Finite Field in z3 of size 2^3
Defn: 1 |--> 1
"""
if not(hasattr(self, "_field_embedding")):
self.defining_set()
Expand Down Expand Up @@ -661,16 +648,13 @@ def defining_set(self, primitive_root=None):
s = Zmod(n)(q).multiplicative_order()

if primitive_root is None:
Fsplit, F_to_Fsplit = F.extension(Integer(s), map=True)
FE = RelativeFiniteFieldExtension(Fsplit, F,
embedding=F_to_Fsplit)
Fsplit, FE = F.extension(Integer(s), map=True)
alpha = Fsplit.zeta(n)
else:
try:
alpha = primitive_root
Fsplit = alpha.parent()
FE = RelativeFiniteFieldExtension(Fsplit, F)
F_to_Fsplit = FE.embedding()
FE = Hom(Fsplit, F)[0]
except ValueError:
raise ValueError("primitive_root does not belong to the "
"right splitting field")
Expand All @@ -679,9 +663,10 @@ def defining_set(self, primitive_root=None):
"order equal to the code length")

Rsplit = Fsplit['xx']
gsplit = Rsplit([F_to_Fsplit(coeff) for coeff in g])
gsplit = Rsplit([FE(coeff) for coeff in g])
roots = gsplit.roots(multiplicities=False)
D = [root.log(alpha) for root in roots]

self._field_embedding = FE
self._primitive_root = alpha
self._defining_set = sorted(D)
Expand Down
14 changes: 0 additions & 14 deletions src/sage/coding/linear_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,20 +344,6 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
It is thus strongly recommended to set an encoder with a generator matrix implemented
as a default encoder.
TESTS:
This class uses the following experimental feature:
:class:`sage.coding.relative_finite_field_extension.RelativeFiniteFieldExtension`.
This test block is here only to trigger the experimental warning so it does not
interferes with doctests::
sage: from sage.coding.relative_finite_field_extension import *
sage: Fqm.<aa> = GF(16)
sage: Fq.<a> = GF(4)
sage: RelativeFiniteFieldExtension(Fqm, Fq)
doctest:...: FutureWarning: This class/method/function is marked as experimental. It, its functionality or its interface might change without a formal deprecation.
See http://trac.sagemath.org/20284 for details.
Relative field extension between Finite Field in aa of size 2^4 and Finite Field in a of size 2^2
"""
_registered_encoders = {}
_registered_decoders = {}
Expand Down
Loading

0 comments on commit 0a05cd4

Please sign in to comment.