sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.45k stars 481 forks source link

Syndrome decoder is not a syndrome decoder #19623

Closed 1861b8a9-77f0-4f35-8431-8514a75b40d1 closed 8 years ago

1861b8a9-77f0-4f35-8431-8514a75b40d1 commented 8 years ago

The current implementation of syndrome decoder for linear codes actually uses a nearest neighbor decoding algorithm.

It should be rewritten.

CC: @johanrosenkilde @ClementPernet @jlavauzelle

Component: coding theory

Author: David Lucas

Branch/Commit: 2bef528

Reviewer: Julien Lavauzelle, Johan Sebastian Rosenkilde Nielsen

Issue created by migration from https://trac.sagemath.org/ticket/19623

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

1e738f3Some docstring typography
johanrosenkilde commented 8 years ago

Changed reviewer from Julien Lavauzelle to Julien Lavauzelle, Johan Sebastian Rosenkilde Nielsen

johanrosenkilde commented 8 years ago
comment:40

OK, looks good. I fixed some phrasings and some typos in the docstring. If you can accept them, set the ticket to positive review :-)

1861b8a9-77f0-4f35-8431-8514a75b40d1 commented 8 years ago
comment:41

I accept your changes, positive reviewed!

David

jlavauzelle commented 8 years ago
comment:42

Before you close the ticket (it is not long enough ;-)), just a minor remark: your documentation of decode_to_code talks about decoding into the "message space" instead of the code.

Otherwise, really good job :)

1861b8a9-77f0-4f35-8431-8514a75b40d1 commented 8 years ago

Changed branch from u/jsrn/generic_decoders to u/dlucas/generic_decoders

1861b8a9-77f0-4f35-8431-8514a75b40d1 commented 8 years ago
comment:44

Dammit, you're right, I thought I fixed this long ago... Well, nice catch, it's fixed now ;)


New commits:

642dca4Fixed typo in decode_to_code
1861b8a9-77f0-4f35-8431-8514a75b40d1 commented 8 years ago

Changed commit from 1e738f3 to 642dca4

vbraun commented 8 years ago
comment:45

Something is broken in combination with #19897

sage -t --long src/doc/en/thematic_tutorials/coding_theory.rst
**********************************************************************
File "src/doc/en/thematic_tutorials/coding_theory.rst", line 253, in doc.en.thematic_tutorials.coding_theory
Failed example:
    c_dec = C.decode_to_code(r)
Exception raised:
    Traceback (most recent call last):
      File "/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 496, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/doctest/forker.py", line 858, in compile_and_execute
        exec(compiled, globs)
      File "<doctest doc.en.thematic_tutorials.coding_theory[29]>", line 1, in <module>
        c_dec = C.decode_to_code(r)
      File "/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/coding/linear_code.py", line 1656, in decode_to_code
        D = self.decoder(decoder_name, **kwargs)
      File "sage/misc/cachefunc.pyx", line 1909, in sage.misc.cachefunc.CachedMethodCaller.__call__ (/home/buildslave-sage/slave/sage_git/build/src/build/cythonized/sage/misc/cachefunc.c:9941)
        w = self._instance_call(*args, **kwds)
      File "sage/misc/cachefunc.pyx", line 1785, in sage.misc.cachefunc.CachedMethodCaller._instance_call (/home/buildslave-sage/slave/sage_git/build/src/build/cythonized/sage/misc/cachefunc.c:9408)
        return self.f(self._instance, *args, **kwds)
      File "/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/coding/linear_code.py", line 1739, in decoder
        D = decClass(self, **kwargs)
      File "/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/coding/linear_code.py", line 4173, in __init__
        self._lookup_table = self._build_lookup_table()
      File "sage/misc/cachefunc.pyx", line 2235, in sage.misc.cachefunc.CachedMethodCallerNoArgs.__call__ (/home/buildslave-sage/slave/sage_git/build/src/build/cythonized/sage/misc/cachefunc.c:12406)
        self.cache = f(self._instance)
      File "/home/buildslave-sage/slave/sage_git/build/local/lib/python2.7/site-packages/sage/coding/linear_code.py", line 4298, in _build_lookup_table
        lookup[s] = copy(e)
    MemoryError
**********************************************************************
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Changed commit from 642dca4 to 2bef528

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 8 years ago

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

cb65314Update to latest beta
2057feeSmall fixes and improvements
d9bcb28Update to 7.1beta0
70e5211Added ..linkall keyword and wrote a new paragraph on decoders and introspections
4035292Moved and fixed list of decoder types
b443718Update to 7.1beta1
61d49ccRewrote some sentences and fixed typos
12bf512Removed table of types
564dcddMerge branch 'introductory_thematic_tutorial' into generic_decoders
2bef528Picked a smaller code in thematic tutorial to fix examples
1861b8a9-77f0-4f35-8431-8514a75b40d1 commented 8 years ago
comment:47

I identified the problem, it was because of a [12, 4] GRS code over GF(13) in my examples. Decoding over this code using the new syndrome decoder required to build a huge syndrome lookup table, hence the memory error.

I replaced it by a [6, 3] code over GF(7), so it should be fine now.

Reopening for review...

David

johanrosenkilde commented 8 years ago
comment:48

Hah, that's pretty funny: before, the syndrome decoder was actually a nearest neighbor decoder, and therefore ran in q^k. Now, it's really a syndrome decoder and runs in q^(n-k), which is too big for the previous example in the tutorial.

Perhaps, a linear code should default to using syndrome or nearest neighbor depending on which of q^(n-k) or q^k is biggest?

For this ticket: green again.

vbraun commented 8 years ago

Changed branch from u/dlucas/generic_decoders to 2bef528