Skip to content

Commit

Permalink
Trac #33847: Bug in h_star_vector for polytopes with the normaliz bac…
Browse files Browse the repository at this point in the history
…kend

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
  • Loading branch information
Release Manager committed May 22, 2022
2 parents f69c9b8 + 6027fb1 commit a357cf7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/sage/geometry/polyhedron/backend_normaliz.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,8 +1433,18 @@ def _h_star_vector_normaliz(self):
sage: cube = polytopes.cube(intervals='zero_one', backend='normaliz') # optional - pynormaliz
sage: cube.h_star_vector() # optional - pynormaliz
[1, 4, 1]
TESTS:
Check that :trac:`33847` is fixed::
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') # optional - pynormaliz
sage: P.h_star_vector() # optional - pynormaliz
[1, 0, 2]
"""
return self.ehrhart_series().numerator().coefficients()
return self.ehrhart_series().numerator().list()

def _volume_normaliz(self, measure='euclidean'):
r"""
Expand Down

0 comments on commit a357cf7

Please sign in to comment.