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

Commit

Permalink
cached the results; opted out when discovering not 2-simple/simplicial
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Oct 16, 2019
1 parent 9f6f172 commit 6ec5053
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ cdef class CombinatorialPolyhedron(SageObject):
cdef ListOfFaces _far_face # a 'face' containing all none-vertices of Vrepr
cdef tuple _far_face_tuple
cdef tuple _f_vector
cdef _simpliciality
cdef _simpliness

# Edges, ridges and incidences are stored in a pointer of pointers.
# The first edge has vertices ``edges[0][0]`` and ``edges[0][1]``,
Expand Down
14 changes: 14 additions & 0 deletions src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,9 @@ cdef class CombinatorialPolyhedron(SageObject):
sage: CombinatorialPolyhedron(P).simpliciality()
1
"""
if self._simpliciality:
return smallInteger(self._simpliciality)

if not self.is_bounded():
raise NotImplementedError("must be bounded")
cdef FaceIterator face_iter = self._face_iter(False, -2)
Expand All @@ -1180,6 +1183,10 @@ cdef class CombinatorialPolyhedron(SageObject):
if simpliciality > d - 1:
simpliciality = d - 1
d = face_iter.next_dimension()
if simpliciality == 1:
# Every polytope is 1-simplicial.
d = dim
self._simpliciality = simpliciality
return smallInteger(simpliciality)

def simpliness(self):
Expand Down Expand Up @@ -1215,6 +1222,9 @@ cdef class CombinatorialPolyhedron(SageObject):
sage: CombinatorialPolyhedron(P).simpliness()
1
"""
if self._simpliness:
return smallInteger(self._simpliness)

if not self.is_bounded():
raise NotImplementedError("must be bounded")
cdef FaceIterator face_iter = self._face_iter(True, -2)
Expand All @@ -1240,6 +1250,10 @@ cdef class CombinatorialPolyhedron(SageObject):
if simpliness > d - 1:
simpliness = d - 1
d = face_iter.next_dimension()
if simpliness == 1:
# Every polytope is 1-simple.
d = dim
self._simpliness = simpliness
return smallInteger(simpliness)

def face_iter(self, dimension=None, dual=None):
Expand Down

0 comments on commit 6ec5053

Please sign in to comment.