Skip to content

Commit 5409f5e

Browse files
Release Managervbraun
Release Manager
authored andcommittedAug 27, 2016
Trac #21331: Make Roth-Ruckenstein algorithm a method of polynomials
The coding part of Sage (see #18846) contains Roth-Ruckenstein algorithm to compute the roots of a polynomial `Q(y)` with coefficients in `F[x]` (where `F` is a finite field). The purpose of this ticket is to move the implementation to make this algorithm a method of polynomials. Toward this end, we also define a generic implementation for roots of univariate polynomials over univariate polynomial rings, that goes through their factorization. And this requires to implement the factorization for these "recursive" polynomial rings: Currently, the algorithm consists in flattening the recursive polynomial ring and use methods for multivariate polynomial rings. URL: https://trac.sagemath.org/21331 Reported by: bruno Ticket author(s): Bruno Grenet Reviewer(s): Turku Ozlum Celik
2 parents 98e4173 + 01378dc commit 5409f5e

File tree

5 files changed

+219
-391
lines changed

5 files changed

+219
-391
lines changed
 

‎src/doc/en/reference/coding/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ Linear codes and related constructions
3030
sage/coding/hamming_code
3131
sage/coding/guruswami_sudan/gs_decoder
3232
sage/coding/guruswami_sudan/interpolation
33-
sage/coding/guruswami_sudan/rootfinding
3433
sage/coding/guruswami_sudan/utils
3534
sage/coding/subfield_subcode
3635
sage/coding/code_constructions

‎src/sage/coding/guruswami_sudan/gs_decoder.py

+28-13
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from sage.rings.integer_ring import ZZ
3232
from sage.coding.decoder import Decoder
3333
from sage.coding.guruswami_sudan.interpolation import gs_interpolation_linalg, gs_interpolation_lee_osullivan
34-
from sage.coding.guruswami_sudan.rootfinding import rootfind_roth_ruckenstein
3534
from sage.coding.guruswami_sudan.utils import (johnson_radius,
3635
gilt,
3736
solve_degree2_to_integer_range)
@@ -85,6 +84,24 @@ def n_k_params(C, n_k):
8584
elif n_k is not None:
8685
return n_k
8786

87+
def roth_ruckenstein_root_finder(p, maxd=None, precision=None):
88+
"""
89+
Wrapper for Roth-Ruckenstein algorithm to compute the roots of a polynomial
90+
with coefficients in ``F[x]``.
91+
92+
TESTS::
93+
94+
sage: from sage.coding.guruswami_sudan.gs_decoder import roth_ruckenstein_root_finder
95+
sage: R.<x> = GF(13)[]
96+
sage: S.<y> = R[]
97+
sage: p = (y - x^2 - x - 1) * (y + x + 1)
98+
sage: roth_ruckenstein_root_finder(p, maxd = 2)
99+
[12*x + 12, x^2 + x + 1]
100+
"""
101+
gens = p.parent().gens()
102+
if len(gens) == 2:
103+
p = p.polynomial(gens[1])
104+
return p.roots(multiplicities=False, degree_bound=maxd, algorithm="Roth-Ruckenstein")
88105

89106
class GRSGuruswamiSudanDecoder(Decoder):
90107
r"""
@@ -155,8 +172,7 @@ class GRSGuruswamiSudanDecoder(Decoder):
155172
``my_rootfinder(Q, maxd=default_value, precision=default_value)``. `Q`
156173
will be given as an element of `F[x][y]`. The function must return the
157174
roots as a list of polynomials over a univariate polynomial ring. See
158-
:meth:`sage.coding.guruswami_sudan.rootfinding.rootfind_roth_ruckenstein`
159-
for an example.
175+
:meth:`roth_ruckenstein_root_finder` for an example.
160176
161177
If one provides a function as ``interpolation_alg``, its signature has
162178
to be: ``my_inter(interpolation_points, tau, s_and_l, wy)``. See
@@ -178,8 +194,8 @@ class GRSGuruswamiSudanDecoder(Decoder):
178194
179195
One can pass a method as ``root_finder`` (works also for ``interpolation_alg``)::
180196
181-
sage: from sage.coding.guruswami_sudan.rootfinding import rootfind_roth_ruckenstein
182-
sage: rf = rootfind_roth_ruckenstein
197+
sage: from sage.coding.guruswami_sudan.gs_decoder import roth_ruckenstein_root_finder
198+
sage: rf = roth_ruckenstein_root_finder
183199
sage: D = codes.decoders.GRSGuruswamiSudanDecoder(C, parameters = (1,2), root_finder = rf)
184200
sage: D
185201
Guruswami-Sudan decoder for [250, 70, 181] Generalized Reed-Solomon Code over Finite Field of size 251 decoding 97 errors with parameters (1, 2)
@@ -189,8 +205,6 @@ class GRSGuruswamiSudanDecoder(Decoder):
189205
This works for ``interpolation_alg`` as well::
190206
191207
192-
sage: from sage.coding.guruswami_sudan.rootfinding import rootfind_roth_ruckenstein
193-
sage: rf = rootfind_roth_ruckenstein
194208
sage: D = codes.decoders.GRSGuruswamiSudanDecoder(C, parameters = (1,2), root_finder="RothRuckenstein")
195209
sage: D
196210
Guruswami-Sudan decoder for [250, 70, 181] Generalized Reed-Solomon Code over Finite Field of size 251 decoding 97 errors with parameters (1, 2)
@@ -576,7 +590,7 @@ def __init__(self, code, tau = None, parameters = None, interpolation_alg = None
576590
if hasattr(root_finder, '__call__'):
577591
self._root_finder = root_finder
578592
elif root_finder == None or root_finder == "RothRuckenstein":
579-
self._root_finder = rootfind_roth_ruckenstein
593+
self._root_finder = roth_ruckenstein_root_finder
580594
else:
581595
raise ValueError("Please provide a method or one of the allowed strings for root_finder")
582596
super(GRSGuruswamiSudanDecoder, self).__init__(code, code.ambient_space(), "EvaluationPolynomial")
@@ -640,8 +654,8 @@ def interpolation_algorithm(self):
640654
641655
sage: C = codes.GeneralizedReedSolomonCode(GF(251).list()[:250], 70)
642656
sage: D = C.decoder("GuruswamiSudan", tau = 97)
643-
sage: D.interpolation_algorithm() #random
644-
<function gs_interpolation_linalg at 0x7f9d55753500>
657+
sage: D.interpolation_algorithm()
658+
<function gs_interpolation_lee_osullivan at 0x...>
645659
"""
646660
return self._interpolation_alg
647661

@@ -651,15 +665,16 @@ def rootfinding_algorithm(self):
651665
652666
Remember that its signature has to be:
653667
``my_rootfinder(Q, maxd=default_value, precision=default_value)``.
654-
See :meth:`sage.coding.guruswami_sudan.rootfinding.rootfind_roth_ruckenstein`
668+
See :meth:`roth_ruckenstein_root_finder`
655669
for an example.
656670
657671
EXAMPLES::
658672
673+
sage: from sage.coding.guruswami_sudan.gs_decoder import roth_ruckenstein_root_finder
659674
sage: C = codes.GeneralizedReedSolomonCode(GF(251).list()[:250], 70)
660675
sage: D = C.decoder("GuruswamiSudan", tau = 97)
661-
sage: D.rootfinding_algorithm() #random
662-
<function rootfind_roth_ruckenstein at 0x7fea00618848>
676+
sage: D.rootfinding_algorithm()
677+
<function roth_ruckenstein_root_finder at 0x...>
663678
"""
664679
return self._root_finder
665680

0 commit comments

Comments
 (0)
Please sign in to comment.