Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit b351e65

Browse files
author
Release Manager
committed
Trac #29475: Weil polynomials iterator is not handling coefficient constraints correctly
Currently, when iterating over Weil polynomals, initial coefficient constraints are not being handled correctly in some cases: {{{ sage: from sage.rings.polynomial.weil.weil_polynomials import WeilPolynomials as WP sage: P.<x> = QQ[] sage: u = x^6 + x^5 + 6*x^4 - 2*x^3 + 66*x^2 + 121*x + 1331 sage: u.is_weil_polynomial() True sage: l = list(WP(6, 11, 1, [1,1])); u in l # This is good True sage: l = list(WP(6, 11, 1, [1,1,6])); u in l # This is bad False }}} URL: https://trac.sagemath.org/29475 Reported by: kedlaya Ticket author(s): Kiran Kedlaya Reviewer(s): Frédéric Chapoton
2 parents 002aaa0 + a751aad commit b351e65

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/sage/rings/polynomial/weil/weil_polynomials.pyx

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class WeilPolynomials_iter():
315315
# Asymmetrize initial coefficients
316316
for i in range(len(coefflist)):
317317
for j in range(1, (len(coefflist)-i+1)//2):
318-
coefflist[i+2*j] -= (d2-i).binomial(j)*coefflist[i]
318+
coefflist[i+2*j] -= (d2-i).binomial(j)*(q**j)*coefflist[i]
319319
for _ in range(d2+1-len(coefflist)):
320320
coefflist.append(0)
321321
modlist.append(1)
@@ -431,22 +431,26 @@ class WeilPolynomials():
431431
432432
- ``sign`` -- integer (default `1`), the sign `s` of the functional equation
433433
434-
- ``lead`` -- integer, list of integers or list of pairs of integers (default `1`),
435-
constraints on the leading few coefficients of the generated polynomials.
434+
- ``lead`` -- integer, list of integers or pairs of integers (default `1`)
435+
436+
These are constraints on the leading coefficients of the generated polynomials.
436437
If pairs `(a, b)` of integers are given, they are treated as a constraint
437438
of the form `\equiv a \pmod{b}`; the moduli must be in decreasing order by
438439
divisibility, and the modulus of the leading coefficient must be 0.
439440
440-
- ``node_limit`` -- integer (default ``None``), an upper bound on the number of
441-
terminal nodes during the search (will raise a ``RuntimeError`` if exceeded)
441+
- ``node_limit`` -- integer (default ``None``)
442+
443+
If set, imposes an upper bound on the number of terminal nodes during the search
444+
(will raise a ``RuntimeError`` if exceeded).
442445
443446
- ``parallel`` -- boolean (default ``False``), whether to use multiple processes
444-
in searching for Weil polynomials. If set, then this file must have been
445-
compiled with OpenMP support (see instructions at the top of
446-
:mod:`sage.rings.polynomial.weil.weil_polynomials`)
447447
448-
- ``squarefree`` -- boolean (default ``False``), whether to only include squarefree
449-
polynomials in the results
448+
If set, will raise an error unless this file was compiled with OpenMP support
449+
(see instructions at the top of :mod:`sage.rings.polynomial.weil.weil_polynomials`).
450+
451+
- ``squarefree`` -- boolean (default ``False``),
452+
453+
If set, only squarefree polynomials will be returned.
450454
451455
- ``polring`` -- optional, a polynomial ring in which to construct the results
452456
@@ -524,6 +528,18 @@ class WeilPolynomials():
524528
True
525529
True
526530
True
531+
532+
Test that :trac:`29475` is resolved::
533+
534+
sage: P.<x> = QQ[]
535+
sage: u = x^6 + x^5 + 6*x^4 - 2*x^3 + 66*x^2 + 121*x + 1331
536+
sage: u.is_weil_polynomial()
537+
True
538+
sage: u in WeilPolynomials(6, 11, 1, [1,1,6])
539+
True
540+
sage: u in WeilPolynomials(6, 11, 1, [(1,0),(1,11),(6,11)])
541+
True
542+
527543
"""
528544
def __init__(self, d, q, sign=1, lead=1, node_limit=None, parallel=False, squarefree=False, polring=None):
529545
r"""

0 commit comments

Comments
 (0)