# Computing minimum_distance of a code on non-prime fields fails ... sometimes. Consider the following piece of code:

C=codes.RandomLinearCode(4,2,GF(16,'b'))
C.minimum_distance()


About half of the time, it fails with error

TypeError: unable to coerce from a finite field other than the prime subfield


I'd understand if SAGE could only compute the minimum distance for codes over primes fields, what has me confused is the fact that sometimes it can, sometimes it can't. Any clues as to what is going on here?

edit retag close merge delete

Hello,

Which version are you using? On both sage-6.5 and sage-6.6.rc0 I got

sage: C=codes.RandomLinearCode(4,2,GF(16,'b'))
sage: C.minimum_distance()
3


Yes, it may work for a few times; but if you keep evaluating, after a couple of successful evaluations you'll come up with a TypeError. You can try it this way, which certainly fails:

for i in range(100):
C=codes.RandomLinearCode(4,2,GF(16,'b'))
C.minimum_distance()


Thanks though for the interest, @vdelecroix

Sort by » oldest newest most voted

Hello,

Indeed there is a bug in Sage/GAP code conversion. It works for $GF(2^3)$ but not $GF(2^4)$

sage: K = GF(8,'a')
sage: for x in K:
....:     print x == K(x._gap_()),
True True True True True True True True

sage: K = GF(16,'a')
sage: for x in K:
....:     print x == K(x._gap_()),
True True True True True
Traceback (most recent call last):
...
TypeError: unable to coerce from a finite field other than the prime subfield


I opened the trac ticket #18048 for that issue.

Vincent

more

Thanks a lot for both the quick answer and the ticket. Do I get bragging rights (for my students) for uncovering this, @vdelecroix ? ;)

Hopefully, Peter Bruin came with a solution to fix the bug (you can have a look on the ticket #18048. So it should be fixed in sage-6.6. In the mean time, the only solution I see is to use git to get his modifications on your computer (you do have explanations in the Developer Guide. If you are not familiar with that it might be simpler to just wait for sage-6.6 (should be a matter of weeks).

You guys rock! I can git my way, if my life depends on it, but since it's not "mission critical", I'll wait for 6.6.