-
Notifications
You must be signed in to change notification settings - Fork 18
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
decode_fast fails with RS(255,247) with 4 errors, when it should not #5
Comments
Another test case that also fails: (255,251) with default args and two errors
I can't seem to find any examples of (255,253) with one error failing. |
Thank you for opening this issue, but I'm not sure I understand what you are trying to do. Here the message you build is not encoded. Is the message you build something you already calculated by yourself beforehand? In any case, it may well be that decode_fast() fails because the chien search used (chien_search_faster()) is a very specifically tailored function with tricks to speed up calculations by avoiding calculations on non interesting coefficients. I don't remember if I invented this trick or if I read it somewhere, but skipping coefficients is probably not a foolproof way to go about it, so you might try to change _chien_search_faster() by _chien_search_fast() in the decode_fast() method, this should be more reliable at the expense of some speed loss. Also note that the library is extensively unit tested (see here: https://github.com/lrq3000/unireedsolomon/blob/master/unireedsolomon/tests/test_rs.py#L319), but it's true that your decoding case. |
No, you're missing the point. The encoded message is the all-zero codeword (255 zeros) and these are examples of received messages with 2 errors for RS(255,251) and 4 errors for RS(255,247) that are decoded correctly (as they should) by This represents an error pattern that can be added to any message that should therefore fail decoding. For example:
which prints (note the errors of
Optimization at the expense of correctness should be avoided, or at least heavily documented. I discovered these cases while doing some statistical analysis of Reed-Solomon using Monte Carlo analysis to generate random patterns with more than t errors (where t = (n-k)/2 is the maximum number of errors that RS will always decode correctly), where RS is not guaranteed to work properly. My intent was to get an idea of how often RS succeeded, or made a bad correction, or failed during the Chien search. Just for validation purposes I verified that it corrected t errors. Using decode_fast() didn't in a few cases, so I posted it here. I have willingness to help, and experience both with finite fields (I'm trying to finish a series of articles) and with implementing Reed-Solomon decoding myself once in Java at a former employer, but very little time unfortunately due to some issues with my family. |
I am willing to add a unit test case that covers these and others (may need some help building/installing the package from source if it does anything besides pure Python), although please note that this would presently produce a failure. It may take me a while to do so, however; my free time is spoken for until at least June 27. |
I agree that optimization should not be at the cost of correctness, but please know that I tried my best to do just that, since most opensource implementations heavily rely on undocumented optimizations for very specific sets of parameters (I think this is the only one or at least one of the very few universal reed-solomon codec out there in any programming language :-) ). So I tried my best to "de-optimize" then "re-optimize" with a more generalizable code including all codec parameters where possible (eg, fcr which is usually assumed as a constant of 0 or 1). I also lack time and knowledge (I did this as a hobby for a personal project, I'm not a professional of signal processing ;-) ), so please feel free to add a test case (for example in the unit test I pointed above, it's a cross-validation kind of test, if you add your case here then it will be tested against all implementations, fast and not fast). Following the results, I will update the package to only use what works with these cases :-) Thank you very much @jason-s for having debugged this ! |
This is with unireedsolomon 1.0 via
pip install unireedsolomon
. Thedecode_fast()
function seems to fail when it shouldn't. I've gotten failures with 4 errors for (255,247) and 8 errors for (255,239).(
And for the record, it doesn't seem faster than decode() at least not for (255,247) and (255,239).edit: oh, never mind, I wasn't timing it carefully enough. Just ran it on (255,191) with 32 errors and for 500 iterations it took 8 seconds fordecode_fast()
and 36 seconds fordecode()
. For (255,223) with 16 errors: 500 iterations took 4 seconds fordecode_fast()
and about 8 seconds for decode(). For (255,239) with 8 errors: 500 iterations took 1.9 seconds for
decode_fast()and 2.9 seconds for
decode()`)Python code:
Result:
The text was updated successfully, but these errors were encountered: