@@ -213,10 +213,12 @@ def integral_points_count(self, verbose=False, use_Hrepresentation=False,
213
213
214
214
@cached_method (do_pickle = True )
215
215
def ehrhart_polynomial (self , engine = None , variable = 't' , verbose = False ,
216
- dual = None , irrational_primal = None , irrational_all_primal = None ,
217
- maxdet = None , no_decomposition = None , compute_vertex_cones = None ,
218
- smith_form = None , dualization = None , triangulation = None ,
219
- triangulation_max_height = None , ** kwds ):
216
+ dual = None , irrational_primal = None ,
217
+ irrational_all_primal = None , maxdet = None ,
218
+ no_decomposition = None , compute_vertex_cones = None ,
219
+ smith_form = None , dualization = None ,
220
+ triangulation = None ,
221
+ triangulation_max_height = None , ** kwds ):
220
222
r"""
221
223
Return the Ehrhart polynomial of this polyhedron.
222
224
@@ -348,23 +350,33 @@ def ehrhart_polynomial(self, engine=None, variable='t', verbose=False,
348
350
sage: Q = loads(dumps(P))
349
351
sage: Q.ehrhart_polynomial.is_in_cache()
350
352
True
353
+
354
+ sage: L = Polyhedron(vertices=[[QQ(0)]])
355
+ sage: L.ehrhart_polynomial()
356
+ 1
351
357
"""
358
+ from sage .rings .polynomial .polynomial_ring_constructor import PolynomialRing
359
+ from sage .rings .rational_field import QQ
360
+ R = PolynomialRing (QQ , variable )
361
+
352
362
# check if ``self`` is compact and has vertices in ZZ
353
363
if self .is_empty ():
354
- from sage .rings .polynomial .polynomial_ring_constructor import PolynomialRing
355
- from sage .rings .rational_field import QQ
356
- R = PolynomialRing (QQ , variable )
357
364
return R .zero ()
358
365
359
366
if not self .is_compact ():
360
367
raise ValueError ("Ehrhart polynomial only defined for compact polyhedra" )
361
368
362
369
if any (not v .is_integral () for v in self .vertex_generator ()):
363
370
raise TypeError ("the polytope has nonintegral vertices, use ehrhart_quasipolynomial with backend 'normaliz'" )
371
+
372
+ if self .dimension () == 0 :
373
+ return R .one ()
374
+
364
375
# Passes to specific latte or normaliz subfunction depending on engine
365
376
if engine is None :
366
377
# set default engine to latte
367
378
engine = 'latte'
379
+
368
380
if engine == 'latte' :
369
381
poly = self ._ehrhart_polynomial_latte (verbose , dual ,
370
382
irrational_primal , irrational_all_primal , maxdet ,
0 commit comments