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

Vector_modn_dense used for too large a modulus? #15220

Closed
mezzarobba opened this issue Sep 24, 2013 · 7 comments
Closed

Vector_modn_dense used for too large a modulus? #15220

mezzarobba opened this issue Sep 24, 2013 · 7 comments

Comments

@mezzarobba
Copy link
Member

sage.rings.finite_rings.integer_mod? says that IntegerMod_int64 "is used if the modulus is less than 2^{31}-1".

Consider however a vector of elements of GF(p) with p between 231 and 232:

sage: K = GF(3037000493)
sage: v = vector(K, [42])
sage: type(v)
<type 'sage.modules.vector_modn_dense.Vector_modn_dense'>

Then:

sage: type(v[0])
<type 'sage.rings.finite_rings.integer_mod.IntegerMod_int64'>

which breaks some operations:

sage: ~v[0]
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-5-43d86000256e> in <module>()
----> 1 ~v[Integer(0)]

/home/marc/co/sage/local/lib/python2.7/site-packages/sage/rings/finite_rings/integer_mod.so in sage.rings.finite_rings.integer_mod.IntegerMod_int64.__invert__ (sage/rings/finite_rings/integer_mod.c:29992)()

/home/marc/co/sage/local/lib/python2.7/site-packages/sage/rings/finite_rings/integer_mod.so in sage.rings.finite_rings.integer_mod.mod_inverse_int64 (sage/rings/finite_rings/integer_mod.c:30920)()

ZeroDivisionError: Inverse does not exist.

This does not happens with modular integers themselves:

sage: type(K(42))
<type 'sage.rings.finite_rings.integer_mod.IntegerMod_gmp'>
sage: ~K(42)
2241595602

Matrices do not seem affected either.

Things work fine with sage-5.8 on the same machine. This makes me suspect that the issue might have been introduced in aa83d6e (#14627)—but I didn't check.

Component: linear algebra

Author: Volker Braun

Reviewer: Marc Mezzarobba

Merged: sage-5.12.rc0

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

@vbraun
Copy link
Member

vbraun commented Sep 24, 2013

Initial patch

@vbraun
Copy link
Member

vbraun commented Sep 24, 2013

comment:1

Attachment: trac_15220_max_modulus.patch.gz

@vbraun
Copy link
Member

vbraun commented Sep 24, 2013

Author: Volker Braun

@vbraun
Copy link
Member

vbraun commented Sep 24, 2013

comment:2

Yes, this is from #14627. Would have been nice if there would have been doctests...

I think its pretty trivial fix so we should get that into the next Sage release.

@mezzarobba
Copy link
Member Author

comment:3

Looks good to me--and solves my problem. Thanks!

@mezzarobba
Copy link
Member Author

Reviewer: Marc Mezzarobba

@jdemeyer
Copy link

jdemeyer commented Oct 1, 2013

Merged: sage-5.12.rc0

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

3 participants