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

Commit

Permalink
unbounded -> bounded, bounded(self) -> is_bounded(self)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Sep 10, 2019
1 parent c18a757 commit 4d165f5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cdef class CombinatorialPolyhedron(SageObject):
cdef unsigned int _length_Hrep # Hrep might include equalities
cdef unsigned int _length_Vrep # Vrep might include rays/lines
cdef size_t _n_facets # length Hrep without equalities
cdef bint _unbounded # ``True`` iff Polyhedron is unbounded
cdef bint _bounded # ``True`` iff Polyhedron is bounded
cdef ListOfFaces _bitrep_facets # facets in bit representation
cdef ListOfFaces _bitrep_Vrep # vertices in bit representation
cdef ListOfFaces _far_face # a 'face' containing all none-vertices of Vrep
Expand Down Expand Up @@ -47,7 +47,7 @@ cdef class CombinatorialPolyhedron(SageObject):
cdef tuple equalities(self)
cdef unsigned int length_Vrep(self)
cdef unsigned int length_Hrep(self)
cdef bint unbounded(self)
cdef bint is_bounded(self)
cdef ListOfFaces bitrep_facets(self)
cdef ListOfFaces bitrep_Vrep(self)
cdef ListOfFaces far_face(self)
Expand Down
42 changes: 21 additions & 21 deletions src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,15 @@ cdef class CombinatorialPolyhedron(SageObject):
self._dimension = data.dimension()

if not data.is_compact():
self._unbounded = True
self._bounded = False
far_face = tuple(i for i in range(data.n_Vrepresentation()) if not data.Vrepresentation()[i].is_vertex())
else:
self._unbounded = False
self._bounded = True

data = data.incidence_matrix()
elif isinstance(data, LatticePolytopeClass):
# input is ``LatticePolytope``
self._unbounded = False
self._bounded = True
Vrep = data.vertices()
self._length_Vrep = len(Vrep)
facets = data.facets()
Expand All @@ -330,11 +330,11 @@ cdef class CombinatorialPolyhedron(SageObject):
# Input is different from ``Polyhedron`` and ``LatticePolytope``.
if not unbounded:
# bounded polyhedron
self._unbounded = False
self._bounded = True
elif not far_face:
raise ValueError("must specify far face for unbounded polyhedron")
else:
self._unbounded = True
self._bounded = False

if Vrep:
# store vertices names
Expand Down Expand Up @@ -375,8 +375,8 @@ cdef class CombinatorialPolyhedron(SageObject):

self._n_facets = self.bitrep_facets().n_faces

# Initialize far_face if unbounded.
if self._unbounded:
# Initialize far_face if not bounded.
if not self._bounded:
self._far_face = facets_tuple_to_bit_rep_of_facets((tuple(far_face),), self._length_Vrep)
else:
self._far_face = None
Expand Down Expand Up @@ -434,13 +434,13 @@ cdef class CombinatorialPolyhedron(SageObject):
# Initializing the Vrep as their Bit-representation.
self._bitrep_Vrep = facets_tuple_to_bit_rep_of_Vrep(facets, length_Vrep)

# Initialize far_face if unbounded.
if self._unbounded:
# Initialize far_face if not unbounded.
if not self._bounded:
self._far_face = facets_tuple_to_bit_rep_of_facets((tuple(far_face),), length_Vrep)
else:
self._far_face = None

