Skip to content

Crash in nmod_poly #124

Open
Open
@GiacomoPope

Description

@GiacomoPope

For fmpz_mod_poly we get an error when we cannot compute an inverse when performing operations

>>> from flint import fmpz_mod_poly_ctx, fmpz_mod_poly
>>> R = fmpz_mod_poly_ctx(10)
>>> f = R([1,2,3])
>>> f
3*x^2 + 2*x + 1
>>> f % f
0
>>> g = R([3,1,2])
>>> g
2*x^2 + x + 3
>>> g % g
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "src/flint/types/fmpz_mod_poly.pyx", line 659, in flint.types.fmpz_mod_poly.fmpz_mod_poly.__mod__
  File "src/flint/types/fmpz_mod_poly.pyx", line 652, in flint.types.fmpz_mod_poly.fmpz_mod_poly._mod_
ValueError: Cannot compute remainder of 2*x^2 + x + 3 modulo 2*x^2 + x + 3

But for nmod_poly we get a crash:

Python 3.11.4 (main, Jul 25 2023, 17:07:07) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from flint import *
>>> f = nmod_poly([2,1,3], 10)
>>> f
3*x^2 + x + 2
>>> f % f
0
>>> f = nmod_poly([3, 1, 2], 10)
>>> f % f
Flint exception (Impossible inverse):
    Cannot invert modulo 2*5
zsh: abort      python3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions