31
31
from sage .rings .integer_ring import ZZ
32
32
from sage .coding .decoder import Decoder
33
33
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
35
34
from sage .coding .guruswami_sudan .utils import (johnson_radius ,
36
35
gilt ,
37
36
solve_degree2_to_integer_range )
@@ -85,6 +84,24 @@ def n_k_params(C, n_k):
85
84
elif n_k is not None :
86
85
return n_k
87
86
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" )
88
105
89
106
class GRSGuruswamiSudanDecoder (Decoder ):
90
107
r"""
@@ -155,8 +172,7 @@ class GRSGuruswamiSudanDecoder(Decoder):
155
172
``my_rootfinder(Q, maxd=default_value, precision=default_value)``. `Q`
156
173
will be given as an element of `F[x][y]`. The function must return the
157
174
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.
160
176
161
177
If one provides a function as ``interpolation_alg``, its signature has
162
178
to be: ``my_inter(interpolation_points, tau, s_and_l, wy)``. See
@@ -178,8 +194,8 @@ class GRSGuruswamiSudanDecoder(Decoder):
178
194
179
195
One can pass a method as ``root_finder`` (works also for ``interpolation_alg``)::
180
196
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
183
199
sage: D = codes.decoders.GRSGuruswamiSudanDecoder(C, parameters = (1,2), root_finder = rf)
184
200
sage: D
185
201
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):
189
205
This works for ``interpolation_alg`` as well::
190
206
191
207
192
- sage: from sage.coding.guruswami_sudan.rootfinding import rootfind_roth_ruckenstein
193
- sage: rf = rootfind_roth_ruckenstein
194
208
sage: D = codes.decoders.GRSGuruswamiSudanDecoder(C, parameters = (1,2), root_finder="RothRuckenstein")
195
209
sage: D
196
210
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
576
590
if hasattr (root_finder , '__call__' ):
577
591
self ._root_finder = root_finder
578
592
elif root_finder == None or root_finder == "RothRuckenstein" :
579
- self ._root_finder = rootfind_roth_ruckenstein
593
+ self ._root_finder = roth_ruckenstein_root_finder
580
594
else :
581
595
raise ValueError ("Please provide a method or one of the allowed strings for root_finder" )
582
596
super (GRSGuruswamiSudanDecoder , self ).__init__ (code , code .ambient_space (), "EvaluationPolynomial" )
@@ -640,8 +654,8 @@ def interpolation_algorithm(self):
640
654
641
655
sage: C = codes.GeneralizedReedSolomonCode(GF(251).list()[:250], 70)
642
656
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... >
645
659
"""
646
660
return self ._interpolation_alg
647
661
@@ -651,15 +665,16 @@ def rootfinding_algorithm(self):
651
665
652
666
Remember that its signature has to be:
653
667
``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 `
655
669
for an example.
656
670
657
671
EXAMPLES::
658
672
673
+ sage: from sage.coding.guruswami_sudan.gs_decoder import roth_ruckenstein_root_finder
659
674
sage: C = codes.GeneralizedReedSolomonCode(GF(251).list()[:250], 70)
660
675
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... >
663
678
"""
664
679
return self ._root_finder
665
680
0 commit comments