Skip to content

Commit 7b74bf7

Browse files
author
Release Manager
committed
gh-39883: Fix a bug in caching of reduced norm of skew polynomials This fixes the following bug ``` sage: k.<t> = GF(5^3) sage: Frob = k.frobenius_endomorphism() sage: S.<u> = k['u', Frob] sage: f = u^5 + t*u^4 + t^2*u^3 + t^3*u^2 + t^4*u + t^5 sage: f.reduced_norm() z^5 + 2*z^4 + 4*z^3 + z^2 + 4*z + 2 sage: f.reduced_charpoly() x^3 + z*x^2 + (2*z + 3)*x + 4*z^5 + 3*z^4 + z^3 + 4*z^2 + z + 3 sage: f.reduced_norm() 1 ``` ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [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. - [x] I have updated the documentation and checked the documentation preview. URL: #39883 Reported by: Xavier Caruso Reviewer(s): Travis Scrimshaw
2 parents fbb3237 + ac7efcf commit 7b74bf7

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/sage/rings/polynomial/skew_polynomial_finite_order.pyx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ cdef class SkewPolynomial_finite_order_dense(SkewPolynomial_generic_dense):
381381
polynomial is ``x`` and the name of central variable is usually ``z``
382382
(see :meth:`~sage.rings.polynomial.skew_polynomial_ring.SkewPolynomialRing_finite_order.center`
383383
for more details about this).
384-
The user can speciify different names if desired::
384+
The user can specify different names if desired::
385385
386386
sage: a.reduced_charpoly(var='T') # variable name for the characteristic polynomial
387387
T^3 + (2*z + 1)*T^2 + (3*z^2 + 4*z)*T + 4*z^3 + z^2 + 1
@@ -392,13 +392,28 @@ cdef class SkewPolynomial_finite_order_dense(SkewPolynomial_generic_dense):
392392
.. SEEALSO::
393393
394394
:meth:`reduced_trace`, :meth:`reduced_norm`
395+
396+
TESTS:
397+
398+
We test that the cache works correctly (see :issue:`39883`)::
399+
400+
sage: f = u^5 + t*u^4 + t^2*u^3 + t^3*u^2 + t^4*u + t^5
401+
sage: f.reduced_norm()
402+
z^5 + 2*z^4 + 4*z^3 + z^2 + 4*z + 2
403+
sage: f.reduced_charpoly()
404+
x^3 + z*x^2 + (2*z + 3)*x + 4*z^5 + 3*z^4 + z^3 + 4*z^2 + z + 3
405+
sage: f.reduced_norm()
406+
z^5 + 2*z^4 + 4*z^3 + z^2 + 4*z + 2
395407
"""
396408
if self._charpoly is None:
397409
M = self._matmul_c()
398410
chi = M.charpoly()
399411
self._charpoly = [tuple(c.list()) for c in chi.list()]
400-
if self._norm is not None:
401-
self._norm = self._charpoly[-1]
412+
if self._norm is None:
413+
if len(self._charpoly) % 2:
414+
self._norm = self._charpoly[0]
415+
else:
416+
self._norm = tuple((-chi[0]).list())
402417
varcenter = None
403418
if var is None:
404419
varcharpoly = 'x'

0 commit comments

Comments
 (0)