Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in Reed-Solomon error-erasure decoder #38918

Open
2 tasks done
luan-xiaokun opened this issue Nov 3, 2024 · 0 comments
Open
2 tasks done

Bug in Reed-Solomon error-erasure decoder #38918

luan-xiaokun opened this issue Nov 3, 2024 · 0 comments

Comments

@luan-xiaokun
Copy link

Steps To Reproduce

A Reed-Solomon code RSC(n,k) is supposed to correct at most n - k erasures, while the following snippet shows that this error-erasure decoder does not work as expected.

F = GF(59)
n, k = 40, 12
C = codes.GeneralizedReedSolomonCode(F.list()[:n], k)
D = codes.decoders.GRSErrorErasureDecoder(C)
erasure_num = n - k  # work as expected if changed to values less than n - k

message = vector(F, list(range(1, k + 1)))
codeword = C.encode(message)
for i in range(erasure_num):
    codeword[i] = F.from_integer(1)
erasure = vector(GF(2), [1] * erasure_num + [0] * (n - erasure_num))
print(D.decode_to_message((codeword, erasure)))
# prints (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) instead of (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)

Expected Behavior

The decoded message should be (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)

Actual Behavior

It prints (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) instead

Additional Information

I'm not very familiar with coding theory, but it seems that when there are n-k erasures and no errors, the decoding process is essentially solving a linear equation, and the following snippet works for my case.

received = vector(F, [w for i, w in enumerate(received) if erasure[i]])
vandermonde = matrix([[multipliers[i] * eval_points[i] ** j for j in range(cut)] for i in range(cut)])
decoded = vandermonde.inverse() * received

Environment

  • OS: Ubuntu 22.04
  • Sage Version: 10.4

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants