-
-
Notifications
You must be signed in to change notification settings - Fork 706
Closed
Description
Steps To Reproduce
The following code creates a univariate polynomial factor(f) can not find .modulus, f.radical() produces wrong result, wrong arithmetic, probably more).
print(version())
x = PolynomialRing(GF(37), ['x'], sparse=True).fraction_field().gen()
f = (x^8 + 16*x^6 + 4*x^4 + x^2 + 12).numerator()
print(type(f), f.parent())
print(" f", f)
print("f+1", f+1)
print("rad", f.radical())
print("r^2", f.radical()**2)
print(factor(f))Output:
SageMath version 10.2, Release Date: 2023-12-03
<class 'sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint'> Sparse Univariate Polynomial Ring in x over Finite Field of size 37
f x^8 + 16*x^6 + 4*x^4 + x^2 + 12
f+1 x^8 + 16*x^6 + 4*x^4 + x^2 + 12
rad x^4 + 15*x^2 + 26
r^2 x^8 + x^4
...
AttributeError: 'PolynomialRing_field_with_category' object has no attribute 'modulus'
While the actual radical should be just the square root of the polynomial which is:
sage: x = GF(37)['x'].gen()
sage: f = (x^8 + 16*x^6 + 4*x^4 + x^2 + 12)
sage: f.radical()
x^4 + 8*x^2 + 7
sage: f.radical()**2
x^8 + 16*x^6 + 4*x^4 + x^2 + 12
sage: factor(f)
(x + 6)^2 * (x + 17)^2 * (x + 20)^2 * (x + 31)^2Expected Behavior
The output object is well formed and performs correctly (e.g. factor(f) succeeds, f.radical() is computed correctly, f+1 is computed correctly, etc.).
Actual Behavior
The output object is corrupted and yields wrong results / exceptions.
Additional Information
It might be that flint does not support sparse polynomials, while Sage wrongfully forces a dense object to be interpreted as a sparse one?
sage: PolynomialRing(GF(37), ['x'], sparse=False, implementation="FLINT")
Univariate Polynomial Ring in x over Finite Field of size 37
sage: PolynomialRing(GF(37), ['x'], sparse=True, implementation="FLINT")
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
...
ValueError: unknown implementation 'FLINT' for sparse polynomial rings over Finite Field of size 37Environment
- **OS**: Linux Mint 21.3
- **Sage Version**: 10.2Checklist
- 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