if self._unbounded:
if not self._bounded:
self._far_face_tuple = tuple(far_face)
else:
self._far_face_tuple = ()
Expand Down Expand Up @@ -530,7 +530,7 @@ cdef class CombinatorialPolyhedron(SageObject):
True
"""
# Give a constructor by list of facets.
if self.unbounded():
if not self.is_bounded():
return (CombinatorialPolyhedron, (self.facets(),
self.Vrepresentation(), self.Hrepresentation(),
True, self.far_face_tuple()))
Expand Down Expand Up @@ -602,7 +602,7 @@ cdef class CombinatorialPolyhedron(SageObject):
# exactly one "vertex" and for each dimension one "line" as in
# :class:`~sage.geometry.polyhedron.parent.Polyhedron_base`
self._dimension = self.length_Vrep() - 1
elif self.unbounded() or self.n_facets() <= self.length_Vrep():
elif not self.is_bounded() or self.n_facets() <= self.length_Vrep():
self._dimension = self.bitrep_facets().compute_dimension()
else:
# If the polyhedron has many facets,
Expand Down Expand Up @@ -654,7 +654,7 @@ cdef class CombinatorialPolyhedron(SageObject):
if self.dimension() == 0:
# This specific trivial polyhedron needs special attention.
return smallInteger(1)
if self.unbounded():
if not self.is_bounded():
# Some elements in the ``Vrep`` might not correspond to actual combinatorial vertices.
return len(self.vertices())
else:
Expand Down Expand Up @@ -713,7 +713,7 @@ cdef class CombinatorialPolyhedron(SageObject):
return (self.V()[0],)
else:
return (smallInteger(0),)
if self.unbounded():
if not self.is_bounded():
it = self.face_iter(0)
try:
# The Polyhedron has at least one vertex.
Expand Down Expand Up @@ -893,7 +893,7 @@ cdef class CombinatorialPolyhedron(SageObject):
cdef size_t len_edge_list = self._length_edges_list
if self._edges is NULL:
# compute the edges.
if self.unbounded():
if not self.is_bounded():
self._compute_edges(dual=False)
elif self.length_Vrep() > self.n_facets()*self.n_facets():
# This is a wild estimate
Expand Down Expand Up @@ -1051,7 +1051,7 @@ cdef class CombinatorialPolyhedron(SageObject):
cdef size_t len_ridge_list = self._length_edges_list
if self._ridges is NULL:
# compute the ridges.
if self.unbounded():
if not self.is_bounded():
self._compute_ridges(dual=False)
elif self.length_Vrep()*self.length_Vrep() < self.n_facets():
# This is a wild estimate
Expand Down Expand Up @@ -1248,7 +1248,7 @@ cdef class CombinatorialPolyhedron(SageObject):
cdef FaceIterator face_iter
if dual is None:
# Determine the faster way, to iterate through all faces.
if self.unbounded() or self.n_facets() <= self.length_Vrep():
if not self.is_bounded() or self.n_facets() <= self.length_Vrep():
dual = False
else:
dual = True
Expand All @@ -1265,7 +1265,7 @@ cdef class CombinatorialPolyhedron(SageObject):
See :meth:`CombinatorialPolyhedron.face_iter`
"""
if dual and self.unbounded():
if dual and not self.is_bounded():
raise ValueError("cannot iterate over dual of unbounded polyhedron")
if dimension == -2:
return FaceIterator(self, dual)
Expand Down Expand Up @@ -1478,8 +1478,8 @@ cdef class CombinatorialPolyhedron(SageObject):
cdef unsigned int length_Hrep(self):
return self._length_Hrep

cdef bint unbounded(self):
return self._unbounded
cdef bint is_bounded(self):
return self._bounded

cdef ListOfFaces bitrep_facets(self):
return self._bitrep_facets
Expand All @@ -1503,7 +1503,7 @@ cdef class CombinatorialPolyhedron(SageObject):
return 0 # There is no need to recompute the f_vector.

cdef bint dual
if self.unbounded() or self.n_facets() <= self.length_Vrep():
if not self.is_bounded() or self.n_facets() <= self.length_Vrep():
# In this case the non-dual approach is faster..
dual = False
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ cdef class FaceIterator(SageObject):
sage: TestSuite(sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator.FaceIterator).run()
"""
if dual and C._unbounded:
if dual and not C.is_bounded():
raise ValueError("cannot iterate over dual of unbounded Polyedron")
cdef int i
cdef ListOfFaces some_list # make Cython aware of type
Expand Down Expand Up @@ -477,7 +477,7 @@ cdef class FaceIterator(SageObject):
self.visited_all = <uint64_t **> self._mem.allocarray(self.coatoms.n_faces, sizeof(uint64_t *))
self.n_visited_all = <size_t *> self._mem.allocarray(self.dimension, sizeof(size_t))
self.n_visited_all[self.dimension -1] = 0
if C.unbounded():
if not C.is_bounded():
# Treating the far face as if we had visited all its elements.
# Hence we will visit all intersections of facets unless contained in the far face.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ cdef class PolyhedronFaceLattice:
self.dual = False
if C.bitrep_facets().n_faces > C.bitrep_Vrep().n_faces:
self.dual = True
if C.unbounded():
if not C.is_bounded():
self.dual = False
cdef FaceIterator face_iter = C._face_iter(self.dual, -2)
self.face_length = face_iter.face_length
Expand Down

0 comments on commit 4d165f5

Please sign in to comment.