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

Fix univariate polynomial reverse #37201

Merged
merged 4 commits into from
Feb 2, 2024
Merged

Conversation

vneiger
Copy link
Contributor

@vneiger vneiger commented Jan 30, 2024

For univariate polynomials over "non-prime" finite fields, the reverse method had an issue when specifying degree=0: it raised an error saying that this optional argument should be... nonnegative (which 0 is).

Example:

sage: ring.<x> = GF(9)[]
sage: pol = ring(1)
sage: pol.reverse(degree=2)
x^2
sage: pol.reverse()
1
sage: pol.reverse(degree=0)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[5], line 1
----> 1 pol.reverse(degree=Integer(0))

File ~/repositories/software/sage/src/sage/rings/polynomial/polynomial_zz_pex.pyx:537, in sage.rings.polynomial.polynomial_zz_pex.Polynomial_ZZ_pEX.reverse()
    535 if degree is not None:
    536     if degree <= 0:
--> 537         raise ValueError("degree argument must be a non-negative integer, got %s" % (degree))
    538     try:
    539         d = degree

ValueError: degree argument must be a non-negative integer, got 0

This is fixed in this PR, along with fixes in similar code where the error message was not the expected one ("cannot convert to long", instead of "degree must be nonnegative").

@xcaruso
Copy link
Contributor

xcaruso commented Jan 30, 2024

Looks good to me.

@xcaruso xcaruso self-requested a review January 30, 2024 23:08
@vneiger
Copy link
Contributor Author

vneiger commented Jan 31, 2024

Minor fix: the change of the error message (upon negative input value) affects a doctest in matrix_polynomial_dense, this is fixed.

Copy link

Documentation preview for this PR (built with commit 9f15f69; changes) is ready! 🎉

vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 1, 2024
…in corner case

    
For univariate polynomial matrices, either with zero columns (or zero
rows if `row_wise=False`), or which are zero, the computed minimal
kernel basis was of the sparse type (due to a mistake in using the
identity method). This is fixed.

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

PR sagemath#37201  modified a test in the same file
`matrix_polynomial_dense.pyx`
    
URL: sagemath#37208
Reported by: Vincent Neiger
Reviewer(s): Vincent Neiger, Xavier Caruso
@vbraun vbraun merged commit c01ed87 into sagemath:develop Feb 2, 2024
21 of 35 checks passed
@mkoeppe mkoeppe added this to the sage-10.3 milestone Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants