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

Minimum distance for long codes over GF(2) or GF(3) is incorrect #46

Open
hellman opened this issue Apr 26, 2019 · 0 comments
Open

Minimum distance for long codes over GF(2) or GF(3) is incorrect #46

hellman opened this issue Apr 26, 2019 · 0 comments

Comments

@hellman
Copy link

hellman commented Apr 26, 2019

Guava's code for computing minimum distance of codes over GF(2) or GF(3) is broken when the code's block length is larger than 2**16. This happens because in the C code short type is used in many places (all the C code is in the folder src/ctjhai/). For example, see src/ctjhai/types.h.

I suggest to use unsigned long everywhere (maybe just the MATRIX struct should use unsigned char to save some memory, since only GF(2) and GF(3) are supported). Such replacement would also require appropriate changes in format strings. Moreover, many ints should be replaced too, as I think it's possible that larger codes are also analyzed, i.e. with length greater than 2**32. But I don't know if Guava itself can hold such large codes.

I can make a pull request with type changes if it's agreed.

Also there should be a check somewhere whether the block length is higher than possible to hold in the current architecture's word. Otherwise, an error should be thrown.

I arrived at this bug when using it from SageMath. See the following simple example, where the minimum distance is clearly 2, but Guava returns 0. Similar error happens on almost any other code with large block length.

from sage.all import *

G = matrix(GF(2), [
    [1]*2**16 + [1, 0, 0],
    [1]*2**16 + [0, 1, 0],
    [1]*2**16 + [0, 0, 1],
])
dist = min(sum(map(int, v)) for v in G.row_space() if v)
dist_guava = LinearCode(G).minimum_distance(algorithm="guava")
print "real minimum distance: %d, guava: %d" % (dist, dist_guava)

# real minimum distance: 2, guava: 0

For completeness, here are versions that I use:

SageMath version 8.7, Release Date: 2019-03-23 │Using Python 2.7.15
GAP 4.10.0 of 01-Nov-2018
Architecture: x86_64-pc-linux-gnu-default64
GUAVA Version 3.14
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

No branches or pull requests

1 participant