Matrix(GF(2^n)) with large n not working on SageMath 9.1

58 views
Skip to first unread message

Zihan Zheng

unread,
Aug 13, 2020, 3:51:38 PM8/13/20
to sage-devel
Hi developers,

I think I found a bug of SageMath 9.1

F.<x> = GF(2 ^ 64)
Matrix(F, 5, 5)

This piece of code runs without error on SageMath 8.9 and 9.0, but throws error on 9.1

(reproducible on cocalc.com)

OverflowError: Python int too large to convert to C unsigned long

Best,
Zihan

Maxime Bombar

unread,
Aug 13, 2020, 5:59:11 PM8/13/20
to sage-...@googlegroups.com, Zihan Zheng
--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/366187ef-d6bf-4dbf-a55a-9db2a243d9cen%40googlegroups.com.

Hi,

it works very well for me, even for (much) larger fields.

sage: F.<x> = GF(2^16384)
sage: Matrix(F, 5, 5)
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 0]

Can you be more specific ? What version of python are you using ? And on which OS ?

Best,

--
Maxime


signature.asc

dmo...@deductivepress.ca

unread,
Aug 14, 2020, 12:24:00 AM8/14/20
to sage-devel
I confirm that the error occurs on CoCalc (with the 9.1 or Development kernel), so there certainly seems to be a bug somewhere, even though I do not get an error on my own computer (MacOS 10.15.5).

F.<x> = GF(2 ^ 64)
Matrix(F, 5, 5)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
<ipython-input-1-9d9a316b9fa1> in <module>()
      1 F = GF(Integer(2) ** Integer(64), names=('x',)); (x,) = F._first_ngens(1)
----> 2 Matrix(F, Integer(5), Integer(5))

/ext/sage/sage-dev/local/lib/python3.7/site-packages/sage/matrix/constructor.pyx in sage.matrix.constructor.matrix (build/cythonized/sage/matrix/constructor.c:2479)()
    634     """
    635     immutable = kwds.pop('immutable', False)
--> 636     M = MatrixArgs(*args, **kwds).matrix()
    637     if immutable:
    638         M.set_immutable()
/ext/sage/sage-dev/local/lib/python3.7/site-packages/sage/matrix/args.pyx in sage.matrix.args.MatrixArgs.matrix (build/cythonized/sage/matrix/args.c:7846)()
    660                     break
    661         else:
--> 662             M = self.space(self, coerce=convert)
    663
    664         # Also store the matrix to support multiple calls of matrix()
/ext/sage/sage-dev/local/lib/python3.7/site-packages/sage/matrix/matrix_space.py in __call__(self, entries, coerce, copy)
    829             [t]
    830         """
--> 831         return self.element_class(self, entries, copy, coerce)
    832
    833     def change_ring(self, R):
/ext/sage/sage-dev/local/lib/python3.7/site-packages/sage/matrix/matrix_gf2e_dense.pyx in sage.matrix.matrix_gf2e_dense.Matrix_gf2e_dense.__cinit__ (build/cythonized/sage/matrix/matrix_gf2e_dense.c:3774)()
    171
    172         cdef long i
--> 173         cdef m4ri_word poly = sum(((<m4ri_word>c) << i) for (i, c) in enumerate(f))
    174
    175         if alloc and self._nrows and self._ncols:

OverflowError: Python int too large to convert to C unsigned long

Alex J Best

unread,
Aug 14, 2020, 1:15:41 AM8/14/20
to sage-devel
Looks like this is probably fixed by https://trac.sagemath.org/ticket/29818
Reply all
Reply to author
Forward
0 new messages