Skip to content

Commit 86045cd

Browse files
author
Release Manager
committed
gh-39103: Bugfix for erasure decoder of Reed-Solomon codes <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> This PR fixes issue #38918. The decoder that was called did not correspond to the punctured codeword that requires to be unencoded; this has been fixed. All tests pass, including the minimal example provided in the issue. I also fixed a minor bug for the computation of the decoding radius in case of a maximal number of erasures. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> #38918: raised issue URL: #39103 Reported by: Julien Lavauzelle Reviewer(s): Travis Scrimshaw
2 parents 2ce5e7c + 294c4d6 commit 86045cd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/sage/coding/grs_code.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,12 @@ def decode_to_message(self, word_and_erasure_vector):
19151915
sage: y = Chan(c)
19161916
sage: D.connected_encoder().unencode(c) == D.decode_to_message(y)
19171917
True
1918+
sage: n_era = C.minimum_distance() - 1
1919+
sage: Chan = channels.ErrorErasureChannel(C.ambient_space(),
1920+
....: D.decoding_radius(n_era), n_era)
1921+
sage: y = Chan(c)
1922+
sage: D.connected_encoder().unencode(c) == D.decode_to_message(y)
1923+
True
19181924
19191925
TESTS:
19201926
@@ -1958,14 +1964,14 @@ def decode_to_message(self, word_and_erasure_vector):
19581964
[word[i] for i in range(len(word))
19591965
if not erasure_vector[i]])
19601966
C1_length = len(punctured_word)
1961-
if C1_length == k:
1962-
return self.connected_encoder().unencode_nocheck(word)
19631967
C1_evaluation_points = [self.code().evaluation_points()[i] for i in
19641968
range(n) if erasure_vector[i] != 1]
19651969
C1_column_multipliers = [self.code().column_multipliers()[i] for i in
19661970
range(n) if erasure_vector[i] != 1]
19671971
C1 = GeneralizedReedSolomonCode(C1_evaluation_points, k,
19681972
C1_column_multipliers)
1973+
if C1_length == k:
1974+
return C1.unencode(punctured_word, nocheck=True)
19691975
return C1.decode_to_message(punctured_word)
19701976

19711977
def decoding_radius(self, number_erasures):
@@ -1997,7 +2003,7 @@ def decoding_radius(self, number_erasures):
19972003
ValueError: The number of erasures exceed decoding capability
19982004
"""
19992005
diff = self.code().minimum_distance() - 1 - number_erasures
2000-
if diff <= 0:
2006+
if diff < 0:
20012007
raise ValueError("The number of erasures exceed decoding capability")
20022008
else:
20032009
return diff // 2

0 commit comments

Comments
 (0)