Skip to content

Commit a357cf7

Browse files
author
Release Manager
committed
Trac #33847: Bug in h_star_vector for polytopes with the normaliz backend
Dr. Ben Braun reported the following error. The h-star-vector records the coefficients of the polynomial in the numerator of the Ehrhart series of a lattice polytope. The method h_star_vector() for polytopes with the normaliz backend was implemented in #28413. The implementation seems to have an error, namely that it drops internal zeros from the vector. Example: {{{ sage: L = [[1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0], [1, 0, 0, ....: 1, 0, 0], [1, 0, 0, 0, 1, 0], [1, 0, 0, 1, 2, 3]] sage: P = Polyhedron(vertices=L,backend='normaliz') sage: P.ehrhart_series().numerator() 2*t^2 + 1 sage: P.h_star_vector() [1, 2] }}} Actually, the correct return should be `[1, 0, 2]`. This bug is caused by the line 1437 of `src/sage/geometry/polyhedron/backend_normaliz.py`, which forgets to pass `sparse=False` into `self.ehrhart_series().numerator().coefficients()`. We fix the bug by changing this line to `return self.ehrhart_series().numerator().list()`. URL: https://trac.sagemath.org/33847 Reported by: yzh Ticket author(s): Yuan Zhou Reviewer(s): Matthias Koeppe
2 parents f69c9b8 + 6027fb1 commit a357cf7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/sage/geometry/polyhedron/backend_normaliz.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1433,8 +1433,18 @@ def _h_star_vector_normaliz(self):
14331433
sage: cube = polytopes.cube(intervals='zero_one', backend='normaliz') # optional - pynormaliz
14341434
sage: cube.h_star_vector() # optional - pynormaliz
14351435
[1, 4, 1]
1436+
1437+
TESTS:
1438+
1439+
Check that :trac:`33847` is fixed::
1440+
1441+
sage: L = [[1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0],
1442+
....: [1, 0, 0, 1, 0, 0], [1, 0, 0, 0, 1, 0], [1, 0, 0, 1, 2, 3]]
1443+
sage: P = Polyhedron(vertices=L,backend='normaliz') # optional - pynormaliz
1444+
sage: P.h_star_vector() # optional - pynormaliz
1445+
[1, 0, 2]
14361446
"""
1437-
return self.ehrhart_series().numerator().coefficients()
1447+
return self.ehrhart_series().numerator().list()
14381448

14391449
def _volume_normaliz(self, measure='euclidean'):
14401450
r"""

0 commit comments

Comments
 (0)