Skip to content

Commit

Permalink
Trac #21331: Make Roth-Ruckenstein algorithm a method of polynomials
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Release Manager authored and vbraun committed Aug 27, 2016
2 parents 98e4173 + 01378dc commit 5409f5e
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 391 deletions.
1 change: 0 additions & 1 deletion src/doc/en/reference/coding/index.rst
Expand Up @@ -30,7 +30,6 @@ Linear codes and related constructions
sage/coding/hamming_code
sage/coding/guruswami_sudan/gs_decoder
sage/coding/guruswami_sudan/interpolation
sage/coding/guruswami_sudan/rootfinding
sage/coding/guruswami_sudan/utils
sage/coding/subfield_subcode
sage/coding/code_constructions
Expand Down
41 changes: 28 additions & 13 deletions src/sage/coding/guruswami_sudan/gs_decoder.py
Expand Up @@ -31,7 +31,6 @@
from sage.rings.integer_ring import ZZ
from sage.coding.decoder import Decoder
from sage.coding.guruswami_sudan.interpolation import gs_interpolation_linalg, gs_interpolation_lee_osullivan
from sage.coding.guruswami_sudan.rootfinding import rootfind_roth_ruckenstein
from sage.coding.guruswami_sudan.utils import (johnson_radius,
gilt,
solve_degree2_to_integer_range)
Expand Down Expand Up @@ -85,6 +84,24 @@ def n_k_params(C, n_k):
elif n_k is not None:
return n_k

def roth_ruckenstein_root_finder(p, maxd=None, precision=None):
"""
Wrapper for Roth-Ruckenstein algorithm to compute the roots of a polynomial
with coefficients in ``F[x]``.
TESTS::
sage: from sage.coding.guruswami_sudan.gs_decoder import roth_ruckenstein_root_finder
sage: R.<x> = GF(13)[]
sage: S.<y> = R[]
sage: p = (y - x^2 - x - 1) * (y + x + 1)
sage: roth_ruckenstein_root_finder(p, maxd = 2)
[12*x + 12, x^2 + x + 1]
"""
gens = p.parent().gens()
if len(gens) == 2:
p = p.polynomial(gens[1])
return p.roots(multiplicities=False, degree_bound=maxd, algorithm="Roth-Ruckenstein")

class GRSGuruswamiSudanDecoder(Decoder):
r"""
Expand Down Expand Up @@ -155,8 +172,7 @@ class GRSGuruswamiSudanDecoder(Decoder):
``my_rootfinder(Q, maxd=default_value, precision=default_value)``. `Q`
will be given as an element of `F[x][y]`. The function must return the
roots as a list of polynomials over a univariate polynomial ring. See
:meth:`sage.coding.guruswami_sudan.rootfinding.rootfind_roth_ruckenstein`
for an example.
:meth:`roth_ruckenstein_root_finder` for an example.
If one provides a function as ``interpolation_alg``, its signature has
to be: ``my_inter(interpolation_points, tau, s_and_l, wy)``. See
Expand All @@ -178,8 +194,8 @@ class GRSGuruswamiSudanDecoder(Decoder):
One can pass a method as ``root_finder`` (works also for ``interpolation_alg``)::
sage: from sage.coding.guruswami_sudan.rootfinding import rootfind_roth_ruckenstein
sage: rf = rootfind_roth_ruckenstein
sage: from sage.coding.guruswami_sudan.gs_decoder import roth_ruckenstein_root_finder
sage: rf = roth_ruckenstein_root_finder
sage: D = codes.decoders.GRSGuruswamiSudanDecoder(C, parameters = (1,2), root_finder = rf)
sage: D
Guruswami-Sudan decoder for [250, 70, 181] Generalized Reed-Solomon Code over Finite Field of size 251 decoding 97 errors with parameters (1, 2)
Expand All @@ -189,8 +205,6 @@ class GRSGuruswamiSudanDecoder(Decoder):
This works for ``interpolation_alg`` as well::
sage: from sage.coding.guruswami_sudan.rootfinding import rootfind_roth_ruckenstein
sage: rf = rootfind_roth_ruckenstein
sage: D = codes.decoders.GRSGuruswamiSudanDecoder(C, parameters = (1,2), root_finder="RothRuckenstein")
sage: D
Guruswami-Sudan decoder for [250, 70, 181] Generalized Reed-Solomon Code over Finite Field of size 251 decoding 97 errors with parameters (1, 2)
Expand Down Expand Up @@ -576,7 +590,7 @@ def __init__(self, code, tau = None, parameters = None, interpolation_alg = None
if hasattr(root_finder, '__call__'):
self._root_finder = root_finder
elif root_finder == None or root_finder == "RothRuckenstein":
self._root_finder = rootfind_roth_ruckenstein
self._root_finder = roth_ruckenstein_root_finder
else:
raise ValueError("Please provide a method or one of the allowed strings for root_finder")
super(GRSGuruswamiSudanDecoder, self).__init__(code, code.ambient_space(), "EvaluationPolynomial")
Expand Down Expand Up @@ -640,8 +654,8 @@ def interpolation_algorithm(self):
sage: C = codes.GeneralizedReedSolomonCode(GF(251).list()[:250], 70)
sage: D = C.decoder("GuruswamiSudan", tau = 97)
sage: D.interpolation_algorithm() #random
<function gs_interpolation_linalg at 0x7f9d55753500>
sage: D.interpolation_algorithm()
<function gs_interpolation_lee_osullivan at 0x...>
"""
return self._interpolation_alg

Expand All @@ -651,15 +665,16 @@ def rootfinding_algorithm(self):
Remember that its signature has to be:
``my_rootfinder(Q, maxd=default_value, precision=default_value)``.
See :meth:`sage.coding.guruswami_sudan.rootfinding.rootfind_roth_ruckenstein`
See :meth:`roth_ruckenstein_root_finder`
for an example.
EXAMPLES::
sage: from sage.coding.guruswami_sudan.gs_decoder import roth_ruckenstein_root_finder
sage: C = codes.GeneralizedReedSolomonCode(GF(251).list()[:250], 70)
sage: D = C.decoder("GuruswamiSudan", tau = 97)
sage: D.rootfinding_algorithm() #random
<function rootfind_roth_ruckenstein at 0x7fea00618848>
sage: D.rootfinding_algorithm()
<function roth_ruckenstein_root_finder at 0x...>
"""
return self._root_finder

Expand Down

0 comments on commit 5409f5e

Please sign in to comment.