Skip to content

Fix the generalized Reed-Solomon interpolation decoder - #129

Merged
osj1961 merged 1 commit into
masterfrom
fix-grs-interpolation-decoder
Aug 17, 2026
Merged

Fix the generalized Reed-Solomon interpolation decoder#129
osj1961 merged 1 commit into
masterfrom
fix-grs-interpolation-decoder

Conversation

@fingolfin

@fingolfin fingolfin commented Aug 16, 2026

Copy link
Copy Markdown
Member

The interpolation step produces Q(x,y) = Q0(x) + Q1(x)*y vanishing at every (P[i],v[i]), so the message polynomial is f = -Q0/Q1. GeneralizedReedSolomonDecoder computed -Q1/Q0 instead and returned the evaluations of that unrelated rational function.

It also now returns an information word. Decode passes a special decoder's result through verbatim and is documented to return an information word, so returning a codeword made Decode fail outright (the reported symptom). That in turn exposed Decodeword re-encoding via c0*C, which for a cyclic code multiplies by the generator polynomial while InformationWord inverts the generator matrix; for a GRS code that happens to be cyclic the two disagree.

That second part is the last outstanding item of #126: GeneralizedReedSolomonDecoder was the only special decoder still returning a codeword rather than an information word. Checking both halves of the contract (Decode returns the information vector, Decodeword the nearest codeword) on words carrying errors, for every decoder that is actually installed via SetSpecialDecoder:

special decoder before after
HammingDecoder (GF(2), GF(3)) ok ok
BCHDecoder (RS/GF(11), BCH/GF(2), BCH/GF(3)) ok ok
CyclicDecoder (binary cyclic [7,4,3]) ok ok
GeneralizedReedSolomonDecoder (GF(11), GF(5)) dies, "Denominator evaluates as zero" ok

Hamming, BCH and cyclic were already put right by fc0434c, 6547003 and 94a9c9d.

Fixes #12
Fixes #126

Co-Authored-By: Claude Opus 5 noreply@anthropic.com

@codecov

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 47.25%. Comparing base (500c2bd) to head (a1db600).

Files with missing lines Patch % Lines
lib/decoders.gi 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #129      +/-   ##
==========================================
- Coverage   47.27%   47.25%   -0.03%     
==========================================
  Files          44       44              
  Lines       14328    14335       +7     
  Branches      203      203              
==========================================
  Hits         6774     6774              
- Misses       7554     7561       +7     
Files with missing lines Coverage Δ
lib/decoders.gi 27.42% <0.00%> (-0.36%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The interpolation step produces Q(x,y) = Q0(x) + Q1(x)*y vanishing at
every (P[i],v[i]), so the message polynomial is f = -Q0/Q1.
GeneralizedReedSolomonDecoder computed -Q1/Q0 instead and returned the
evaluations of that unrelated rational function.

It also now returns an information word.  Decode passes a special
decoder's result through verbatim and is documented to return an
information word, so returning a codeword made Decode fail outright
(the reported symptom).  That in turn exposed Decodeword re-encoding
via c0*C, which for a cyclic code multiplies by the generator
polynomial while InformationWord inverts the generator matrix; for a
GRS code that happens to be cyclic the two disagree.

Fixes #12

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@fingolfin
fingolfin requested a review from osj1961 August 16, 2026 17:58
@fingolfin

fingolfin commented Aug 16, 2026

Copy link
Copy Markdown
Member Author

@osj1961 out of my 4 recent PRs, I recommend you merge this one first in order to minimize conflicts. After that: PR #128.

@fingolfin
fingolfin force-pushed the fix-grs-interpolation-decoder branch from dd40a94 to a1db600 Compare August 16, 2026 20:31
@osj1961
osj1961 merged commit 7c74784 into master Aug 17, 2026
4 of 5 checks passed
@osj1961
osj1961 deleted the fix-grs-interpolation-decoder branch August 17, 2026 03:08
@osj1961

osj1961 commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

This will likely fix a lot of the failed tests from the .tst files pulled from the manual. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decode() vs Decodeword() GeneralizedReedSolomonCode decoding is broken

2 participants