Skip to content

Commit

Permalink
Trac #28605: CombinatorialPolyhedron: replace attributes by methods
Browse files Browse the repository at this point in the history
Replace attributes in `CombinatorialPolyhedron` by methods, such that
they can potentially be lazily evaluated.

More precisely we replace an attribute by a private attribute (with
leading `_`) and add a method without leading `_`. E.g. the attribute
`far_face_tuple` is replaced by `_far_face_tuple` and we add a method
`far_face_tuple(self)`. Thus we gain flexibility in the sense that those
attributes must not be set on initialization.

This is motivated by #10777.

We remove the attribute `Vinv` completely, as it is not being used.

URL: https://trac.sagemath.org/28605
Reported by: gh-kliem
Ticket author(s): Jonathan Kliem
Reviewer(s): Laith Rastanawi, Jean-Philippe Labbé
  • Loading branch information
Release Manager committed Nov 16, 2019
2 parents 133435b + d4b3163 commit 3a35510
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 81 deletions.
21 changes: 16 additions & 5 deletions src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd
Expand Up @@ -8,19 +8,19 @@ from .polyhedron_face_lattice cimport PolyhedronFaceLattice

@cython.final
cdef class CombinatorialPolyhedron(SageObject):
# Do not assume any of those attributes to be initialized, use the corresponding methods instead.
cdef tuple _V # the names of VRep, if they exist
cdef dict _Vinv # dictionary to look up enumeration of vertices
cdef tuple _H # the names of HRep, if they exist
cdef tuple _equalities # stores equalities, given on input (might belong to Hrep)
cdef int _dimension # stores dimension, -2 on init
cdef unsigned int _length_Hrepr # Hrepr might include equalities
cdef unsigned int _length_Vrepr # Vrepr might include rays/lines
cdef size_t _n_facets # length Hrep without equalities
cdef bint _unbounded # ``True`` iff Polyhedron is unbounded
cdef ListOfFaces bitrep_facets # facets in bit representation
cdef ListOfFaces bitrep_Vrepr # vertices in bit representation
cdef ListOfFaces far_face # a 'face' containing all none-vertices of Vrepr
cdef tuple far_face_tuple
cdef ListOfFaces _bitrep_facets # facets in bit representation
cdef ListOfFaces _bitrep_Vrepr # vertices in bit representation
cdef ListOfFaces _far_face # a 'face' containing all none-vertices of Vrepr
cdef tuple _far_face_tuple
cdef tuple _f_vector

# Edges, ridges and incidences are stored in a pointer of pointers.
Expand All @@ -40,6 +40,17 @@ cdef class CombinatorialPolyhedron(SageObject):
cdef size_t _n_face_lattice_incidences
cdef PolyhedronFaceLattice _all_faces # class to generate Hasse diagram incidences

cdef tuple V(self)
cdef tuple H(self)
cdef tuple equalities(self)
cdef unsigned int length_Vrepr(self)
cdef unsigned int length_Hrepr(self)
cdef bint unbounded(self)
cdef ListOfFaces bitrep_facets(self)
cdef ListOfFaces bitrep_Vrepr(self)
cdef ListOfFaces far_face(self)
cdef tuple far_face_tuple(self)

# Space for edges, ridges, etc. is allocated with ``MemoryAllocators``.
# Upon success they are copied to ``_mem_tuple``.
# Thus deallocation (at the correct time) is taken care of.
Expand Down

0 comments on commit 3a35510

Please sign in to comment.