This repository was archived by the owner on Jan 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
src/sage/geometry/polyhedron Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -3170,6 +3170,17 @@ def is_pyramid(self, certificate=False):
31703170 sage: Q = polytopes.octahedron()
31713171 sage: Q.is_pyramid()
31723172 False
3173+
3174+ For the `0`-dimensional polyhedron, the output is ``True``,
3175+ but it cannot be constructed as a pyramid over the empty polyhedron::
3176+
3177+ sage: P = Polyhedron([[0]])
3178+ sage: P.is_pyramid()
3179+ True
3180+ sage: Polyhedron().pyramid()
3181+ Traceback (most recent call last):
3182+ ...
3183+ ZeroDivisionError: rational division by zero
31733184 """
31743185 if not self .is_compact ():
31753186 raise ValueError ("polyhedron has to be compact" )
Original file line number Diff line number Diff line change @@ -410,9 +410,15 @@ cdef class CombinatorialPolyhedron(SageObject):
410410 # one can give an Integer as Input.
411411 if data < - 1 :
412412 ValueError (" any polyhedron must have dimension at least -1" )
413- self ._n_facets = 0
414413 self ._dimension = data
415414
415+ if self ._dimension == 0 :
416+ self ._n_facets = 1
417+ self ._n_Vrepresentation = 1
418+ else :
419+ self ._n_facets = 0
420+ self ._n_Vrepresentation = 0
421+
416422 # Initializing the facets in their Bit-representation.
417423 self ._bitrep_facets = facets_tuple_to_bit_repr_of_facets((), 0 )
418424
@@ -1831,10 +1837,31 @@ cdef class CombinatorialPolyhedron(SageObject):
18311837 Traceback ( most recent call last) :
18321838 ...
18331839 ValueError: polyhedron has to be compact
1840+
1841+ TESTS::
1842+
1843+ sage: CombinatorialPolyhedron( -1) . is_pyramid( )
1844+ False
1845+ sage: CombinatorialPolyhedron( -1) . is_pyramid( True)
1846+ ( False, None)
1847+ sage: CombinatorialPolyhedron( 0) . is_pyramid( )
1848+ True
1849+ sage: CombinatorialPolyhedron( 0) . is_pyramid( True)
1850+ ( True, 0)
18341851 """
18351852 if not self .is_bounded():
18361853 raise ValueError (" polyhedron has to be compact" )
18371854
1855+ if self .dim() == - 1 :
1856+ if certificate:
1857+ return (False , None )
1858+ return False
1859+
1860+ if self .dim() == 0 :
1861+ if certificate:
1862+ return (True , self .Vrepresentation()[0 ])
1863+ return True
1864+
18381865 # Find a vertex that is incident to all elements in Hrepresentation but one.
18391866 vertex_iter = self ._face_iter(True , 0 )
18401867 n_facets = self .n_facets()
You can’t perform that action at this time.
0 commit comments