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

Matrix construction over prime field fails for some types of inputs #36104

Open
2 tasks done
vneiger opened this issue Aug 19, 2023 · 0 comments
Open
2 tasks done

Matrix construction over prime field fails for some types of inputs #36104

vneiger opened this issue Aug 19, 2023 · 0 comments

Comments

@vneiger
Copy link
Contributor

vneiger commented Aug 19, 2023

Steps To Reproduce

The constructor for matrices of type matrix_modn_dense is supposed to accept a matrix of Python integers int. Yet it will fail with overflow if given integers that exceed the maximum value for a long.

Try the following example:

sage: x = int(2**128 + 1)
sage: mat = matrix(GF(9001), [[x]])

Expected Behavior

We expect that mat is constructed as an 1 x 1 matrix with single entry the element GF(9001)(x) (represented by 7633 in sage).

Actual Behavior

[...]
File src/sage/matrix/matrix_modn_dense_template.pxi:531, in sage.matrix.matrix_modn_dense_double.Matrix_modn_dense_template.__init__()
    529 x = next(it)
    530 if type(x) is int:
--> 531     tmp = (<long>x) % p
    532     v[j] = tmp + (tmp<0)*p
    533 elif type(x) is IntegerMod_int and (<IntegerMod_int>x)._parent is R:

OverflowError: Python int too large to convert to C long

Additional Information

We see in the error message that there is an attempt to convert x into a long, hence the overflow error.

Environment

- **OS**: ubuntu 22.04
- **Sage Version**: 10.1.rc0

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
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

1 participant