From c18a7573d3d1d68e2cd13ec77f3f98f6fcfdeedd Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Tue, 10 Sep 2019 15:31:17 +0200 Subject: [PATCH] abbreavations: Hrepr -> Hrep, Vrepr -> Vrep etc. --- .../combinatorial_polyhedron/base.pxd | 14 +- .../combinatorial_polyhedron/base.pyx | 222 ++++++++--------- .../bit_vector_operations.cc | 2 +- .../bit_vector_operations.pxd | 2 +- .../combinatorial_face.pxd | 12 +- .../combinatorial_face.pyx | 128 +++++----- .../combinatorial_polyhedron/conversions.pxd | 6 +- .../combinatorial_polyhedron/conversions.pyx | 228 +++++++++--------- .../face_iterator.pxd | 10 +- .../face_iterator.pyx | 74 +++--- .../list_of_faces.pyx | 44 ++-- .../polyhedron_face_lattice.pxd | 10 +- .../polyhedron_face_lattice.pyx | 74 +++--- 13 files changed, 413 insertions(+), 413 deletions(-) diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd index c3febc3390c..b17432ea503 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd @@ -14,13 +14,13 @@ cdef class CombinatorialPolyhedron(SageObject): 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 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 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 ListOfFaces _bitrep_Vrep # vertices in bit representation + cdef ListOfFaces _far_face # a 'face' containing all none-vertices of Vrep cdef tuple _far_face_tuple cdef tuple _f_vector @@ -45,11 +45,11 @@ cdef class CombinatorialPolyhedron(SageObject): cdef dict Vinv(self) cdef tuple H(self) cdef tuple equalities(self) - cdef unsigned int length_Vrepr(self) - cdef unsigned int length_Hrepr(self) + cdef unsigned int length_Vrep(self) + cdef unsigned int length_Hrep(self) cdef bint unbounded(self) cdef ListOfFaces bitrep_facets(self) - cdef ListOfFaces bitrep_Vrepr(self) + cdef ListOfFaces bitrep_Vrep(self) cdef ListOfFaces far_face(self) cdef tuple far_face_tuple(self) diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx index d56b8bcd52c..e30cd589dbe 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx @@ -11,18 +11,18 @@ the ridges and the face lattice. Terminology used in this module: -- Vrepr -- ``[vertices, rays, lines]`` of the polyhedron. -- Hrepr -- inequalities and equalities of the polyhedron. +- Vrep -- ``[vertices, rays, lines]`` of the polyhedron. +- Hrep -- inequalities and equalities of the polyhedron. - Facets -- facets of the polyhedron. -- Vrepresentation -- represents a face by the list of Vrepr it contains. -- Hrepresentation -- represents a face by a list of Hrepr it is contained in. +- Vrepresentation -- represents a face by the list of Vrep it contains. +- Hrepresentation -- represents a face by a list of Hrep it is contained in. - bit representation -- represents incidences as ``uint64_t``-array, where each bit represents one incidence. There might be trailing zeros, to fit alignment requirements. In most instances, faces are represented by the bit representation, where each bit corresponds to - a Vrepr or facet. Thus a bit representation can either be - a Vrepr or facet representation depending on context. + a Vrep or facet. Thus a bit representation can either be + a Vrep or facet representation depending on context. EXAMPLES: @@ -94,10 +94,10 @@ from sage.geometry.lattice_polytope import LatticePolytopeClass from sage.structure.element import Matrix from sage.misc.misc import is_iterator from .conversions \ - import incidence_matrix_to_bit_repr_of_facets, \ - incidence_matrix_to_bit_repr_of_Vrepr, \ - facets_tuple_to_bit_repr_of_facets, \ - facets_tuple_to_bit_repr_of_Vrepr + import incidence_matrix_to_bit_rep_of_facets, \ + incidence_matrix_to_bit_rep_of_Vrep, \ + facets_tuple_to_bit_rep_of_facets, \ + facets_tuple_to_bit_rep_of_Vrep from sage.rings.integer cimport smallInteger from cysignals.signals cimport sig_check, sig_block, sig_unblock @@ -116,7 +116,7 @@ cdef class CombinatorialPolyhedron(SageObject): * or a :class:`~sage.geometry.lattice_polytope.LatticePolytopeClass` * or an ``incidence_matrix`` as in :meth:`~sage.geometry.polyhedron.base.Polyhedron_base.incidence_matrix` - In this case you should also specify the ``Vrepr`` and ``facets`` arguments + In this case you should also specify the ``Vrep`` and ``facets`` arguments * or list of facets, each facet given as a list of ``[vertices, rays, lines]`` if the polyhedron is unbounded, then rays and lines and the extra argument ``nr_lines`` are required @@ -126,7 +126,7 @@ cdef class CombinatorialPolyhedron(SageObject): rays and lines. * or an integer, representing the dimension of a polyhedron equal to its affine hull - - ``Vrepr`` -- (optional) when ``data`` is an incidence matrix, it should + - ``Vrep`` -- (optional) when ``data`` is an incidence matrix, it should be the list of ``[vertices, rays, lines]``, if the rows in the incidence_matrix should correspond to names - ``facets`` -- (optional) when ``data`` is an incidence matrix or a list of facets, @@ -162,7 +162,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: far_face = [i for i in range(2) if not P.Vrepresentation()[i].is_vertex()] sage: CombinatorialPolyhedron(data, unbounded=True, far_face=far_face) A 1-dimensional combinatorial polyhedron with 1 facet - sage: C = CombinatorialPolyhedron(data, Vrepr=['myvertex'], + sage: C = CombinatorialPolyhedron(data, Vrep=['myvertex'], ....: facets=['myfacet'], unbounded=True, far_face=far_face) sage: C.Vrepresentation() ('myvertex',) @@ -202,7 +202,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: data = P.incidence_matrix() sage: vert = P.Vrepresentation() - sage: C = CombinatorialPolyhedron(data, Vrepr=vert) + sage: C = CombinatorialPolyhedron(data, Vrep=vert) sage: C A 2-dimensional combinatorial polyhedron with 2 facets sage: C.f_vector() @@ -213,7 +213,7 @@ cdef class CombinatorialPolyhedron(SageObject): The correct usage is:: sage: far_face = [i for i in range(3) if not P.Vrepresentation()[i].is_vertex()] - sage: C = CombinatorialPolyhedron(data, Vrepr=vert, unbounded=True, far_face=far_face) + sage: C = CombinatorialPolyhedron(data, Vrep=vert, unbounded=True, far_face=far_face) sage: C A 2-dimensional combinatorial polyhedron with 2 facets sage: C.f_vector() @@ -252,7 +252,7 @@ cdef class CombinatorialPolyhedron(SageObject): (A vertex at (0, 0),) sage: data = P.incidence_matrix() sage: vert = P.Vrepresentation() - sage: C = CombinatorialPolyhedron(data, Vrepr=vert) + sage: C = CombinatorialPolyhedron(data, Vrep=vert) sage: C A 2-dimensional combinatorial polyhedron with 2 facets sage: C.f_vector() @@ -262,7 +262,7 @@ cdef class CombinatorialPolyhedron(SageObject): A ray in the direction (0, 1), A ray in the direction (1, 0)) sage: far_face = [i for i in range(3) if not P.Vrepresentation()[i].is_vertex()] - sage: C = CombinatorialPolyhedron(data, Vrepr=vert, unbounded=True, far_face=far_face) + sage: C = CombinatorialPolyhedron(data, Vrep=vert, unbounded=True, far_face=far_face) sage: C A 2-dimensional combinatorial polyhedron with 2 facets sage: C.f_vector() @@ -274,7 +274,7 @@ cdef class CombinatorialPolyhedron(SageObject): """ - def __init__(self, data, Vrepr=None, facets=None, unbounded=False, far_face=None): + def __init__(self, data, Vrep=None, facets=None, unbounded=False, far_face=None): r""" Initialize :class:`CombinatorialPolyhedron`. @@ -306,7 +306,7 @@ cdef class CombinatorialPolyhedron(SageObject): if isinstance(data, Polyhedron_base): # input is ``Polyhedron`` - Vrepr = data.Vrepresentation() + Vrep = data.Vrepresentation() facets = tuple(inequality for inequality in data.Hrepresentation()) self._dimension = data.dimension() @@ -320,10 +320,10 @@ cdef class CombinatorialPolyhedron(SageObject): elif isinstance(data, LatticePolytopeClass): # input is ``LatticePolytope`` self._unbounded = False - Vrepr = data.vertices() - self._length_Vrepr = len(Vrepr) + Vrep = data.vertices() + self._length_Vrep = len(Vrep) facets = data.facets() - self._length_Hrepr = len(facets) + self._length_Hrep = len(facets) data = tuple(tuple(vert for vert in facet.vertices()) for facet in facets) else: @@ -336,9 +336,9 @@ cdef class CombinatorialPolyhedron(SageObject): else: self._unbounded = True - if Vrepr: + if Vrep: # store vertices names - self._V = tuple(Vrepr) + self._V = tuple(Vrep) self._Vinv = {v: i for i,v in enumerate(self._V)} else: self._V = None @@ -364,20 +364,20 @@ cdef class CombinatorialPolyhedron(SageObject): if isinstance(data, Matrix): # Input is incidence-matrix or was converted to it. - self._length_Hrepr = data.ncols() - self._length_Vrepr = data.nrows() + self._length_Hrep = data.ncols() + self._length_Vrep = data.nrows() # Initializing the facets in their Bit-representation. - self._bitrep_facets = incidence_matrix_to_bit_repr_of_facets(data) + self._bitrep_facets = incidence_matrix_to_bit_rep_of_facets(data) - # Initializing the Vrepr as their Bit-representation. - self._bitrep_Vrepr = incidence_matrix_to_bit_repr_of_Vrepr(data) + # Initializing the Vrep as their Bit-representation. + self._bitrep_Vrep = incidence_matrix_to_bit_rep_of_Vrep(data) self._n_facets = self.bitrep_facets().n_faces # Initialize far_face if unbounded. if self._unbounded: - self._far_face = facets_tuple_to_bit_repr_of_facets((tuple(far_face),), self._length_Vrepr) + self._far_face = facets_tuple_to_bit_rep_of_facets((tuple(far_face),), self._length_Vrep) else: self._far_face = None @@ -390,10 +390,10 @@ cdef class CombinatorialPolyhedron(SageObject): self._dimension = data # Initializing the facets in their Bit-representation. - self._bitrep_facets = facets_tuple_to_bit_repr_of_facets((), 0) + self._bitrep_facets = facets_tuple_to_bit_rep_of_facets((), 0) - # Initializing the Vrepr as their Bit-representation. - self._bitrep_Vrepr = facets_tuple_to_bit_repr_of_Vrepr((), 0) + # Initializing the Vrep as their Bit-representation. + self._bitrep_Vrep = facets_tuple_to_bit_rep_of_Vrep((), 0) self._far_face = None @@ -405,20 +405,20 @@ cdef class CombinatorialPolyhedron(SageObject): data = tuple(data) if self._V is None: - # Get the names of the Vrepr. - Vrepr = sorted(set.union(*map(set, data))) - length_Vrepr = len(Vrepr) - if Vrepr != range(len(Vrepr)): - self._V = tuple(Vrepr) + # Get the names of the Vrep. + Vrep = sorted(set.union(*map(set, data))) + length_Vrep = len(Vrep) + if Vrep != range(len(Vrep)): + self._V = tuple(Vrep) self._Vinv = {v: i for i,v in enumerate(self._V)} else: # Assuming the user gave as correct names for the vertices # and labeled them instead by `0,...,n`. - length_Vrepr = len(self._V) + length_Vrep = len(self._V) - self._length_Vrepr = length_Vrepr + self._length_Vrep = length_Vrep - # Relabel the Vrepr to be `0,...,n`. + # Relabel the Vrep to be `0,...,n`. if self._V is not None: def f(v): return self._Vinv[v] else: @@ -426,17 +426,17 @@ cdef class CombinatorialPolyhedron(SageObject): facets = tuple(tuple(f(i) for i in j) for j in data) self._n_facets = len(facets) - self._length_Hrepr = len(facets) + self._length_Hrep = len(facets) # Initializing the facets in their Bit-representation. - self._bitrep_facets = facets_tuple_to_bit_repr_of_facets(facets, length_Vrepr) + self._bitrep_facets = facets_tuple_to_bit_rep_of_facets(facets, length_Vrep) - # Initializing the Vrepr as their Bit-representation. - self._bitrep_Vrepr = facets_tuple_to_bit_repr_of_Vrepr(facets, length_Vrepr) + # 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: - self._far_face = facets_tuple_to_bit_repr_of_facets((tuple(far_face),), length_Vrepr) + self._far_face = facets_tuple_to_bit_rep_of_facets((tuple(far_face),), length_Vrep) else: self._far_face = None @@ -493,8 +493,8 @@ cdef class CombinatorialPolyhedron(SageObject): sage: C1 = loads(C.dumps()) sage: it = C.face_iter() sage: it1 = C1.face_iter() - sage: tup = tuple((face.Vrepr(), face.Hrepr()) for face in it) - sage: tup1 = tuple((face.Vrepr(), face.Hrepr()) for face in it1) + sage: tup = tuple((face.Vrep(), face.Hrep()) for face in it) + sage: tup1 = tuple((face.Vrep(), face.Hrep()) for face in it1) sage: tup == tup1 True @@ -503,8 +503,8 @@ cdef class CombinatorialPolyhedron(SageObject): sage: C1 = loads(C.dumps()) sage: it = C.face_iter() sage: it1 = C1.face_iter() - sage: tup = tuple((face.Vrepr(), face.Hrepr()) for face in it) - sage: tup1 = tuple((face.Vrepr(), face.Hrepr()) for face in it1) + sage: tup = tuple((face.Vrep(), face.Hrep()) for face in it) + sage: tup1 = tuple((face.Vrep(), face.Hrep()) for face in it1) sage: tup == tup1 True @@ -513,8 +513,8 @@ cdef class CombinatorialPolyhedron(SageObject): sage: C1 = loads(C.dumps()) sage: it = C.face_iter() sage: it1 = C1.face_iter() - sage: tup = tuple((face.Vrepr(), face.Hrepr()) for face in it) - sage: tup1 = tuple((face.Vrepr(), face.Hrepr()) for face in it1) + sage: tup = tuple((face.Vrep(), face.Hrep()) for face in it) + sage: tup1 = tuple((face.Vrep(), face.Hrep()) for face in it1) sage: tup == tup1 True @@ -524,8 +524,8 @@ cdef class CombinatorialPolyhedron(SageObject): sage: C1 = loads(C.dumps()) sage: it = C.face_iter() sage: it1 = C1.face_iter() - sage: tup = tuple((face.Vrepr(), face.Hrepr()) for face in it) - sage: tup1 = tuple((face.Vrepr(), face.Hrepr()) for face in it1) + sage: tup = tuple((face.Vrep(), face.Hrep()) for face in it) + sage: tup1 = tuple((face.Vrep(), face.Hrep()) for face in it1) sage: tup == tup1 True """ @@ -556,7 +556,7 @@ cdef class CombinatorialPolyhedron(SageObject): if self.V() is not None: return self.V() else: - return tuple(smallInteger(i) for i in range(self.length_Vrepr())) + return tuple(smallInteger(i) for i in range(self.length_Vrep())) def Hrepresentation(self): r""" @@ -578,7 +578,7 @@ cdef class CombinatorialPolyhedron(SageObject): if self.H() is not None: return self.equalities() + self.H() else: - return tuple(smallInteger(i) for i in range(self.length_Hrepr())) + return tuple(smallInteger(i) for i in range(self.length_Hrep())) def dimension(self): r""" @@ -601,8 +601,8 @@ cdef class CombinatorialPolyhedron(SageObject): # The dimension of a trivial polyhedron is assumed to contain # exactly one "vertex" and for each dimension one "line" as in # :class:`~sage.geometry.polyhedron.parent.Polyhedron_base` - self._dimension = self.length_Vrepr() - 1 - elif self.unbounded() or self.n_facets() <= self.length_Vrepr(): + self._dimension = self.length_Vrep() - 1 + elif self.unbounded() or self.n_facets() <= self.length_Vrep(): self._dimension = self.bitrep_facets().compute_dimension() else: # If the polyhedron has many facets, @@ -655,10 +655,10 @@ cdef class CombinatorialPolyhedron(SageObject): # This specific trivial polyhedron needs special attention. return smallInteger(1) if self.unbounded(): - # Some elements in the ``Vrepr`` might not correspond to actual combinatorial vertices. + # Some elements in the ``Vrep`` might not correspond to actual combinatorial vertices. return len(self.vertices()) else: - return smallInteger(self.length_Vrepr()) + return smallInteger(self.length_Vrep()) def vertices(self, names=True): r""" @@ -717,7 +717,7 @@ cdef class CombinatorialPolyhedron(SageObject): it = self.face_iter(0) try: # The Polyhedron has at least one vertex. - # In this case every element in the ``Vrepr`` + # In this case every element in the ``Vrep`` # that is not contained in the far face # is a vertex. next(it) @@ -725,9 +725,9 @@ cdef class CombinatorialPolyhedron(SageObject): # The Polyhedron has no vertex. return () if names and self.V(): - return tuple(self.V()[i] for i in range(self.length_Vrepr()) if not i in self.far_face_tuple()) + return tuple(self.V()[i] for i in range(self.length_Vrep()) if not i in self.far_face_tuple()) else: - return tuple(smallInteger(i) for i in range(self.length_Vrepr()) if not i in self.far_face_tuple()) + return tuple(smallInteger(i) for i in range(self.length_Vrep()) if not i in self.far_face_tuple()) def n_facets(self): r""" @@ -829,8 +829,8 @@ cdef class CombinatorialPolyhedron(SageObject): face_iter = self.face_iter(self.dimension() - 1, dual=False) facets = [None] * self.n_facets() for face in face_iter: - index = face.Hrepr(names=False)[0] - verts = face.Vrepr(names=names) + index = face.Hrep(names=False)[0] + verts = face.Vrep(names=names) facets[index] = verts return tuple(facets) @@ -895,7 +895,7 @@ cdef class CombinatorialPolyhedron(SageObject): # compute the edges. if self.unbounded(): self._compute_edges(dual=False) - elif self.length_Vrepr() > self.n_facets()*self.n_facets(): + elif self.length_Vrep() > self.n_facets()*self.n_facets(): # This is a wild estimate # that in this case it is better not to use the dual. self._compute_edges(dual=False) @@ -914,7 +914,7 @@ cdef class CombinatorialPolyhedron(SageObject): # Hence, edges are stored in an array of arrays, # with each array containing ``len_edge_list`` of edges. - # Mapping the indices of the Vrepr to the names, if requested. + # Mapping the indices of the Vrep to the names, if requested. if self.V() is not None and names is True: def f(size_t i): return self.V()[i] else: @@ -1037,7 +1037,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: C.ridges() () sage: it = C.face_iter(0) - sage: for face in it: face.Hrepr() + sage: for face in it: face.Hrep() (An inequality (1, 0) x + 0 >= 0, An equation (0, 1) x + 0 == 0) TESTS: @@ -1053,7 +1053,7 @@ cdef class CombinatorialPolyhedron(SageObject): # compute the ridges. if self.unbounded(): self._compute_ridges(dual=False) - elif self.length_Vrepr()*self.length_Vrepr() < self.n_facets(): + elif self.length_Vrep()*self.length_Vrep() < self.n_facets(): # This is a wild estimate # that in this case it is better to use the dual. self._compute_edges(dual=True) @@ -1120,7 +1120,7 @@ cdef class CombinatorialPolyhedron(SageObject): Graph on 2 vertices """ face_iter = self.face_iter(self.dimension() - 1, dual=False) - V = list(facet.Hrepr(names=names) for facet in face_iter) + V = list(facet.Hrep(names=names) for facet in face_iter) E = self.ridges(names=names, add_equalities=True) return Graph([V, E], format="vertices_and_edges") @@ -1189,34 +1189,34 @@ cdef class CombinatorialPolyhedron(SageObject): sage: it = C.face_iter(dimension=2) sage: face = next(it); face A 2-dimensional face of a 4-dimensional combinatorial polyhedron - sage: face.Vrepr() + sage: face.Vrep() (A vertex at (4, 1, 5, 2, 3), A vertex at (4, 2, 5, 1, 3), A vertex at (5, 1, 4, 2, 3), A vertex at (5, 2, 4, 1, 3)) sage: face = next(it); face A 2-dimensional face of a 4-dimensional combinatorial polyhedron - sage: face.Vrepr() + sage: face.Vrep() (A vertex at (4, 1, 5, 2, 3), A vertex at (4, 1, 5, 3, 2), A vertex at (5, 1, 4, 2, 3), A vertex at (5, 1, 4, 3, 2)) - sage: face.Hrepr() + sage: face.Hrep() (An inequality (0, 1, 0, 0, 0) x - 1 >= 0, An inequality (0, 1, 0, 1, 1) x - 6 >= 0, An equation (1, 1, 1, 1, 1) x - 15 == 0) - sage: face.Hrepr(names=False) + sage: face.Hrep(names=False) (25, 29) sage: face = next(it); face A 2-dimensional face of a 4-dimensional combinatorial polyhedron - sage: face.Hrepr(names=False) + sage: face.Hrep(names=False) (12, 29) - sage: face.Vrepr(names=False) + sage: face.Vrep(names=False) (76, 77, 82, 83, 88, 89) sage: C = CombinatorialPolyhedron([[0,1,2],[0,1,3],[0,2,3],[1,2,3]]) sage: it = C.face_iter() - sage: for face in it: face.Vrepr() + sage: for face in it: face.Vrep() (1, 2, 3) (0, 2, 3) (0, 1, 3) @@ -1235,7 +1235,7 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = Polyhedron(rays=[[1,0],[0,1]], vertices=[[1,0],[0,1]]) sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter(1) - sage: for face in it: face.Vrepr() + sage: for face in it: face.Vrep() (A vertex at (0, 1), A vertex at (1, 0)) (A ray in the direction (1, 0), A vertex at (1, 0)) (A ray in the direction (0, 1), A vertex at (0, 1)) @@ -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_Vrepr(): + if self.unbounded() or self.n_facets() <= self.length_Vrep(): dual = False else: dual = True @@ -1448,7 +1448,7 @@ cdef class CombinatorialPolyhedron(SageObject): A 1-dimensional face of a 2-dimensional combinatorial polyhedron, A 2-dimensional face of a 2-dimensional combinatorial polyhedron) - sage: def f(i): return C.face_by_face_lattice_index(i).Vrepr(False) + sage: def f(i): return C.face_by_face_lattice_index(i).Vrep(False) sage: G = F.relabel(f) sage: G._elements ((), (0,), (0, 1), (0, 2), (0, 1, 2)) @@ -1472,11 +1472,11 @@ cdef class CombinatorialPolyhedron(SageObject): cdef tuple equalities(self): return self._equalities - cdef unsigned int length_Vrepr(self): - return self._length_Vrepr + cdef unsigned int length_Vrep(self): + return self._length_Vrep - cdef unsigned int length_Hrepr(self): - return self._length_Hrepr + cdef unsigned int length_Hrep(self): + return self._length_Hrep cdef bint unbounded(self): return self._unbounded @@ -1484,8 +1484,8 @@ cdef class CombinatorialPolyhedron(SageObject): cdef ListOfFaces bitrep_facets(self): return self._bitrep_facets - cdef ListOfFaces bitrep_Vrepr(self): - return self._bitrep_Vrepr + cdef ListOfFaces bitrep_Vrep(self): + return self._bitrep_Vrep cdef ListOfFaces far_face(self): return self._far_face @@ -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_Vrepr(): + if self.unbounded() or self.n_facets() <= self.length_Vrep(): # In this case the non-dual approach is faster.. dual = False else: @@ -1645,12 +1645,12 @@ cdef class CombinatorialPolyhedron(SageObject): edges[one] = mem.allocarray(2 * len_edge_list, sizeof(size_t)) - # Set up face_iter.atom_repr - face_iter.set_atom_repr() + # Set up face_iter.atom_rep + face_iter.set_atom_rep() # Copy the information. - edges[one][2*two] = face_iter.atom_repr[0] - edges[one][2*two + 1] = face_iter.atom_repr[1] + edges[one][2*two] = face_iter.atom_rep[0] + edges[one][2*two + 1] = face_iter.atom_rep[1] counter += 1 # Success, copy the data to ``CombinatorialPolyhedron``. @@ -1697,12 +1697,12 @@ cdef class CombinatorialPolyhedron(SageObject): edges[one] = mem.allocarray(2 * len_edge_list, sizeof(size_t)) - # Set up face_iter.atom_repr - face_iter.set_atom_repr() + # Set up face_iter.atom_rep + face_iter.set_atom_rep() # Copy the information. - edges[one][2*two] = face_iter.atom_repr[0] - edges[one][2*two + 1] = face_iter.atom_repr[1] + edges[one][2*two] = face_iter.atom_rep[0] + edges[one][2*two + 1] = face_iter.atom_rep[1] counter += 1 d = face_iter.next_dimension() # Go to next face. @@ -1818,12 +1818,12 @@ cdef class CombinatorialPolyhedron(SageObject): ridges[one] = mem.allocarray(2 * len_ridge_list, sizeof(size_t)) - # Set up face_iter.coatom_repr - face_iter.set_coatom_repr() + # Set up face_iter.coatom_rep + face_iter.set_coatom_rep() # Copy the information. - ridges[one][2*two] = face_iter.coatom_repr[0] - ridges[one][2*two + 1] = face_iter.coatom_repr[1] + ridges[one][2*two] = face_iter.coatom_rep[0] + ridges[one][2*two + 1] = face_iter.coatom_rep[1] counter += 1 # Success, copy the data to ``CombinatorialPolyhedron``. @@ -1962,30 +1962,30 @@ cdef class CombinatorialPolyhedron(SageObject): sage: P = polytopes.permutahedron(4) sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter() - sage: tup = tuple((face.Vrepr(),face.Hrepr()) for face in it) + sage: tup = tuple((face.Vrep(),face.Hrep()) for face in it) sage: rg = range(1,sum(C.f_vector()) - 1) - sage: tup2 = tuple((C.face_by_face_lattice_index(i).Vrepr(), - ....: C.face_by_face_lattice_index(i).Hrepr()) for i in rg) + sage: tup2 = tuple((C.face_by_face_lattice_index(i).Vrep(), + ....: C.face_by_face_lattice_index(i).Hrep()) for i in rg) sage: sorted(tup) == sorted(tup2) True sage: P = polytopes.cyclic_polytope(4,10) sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter() - sage: tup = tuple((face.Vrepr(),face.Hrepr()) for face in it) + sage: tup = tuple((face.Vrep(),face.Hrep()) for face in it) sage: rg = range(1,sum(C.f_vector()) - 1) - sage: tup2 = tuple((C.face_by_face_lattice_index(i).Vrepr(), - ....: C.face_by_face_lattice_index(i).Hrepr()) for i in rg) + sage: tup2 = tuple((C.face_by_face_lattice_index(i).Vrep(), + ....: C.face_by_face_lattice_index(i).Hrep()) for i in rg) sage: sorted(tup) == sorted(tup2) True sage: P = Polyhedron(rays=[[1,0,0], [-1,0,0], [0,-1,0]]) sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter() - sage: tup = tuple((face.Vrepr(),face.Hrepr()) for face in it) + sage: tup = tuple((face.Vrep(),face.Hrep()) for face in it) sage: rg = range(1,sum(C.f_vector()) - 1) - sage: tup2 = tuple((C.face_by_face_lattice_index(i).Vrepr(), - ....: C.face_by_face_lattice_index(i).Hrepr()) for i in rg) + sage: tup2 = tuple((C.face_by_face_lattice_index(i).Vrep(), + ....: C.face_by_face_lattice_index(i).Hrep()) for i in rg) sage: sorted(tup) == sorted(tup2) True @@ -1993,10 +1993,10 @@ cdef class CombinatorialPolyhedron(SageObject): ....: [0,-1,0], [0,1,0]]) sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter() - sage: tup = tuple((face.Vrepr(),face.Hrepr()) for face in it) + sage: tup = tuple((face.Vrep(),face.Hrep()) for face in it) sage: rg = range(1,sum(C.f_vector()) - 1) - sage: tup2 = tuple((C.face_by_face_lattice_index(i).Vrepr(), - ....: C.face_by_face_lattice_index(i).Hrepr()) for i in rg) + sage: tup2 = tuple((C.face_by_face_lattice_index(i).Vrep(), + ....: C.face_by_face_lattice_index(i).Hrep()) for i in rg) sage: sorted(tup) == sorted(tup2) True """ diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc b/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc index 96fd8c187a8..b896914c987 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc @@ -170,7 +170,7 @@ size_t get_next_level(\ return n_newfaces; } -size_t bit_repr_to_coatom_repr(uint64_t *face, uint64_t **coatoms, \ +size_t bit_rep_to_coatom_rep(uint64_t *face, uint64_t **coatoms, \ size_t n_coatoms, size_t face_length, \ size_t *output){ /* diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.pxd index e5533730820..ad4e8dd129d 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.pxd @@ -54,7 +54,7 @@ cdef extern from "bit_vector_operations.cc": # This is the number of set bits in A. # ``face_length`` is the length of A in terms of uint64_t. - cdef size_t bit_repr_to_coatom_repr( + cdef size_t bit_rep_to_coatom_rep( uint64_t *face, uint64_t **coatoms, size_t n_coatoms, size_t face_length, size_t *output) # Write the coatom-representation of face in output. Return length. diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd index 9372acae5c1..b4df9499945 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd @@ -9,11 +9,11 @@ from .face_iterator cimport FaceIterator cdef class CombinatorialFace(SageObject): cdef readonly bint _dual # if 1, then iterate over dual Polyhedron cdef ListOfFaces face_mem # constructing face - cdef uint64_t *face # the face in bit-repr + cdef uint64_t *face # the face in bit-rep cdef MemoryAllocator _mem - cdef size_t *atom_repr # a place where atom-representaion of face will be stored - cdef size_t *coatom_repr # a place where coatom-representaion of face will be stored + cdef size_t *atom_rep # a place where atom-representaion of face will be stored + cdef size_t *coatom_rep # a place where coatom-representaion of face will be stored cdef int _dimension # dimension of current face, dual dimension if ``dual`` cdef int _ambient_dimension # dimension of the polyhedron cdef size_t face_length # stores length of the faces in terms of uint64_t @@ -24,6 +24,6 @@ cdef class CombinatorialFace(SageObject): # If ``dual == 0``, then coatoms are facets, atoms vertices and vice versa. cdef ListOfFaces atoms, coatoms - cdef size_t length_atom_repr(self) except -1 - cdef size_t set_coatom_repr(self) except -1 - cdef size_t set_atom_repr(self) except -1 + cdef size_t length_atom_rep(self) except -1 + cdef size_t set_coatom_rep(self) except -1 + cdef size_t set_atom_rep(self) except -1 diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx index 8f0a22f501c..1d612517d79 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx @@ -34,11 +34,11 @@ Obtain further information regarding a face:: sage: it = C.face_iter(2) sage: face = next(it); face A 2-dimensional face of a 3-dimensional combinatorial polyhedron - sage: face.Vrepr() + sage: face.Vrep() (A vertex at (0, 0, 1), A vertex at (0, 1, 0), A vertex at (1, 0, 0)) - sage: face.length_Vrepr() + sage: face.length_Vrep() 3 - sage: face.Hrepr(names=False) + sage: face.Hrep(names=False) (5,) sage: face.dimension() 2 @@ -68,9 +68,9 @@ from __future__ import absolute_import, division, print_function import numbers from sage.rings.integer cimport smallInteger -from .conversions cimport bit_repr_to_Vrepr_list +from .conversions cimport bit_rep_to_Vrep_list from .base cimport CombinatorialPolyhedron -from .bit_vector_operations cimport count_atoms, bit_repr_to_coatom_repr +from .bit_vector_operations cimport count_atoms, bit_rep_to_coatom_rep from .polyhedron_face_lattice cimport PolyhedronFaceLattice from libc.string cimport memcpy @@ -112,16 +112,16 @@ cdef class CombinatorialFace(SageObject): The Vrepresentation:: - sage: face.Vrepr() + sage: face.Vrep() (A vertex at (6, 36, 216, 1296, 7776),) - sage: face.Vrepr(names=False) + sage: face.Vrep(names=False) (6,) - sage: face.length_Vrepr() + sage: face.length_Vrep() 1 The Hrepresentation:: - sage: face.Hrepr() + sage: face.Hrep() (An inequality (60, -112, 65, -14, 1) x + 0 >= 0, An inequality (180, -216, 91, -16, 1) x + 0 >= 0, An inequality (360, -342, 119, -18, 1) x + 0 >= 0, @@ -133,9 +133,9 @@ cdef class CombinatorialFace(SageObject): An inequality (-844, 567, -163, 21, -1) x + 420 >= 0, An inequality (84, -152, 83, -16, 1) x + 0 >= 0, An inequality (-210, 317, -125, 19, -1) x + 0 >= 0) - sage: face.Hrepr(names=False) + sage: face.Hrep(names=False) (3, 4, 5, 6, 7, 8, 9, 10, 11, 18, 19) - sage: face.length_Hrepr() + sage: face.length_Hrep() 11 """ def __init__(self, data, dimension=None, index=None): @@ -311,7 +311,7 @@ cdef class CombinatorialFace(SageObject): """ return smallInteger(self._ambient_dimension) - def Vrepr(self, names=True): + def Vrep(self, names=True): r""" Return the vertex-representation of the current face. @@ -329,25 +329,25 @@ cdef class CombinatorialFace(SageObject): sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter(dimension=2) sage: face = next(it) - sage: face.Vrepr() + sage: face.Vrep() (A vertex at (4, 1, 5, 2, 3), A vertex at (4, 2, 5, 1, 3), A vertex at (5, 1, 4, 2, 3), A vertex at (5, 2, 4, 1, 3)) sage: face = next(it) - sage: face.Vrepr() + sage: face.Vrep() (A vertex at (4, 1, 5, 2, 3), A vertex at (4, 1, 5, 3, 2), A vertex at (5, 1, 4, 2, 3), A vertex at (5, 1, 4, 3, 2)) - sage: next(it).Vrepr(False) + sage: next(it).Vrep(False) (76, 77, 82, 83, 88, 89) - sage: next(it).Vrepr(False) + sage: next(it).Vrep(False) (77, 83, 101, 107) sage: C = CombinatorialPolyhedron([[0,1,2],[0,1,3],[0,2,3],[1,2,3]]) sage: it = C.face_iter() - sage: for face in it: (face.dimension(), face.Vrepr()) + sage: for face in it: (face.dimension(), face.Vrep()) (2, (1, 2, 3)) (2, (0, 2, 3)) (2, (0, 1, 3)) @@ -366,43 +366,43 @@ cdef class CombinatorialFace(SageObject): cdef size_t length if self._dual: # if dual, the Vrepresenation corresponds to the coatom-representation - length = self.set_coatom_repr() + length = self.set_coatom_rep() if names and self._V: - return tuple(self._V[self.coatom_repr[i]] + return tuple(self._V[self.coatom_rep[i]] for i in range(length)) else: - return tuple(smallInteger(self.coatom_repr[i]) + return tuple(smallInteger(self.coatom_rep[i]) for i in range(length)) else: # if not dual, the Vrepresenation corresponds to the atom-representation - length = self.set_atom_repr() + length = self.set_atom_rep() if names and self._V: - return tuple(self._V[self.atom_repr[i]] + return tuple(self._V[self.atom_rep[i]] for i in range(length)) else: - return tuple(smallInteger(self.atom_repr[i]) + return tuple(smallInteger(self.atom_rep[i]) for i in range(length)) - def length_Vrepr(self): + def length_Vrep(self): r""" Return the length of the face. - Might be faster than `len(self.Vrepr())`. + Might be faster than `len(self.Vrep())`. EXAMPLES:: sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter() - sage: all(face.length_Vrepr() == len(face.Vrepr()) for face in it) + sage: all(face.length_Vrep() == len(face.Vrep()) for face in it) True """ if self._dual: - return smallInteger(self.set_coatom_repr()) + return smallInteger(self.set_coatom_rep()) else: - return smallInteger(self.length_atom_repr()) + return smallInteger(self.length_atom_rep()) - def Hrepr(self, names=True): + def Hrep(self, names=True): r""" Return the Hrepresentation of the face. @@ -424,48 +424,48 @@ cdef class CombinatorialFace(SageObject): sage: P = polytopes.permutahedron(5) sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter(2) - sage: next(it).Hrepr() + sage: next(it).Hrep() (An inequality (0, 1, 0, 1, 0) x - 3 >= 0, An inequality (0, 1, 0, 1, 1) x - 6 >= 0, An equation (1, 1, 1, 1, 1) x - 15 == 0) - sage: next(it).Hrepr() + sage: next(it).Hrep() (An inequality (0, 1, 0, 0, 0) x - 1 >= 0, An inequality (0, 1, 0, 1, 1) x - 6 >= 0, An equation (1, 1, 1, 1, 1) x - 15 == 0) - sage: next(it).Hrepr(False) + sage: next(it).Hrep(False) (12, 29) - sage: next(it).Hrepr(False) + sage: next(it).Hrep(False) (6, 29) sage: P = polytopes.cyclic_polytope(4,6) sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter() - sage: next(it).Hrepr() + sage: next(it).Hrep() (An inequality (-20, 29, -10, 1) x + 0 >= 0, An inequality (60, -47, 12, -1) x + 0 >= 0, An inequality (30, -31, 10, -1) x + 0 >= 0, An inequality (10, -17, 8, -1) x + 0 >= 0, An inequality (-154, 71, -14, 1) x + 120 >= 0, An inequality (-78, 49, -12, 1) x + 40 >= 0) - sage: next(it).Hrepr() + sage: next(it).Hrep() (An inequality (-50, 35, -10, 1) x + 24 >= 0, An inequality (-12, 19, -8, 1) x + 0 >= 0, An inequality (-20, 29, -10, 1) x + 0 >= 0, An inequality (60, -47, 12, -1) x + 0 >= 0, An inequality (-154, 71, -14, 1) x + 120 >= 0, An inequality (-78, 49, -12, 1) x + 40 >= 0) - sage: next(it).Hrepr(False) + sage: next(it).Hrep(False) (0, 1, 2, 4, 5, 7) - sage: next(it).Hrepr(False) + sage: next(it).Hrep(False) (0, 1, 5, 6, 7, 8) - sage: next(it).Hrepr(False) + sage: next(it).Hrep(False) (0, 1, 2, 3, 6, 8) sage: [next(it).dimension() for _ in range(2)] [0, 1] sage: face = next(it) - sage: face.Hrepr(False) + sage: face.Hrep(False) (4, 5, 7) - sage: face.Hrepr() + sage: face.Hrep() (An inequality (60, -47, 12, -1) x + 0 >= 0, An inequality (30, -31, 10, -1) x + 0 >= 0, An inequality (-154, 71, -14, 1) x + 120 >= 0) @@ -473,43 +473,43 @@ cdef class CombinatorialFace(SageObject): cdef size_t length if not self._dual: # if not dual, the facet-represention corresponds to the coatom-representation - length = self.set_coatom_repr() # fill self.coatom_repr_face + length = self.set_coatom_rep() # fill self.coatom_rep_face if names and self._H: - return tuple(self._H[self.coatom_repr[i]] + return tuple(self._H[self.coatom_rep[i]] for i in range(length)) + self._equalities else: - return tuple(smallInteger(self.coatom_repr[i]) + return tuple(smallInteger(self.coatom_rep[i]) for i in range(length)) else: # if dual, the facet-represention corresponds to the atom-representation - length = self.set_atom_repr() # fill self.atom_repr_face + length = self.set_atom_rep() # fill self.atom_rep_face if names and self._H: - return tuple(self._H[self.atom_repr[i]] + return tuple(self._H[self.atom_rep[i]] for i in range(length)) + self._equalities else: - return tuple(smallInteger(self.atom_repr[i]) + return tuple(smallInteger(self.atom_rep[i]) for i in range(length)) - def length_Hrepr(self): + def length_Hrep(self): r""" - Returns the length of the :meth:`Hrepr`. + Returns the length of the :meth:`Hrep`. - Might be faster than ``len(self.Hrepr())``. + Might be faster than ``len(self.Hrep())``. EXAMPLES:: sage: P = polytopes.cube() sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter() - sage: all(face.length_Hrepr() == len(face.Hrepr()) for face in it) + sage: all(face.length_Hrep() == len(face.Hrep()) for face in it) True """ if not self._dual: - return smallInteger(self.set_coatom_repr()) + return smallInteger(self.set_coatom_rep()) else: - return smallInteger(self.length_atom_repr()) + return smallInteger(self.length_atom_rep()) - cdef size_t length_atom_repr(self) except -1: + cdef size_t length_atom_rep(self) except -1: r""" Compute the number of atoms in the current face by counting the number of set bits. @@ -520,26 +520,26 @@ cdef class CombinatorialFace(SageObject): # The face was not initialized properly. raise LookupError("``FaceIterator`` does not point to a face") - cdef size_t set_coatom_repr(self) except -1: + cdef size_t set_coatom_rep(self) except -1: r""" - Set ``coatom_repr`` to be the coatom-representation of the current face. + Set ``coatom_rep`` to be the coatom-representation of the current face. Return its length. """ cdef size_t n_coatoms = self.coatoms.n_faces cdef uint64_t **coatoms = self.coatoms.data cdef size_t face_length = self.face_length - if not self.coatom_repr: - self.coatom_repr = self._mem.allocarray(self.coatoms.n_faces, sizeof(size_t)) - return bit_repr_to_coatom_repr(self.face, coatoms, n_coatoms, - face_length, self.coatom_repr) + if not self.coatom_rep: + self.coatom_rep = self._mem.allocarray(self.coatoms.n_faces, sizeof(size_t)) + return bit_rep_to_coatom_rep(self.face, coatoms, n_coatoms, + face_length, self.coatom_rep) - cdef size_t set_atom_repr(self) except -1: + cdef size_t set_atom_rep(self) except -1: r""" - Set ``atom_repr`` to be the atom-representation of the current face. + Set ``atom_rep`` to be the atom-representation of the current face. Return its length. """ cdef size_t face_length = self.face_length - if not self.atom_repr: - self.atom_repr = self._mem.allocarray(self.coatoms.n_atoms, sizeof(size_t)) - return bit_repr_to_Vrepr_list(self.face, self.atom_repr, face_length) + if not self.atom_rep: + self.atom_rep = self._mem.allocarray(self.coatoms.n_atoms, sizeof(size_t)) + return bit_rep_to_Vrep_list(self.face, self.atom_rep, face_length) diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd index 7ba717c3736..e36e0c2eb73 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd @@ -1,10 +1,10 @@ from libc.stdint cimport uint64_t -cdef int Vrepr_list_to_bit_repr(tuple Vrepr_list, uint64_t *output, +cdef int Vrep_list_to_bit_rep(tuple Vrep_list, uint64_t *output, size_t face_length) except -1 -cdef int incidences_to_bit_repr(tuple incidences, uint64_t *output, +cdef int incidences_to_bit_rep(tuple incidences, uint64_t *output, size_t face_length) except -1 -cdef size_t bit_repr_to_Vrepr_list(uint64_t *face, size_t *output, +cdef size_t bit_rep_to_Vrep_list(uint64_t *face, size_t *output, size_t face_length) except -1 diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx index e8a9e36008d..d84dae9ff5f 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx @@ -20,10 +20,10 @@ EXAMPLES: Obtain the facets of a polyhedron as :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces.ListOfFaces`:: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import incidence_matrix_to_bit_repr_of_facets + ....: import incidence_matrix_to_bit_rep_of_facets sage: P = polytopes.simplex(4) - sage: face_list = incidence_matrix_to_bit_repr_of_facets(P.incidence_matrix()) - sage: face_list = incidence_matrix_to_bit_repr_of_facets(P.incidence_matrix()) + sage: face_list = incidence_matrix_to_bit_rep_of_facets(P.incidence_matrix()) + sage: face_list = incidence_matrix_to_bit_rep_of_facets(P.incidence_matrix()) sage: face_list.compute_dimension() 4 @@ -31,25 +31,25 @@ Obtain the Vrepresentation of a polyhedron as facet-incidences stored in :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces.ListOfFaces`:: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import incidence_matrix_to_bit_repr_of_Vrepr + ....: import incidence_matrix_to_bit_rep_of_Vrep sage: P = polytopes.associahedron(['A',4]) - sage: face_list = incidence_matrix_to_bit_repr_of_Vrepr(P.incidence_matrix()) + sage: face_list = incidence_matrix_to_bit_rep_of_Vrep(P.incidence_matrix()) sage: face_list.compute_dimension() 4 Obtain the facets of a polyhedron as :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces.ListOfFaces` from a facet list:: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import facets_tuple_to_bit_repr_of_facets + ....: import facets_tuple_to_bit_rep_of_facets sage: facets = ((0,1,2), (0,1,3), (0,2,3), (1,2,3)) - sage: face_list = facets_tuple_to_bit_repr_of_facets(facets, 4) + sage: face_list = facets_tuple_to_bit_rep_of_facets(facets, 4) -Likewise for the Vrepr as facet-incidences:: +Likewise for the Vrep as facet-incidences:: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import facets_tuple_to_bit_repr_of_Vrepr + ....: import facets_tuple_to_bit_rep_of_Vrep sage: facets = ((0,1,2), (0,1,3), (0,2,3), (1,2,3)) - sage: face_list = facets_tuple_to_bit_repr_of_Vrepr(facets, 4) + sage: face_list = facets_tuple_to_bit_rep_of_Vrep(facets, 4) AUTHOR: @@ -83,7 +83,7 @@ cdef inline uint64_t vertex_to_bit_dictionary(size_t i): """ return (1) << (64 - i - 1) -cdef int Vrepr_list_to_bit_repr(tuple Vrepr_list, uint64_t *output, +cdef int Vrep_list_to_bit_rep(tuple Vrep_list, uint64_t *output, size_t face_length) except -1: r""" Convert a vertex list into Bit-representation. Store it in ``output``. @@ -107,38 +107,38 @@ cdef int Vrepr_list_to_bit_repr(tuple Vrepr_list, uint64_t *output, sage: cython(''' ....: from libc.stdint cimport uint64_t ....: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: cimport Vrepr_list_to_bit_repr + ....: cimport Vrep_list_to_bit_rep ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: from sage.rings.integer cimport smallInteger ....: - ....: def Vrepr_list_to_bit_repr_wrapper(tup): + ....: def Vrep_list_to_bit_rep_wrapper(tup): ....: cdef size_t face_length = max(tup)//64 + 1 ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef uint64_t *output = mem.allocarray(face_length, 8) - ....: Vrepr_list_to_bit_repr(tup, output, face_length) + ....: Vrep_list_to_bit_rep(tup, output, face_length) ....: return tuple(smallInteger(output[i]) for i in range(face_length)) ....: - ....: def Vrepr_list_to_bit_repr_wrong_size(tup): + ....: def Vrep_list_to_bit_rep_wrong_size(tup): ....: cdef size_t face_length = 1 ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef uint64_t *output = mem.allocarray(face_length, 8) - ....: Vrepr_list_to_bit_repr(tup, output, face_length) + ....: Vrep_list_to_bit_rep(tup, output, face_length) ....: return tuple(smallInteger(output[i]) for i in range(face_length)) ....: ''') # long time - sage: Vrepr_list_to_bit_repr_wrapper((62, 63)) # long time + sage: Vrep_list_to_bit_rep_wrapper((62, 63)) # long time (3,) - sage: Vrepr_list_to_bit_repr_wrapper((61, 63, 125)) # long time + sage: Vrep_list_to_bit_rep_wrapper((61, 63, 125)) # long time (5, 4) - sage: Vrepr_list_to_bit_repr_wrong_size((62, 70)) # long time + sage: Vrep_list_to_bit_rep_wrong_size((62, 70)) # long time Traceback (most recent call last): ... IndexError: output too small to represent 70 - sage: Vrepr_list_to_bit_repr_wrapper((-1, 12)) # long time + sage: Vrep_list_to_bit_rep_wrapper((-1, 12)) # long time Traceback (most recent call last): ... OverflowError: can't convert negative value to size_t - sage: Vrepr_list_to_bit_repr_wrapper((0, 0)) # long time + sage: Vrep_list_to_bit_rep_wrapper((0, 0)) # long time Traceback (most recent call last): ... ValueError: entries of ``tup`` are not distinct @@ -148,16 +148,16 @@ cdef int Vrepr_list_to_bit_repr(tuple Vrepr_list, uint64_t *output, cdef size_t value # determines which bit will be set in output[position] memset(output, 0, face_length*8) # initialize output - if unlikely(len(Vrepr_list) != len(set(Vrepr_list))): + if unlikely(len(Vrep_list) != len(set(Vrep_list))): raise ValueError("entries of ``tup`` are not distinct") - for entry in Vrepr_list: + for entry in Vrep_list: value = entry % 64 position = entry//64 if unlikely(position >= face_length): raise IndexError("output too small to represent %s"%entry) output[position] += vertex_to_bit_dictionary(value) -cdef int incidences_to_bit_repr(tuple incidences, uint64_t *output, +cdef int incidences_to_bit_rep(tuple incidences, uint64_t *output, size_t face_length) except -1: r""" @@ -182,35 +182,35 @@ cdef int incidences_to_bit_repr(tuple incidences, uint64_t *output, sage: cython(''' ....: from libc.stdint cimport uint64_t ....: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: cimport incidences_to_bit_repr + ....: cimport incidences_to_bit_rep ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: from sage.rings.integer cimport smallInteger ....: - ....: def incidences_to_bit_reprs_wrapper(tup): + ....: def incidences_to_bit_reps_wrapper(tup): ....: cdef size_t face_length = (len(tup)-1)//64 + 1 ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef uint64_t *output = \ ....: mem.allocarray(face_length, 8) - ....: incidences_to_bit_repr(tup, output, face_length) + ....: incidences_to_bit_rep(tup, output, face_length) ....: return tuple(smallInteger(output[i]) for i in range(face_length)) ....: - ....: def incidences_to_bit_reprs_wrong_size(tup): + ....: def incidences_to_bit_reps_wrong_size(tup): ....: cdef size_t face_length = 1 ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef uint64_t *output = \ ....: mem.allocarray(face_length, 8) - ....: incidences_to_bit_repr(tup, output, face_length) + ....: incidences_to_bit_rep(tup, output, face_length) ....: return tuple(smallInteger(output[i]) for i in range(face_length)) ....: ''') # long time - sage: incidences_to_bit_reprs_wrapper((0,) * 62 + (1,1)) # long time + sage: incidences_to_bit_reps_wrapper((0,) * 62 + (1,1)) # long time (3,) - sage: incidences_to_bit_reprs_wrapper((0,) * 61 + (1,0,1) + # long time + sage: incidences_to_bit_reps_wrapper((0,) * 61 + (1,0,1) + # long time ....: (0,) * 61 + (1,)) (5, 4) - sage: incidences_to_bit_reprs_wrapper((1,) * 64) # long time + sage: incidences_to_bit_reps_wrapper((1,) * 64) # long time (-1,) - sage: incidences_to_bit_reprs_wrong_size((1,) * 70) # long time + sage: incidences_to_bit_reps_wrong_size((1,) * 70) # long time Traceback (most recent call last): ... IndexError: output too small to represent all incidences @@ -225,12 +225,12 @@ cdef int incidences_to_bit_repr(tuple incidences, uint64_t *output, raise IndexError("output too small to represent all incidences") for entry in range(length): if incidences[entry]: - # Vrepr ``entry`` is contained in the face, so set the corresponding bit + # Vrep ``entry`` is contained in the face, so set the corresponding bit value = entry % 64 position = entry//64 output[position] += vertex_to_bit_dictionary(value) -def incidence_matrix_to_bit_repr_of_facets(matrix): +def incidence_matrix_to_bit_rep_of_facets(matrix): r""" Initialize facets in Bit-representation as :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces.ListOfFaces`. @@ -249,33 +249,33 @@ def incidence_matrix_to_bit_repr_of_facets(matrix): ....: from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces \ ....: cimport ListOfFaces ....: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: cimport bit_repr_to_Vrepr_list + ....: cimport bit_rep_to_Vrep_list ....: from sage.rings.integer cimport smallInteger ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: from libc.stdint cimport uint64_t ....: - ....: def bit_repr_to_Vrepr_list_wrapper(list_of_faces, index): + ....: def bit_rep_to_Vrep_list_wrapper(list_of_faces, index): ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef size_t *output ....: cdef ListOfFaces faces = list_of_faces ....: output = mem.allocarray(faces.n_atoms, ....: sizeof(size_t)) ....: cdef uint64_t * data = faces.data[index] - ....: length = bit_repr_to_Vrepr_list( + ....: length = bit_rep_to_Vrep_list( ....: data, output, faces.face_length) ....: return tuple(smallInteger(output[i]) for i in range(length)) ....: ''') # long time sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import incidence_matrix_to_bit_repr_of_facets + ....: import incidence_matrix_to_bit_rep_of_facets sage: P = polytopes.permutahedron(4) - sage: facets = incidence_matrix_to_bit_repr_of_facets(P.incidence_matrix()) + sage: facets = incidence_matrix_to_bit_rep_of_facets(P.incidence_matrix()) sage: facets.n_faces 14 sage: facets.n_atoms 24 sage: for i in range(facets.n_faces): # long time - ....: print(bit_repr_to_Vrepr_list_wrapper(facets, i)) + ....: print(bit_rep_to_Vrep_list_wrapper(facets, i)) (18, 19, 20, 21, 22, 23) (9, 11, 15, 17, 21, 23) (16, 17, 22, 23) @@ -303,19 +303,19 @@ def incidence_matrix_to_bit_repr_of_facets(matrix): matrix = matrix[list(i for i in rg if not all(j for j in matrix[i]))] # Output will be a ``ListOfFaces`` with ``matrix.nrows()`` faces and - # ``matrix.ncols()`` Vrepr. + # ``matrix.ncols()`` Vrep. cdef size_t length = matrix.nrows() cdef ListOfFaces facets = ListOfFaces(length, matrix.ncols()) cdef uint64_t **facets_data = facets.data cdef size_t i for i in range(length): - # Filling each facet with its Vrepr-incidences, which "is" the + # Filling each facet with its Vrep-incidences, which "is" the # "i-th column" of the original matrix (but we have transposed). - incidences_to_bit_repr(tuple(matrix[i]), facets_data[i], facets.face_length) + incidences_to_bit_rep(tuple(matrix[i]), facets_data[i], facets.face_length) return facets -def incidence_matrix_to_bit_repr_of_Vrepr(matrix): +def incidence_matrix_to_bit_rep_of_Vrep(matrix): r""" Initialize Vrepresentatives in Bit-representation as :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces.ListOfFaces`. @@ -337,33 +337,33 @@ def incidence_matrix_to_bit_repr_of_Vrepr(matrix): ....: from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces \ ....: cimport ListOfFaces ....: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: cimport bit_repr_to_Vrepr_list + ....: cimport bit_rep_to_Vrep_list ....: from sage.rings.integer cimport smallInteger ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: from libc.stdint cimport uint64_t ....: - ....: def bit_repr_to_Vrepr_list_wrapper(list_of_faces, index): + ....: def bit_rep_to_Vrep_list_wrapper(list_of_faces, index): ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef size_t *output ....: cdef ListOfFaces faces = list_of_faces ....: output = mem.allocarray(faces.n_atoms, ....: sizeof(size_t)) ....: cdef uint64_t * data = faces.data[index] - ....: length = bit_repr_to_Vrepr_list( + ....: length = bit_rep_to_Vrep_list( ....: data, output, faces.face_length) ....: return tuple(smallInteger(output[i]) for i in range(length)) ....: ''') sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import incidence_matrix_to_bit_repr_of_Vrepr + ....: import incidence_matrix_to_bit_rep_of_Vrep sage: P = polytopes.permutahedron(4) - sage: vertices = incidence_matrix_to_bit_repr_of_Vrepr(P.incidence_matrix()) + sage: vertices = incidence_matrix_to_bit_rep_of_Vrep(P.incidence_matrix()) sage: vertices.n_faces 24 sage: vertices.n_atoms 14 sage: for i in range(vertices.n_faces): - ....: print(bit_repr_to_Vrepr_list_wrapper(vertices, i)) + ....: print(bit_rep_to_Vrep_list_wrapper(vertices, i)) (3, 5, 9) (3, 5, 8) (3, 4, 9) @@ -400,27 +400,27 @@ def incidence_matrix_to_bit_repr_of_Vrepr(matrix): matrix = matrix[list(i for i in rg if not all(j for j in matrix[i]))] # Output will be a ``ListOfFaces`` with ``matrix.ncols()`` faces and - # ``matrix.nrows()`` Vrepr. + # ``matrix.nrows()`` Vrep. cdef size_t length = matrix.ncols() - cdef ListOfFaces Vrepr = ListOfFaces(length, matrix.nrows()) - cdef uint64_t **Vrepr_data = Vrepr.data + cdef ListOfFaces Vrep = ListOfFaces(length, matrix.nrows()) + cdef uint64_t **Vrep_data = Vrep.data cdef size_t i for i in range(length): - # Filling each facet with its Vrepr-incidences, which "is" the + # Filling each facet with its Vrep-incidences, which "is" the # "i-th row" of the original matrix (but we have transposed). - incidences_to_bit_repr(tuple(matrix.column(i)), Vrepr_data[i], Vrepr.face_length) - return Vrepr + incidences_to_bit_rep(tuple(matrix.column(i)), Vrep_data[i], Vrep.face_length) + return Vrep -def facets_tuple_to_bit_repr_of_facets(tuple facets_input, size_t n_Vrepr): +def facets_tuple_to_bit_rep_of_facets(tuple facets_input, size_t n_Vrep): r""" Initializes facets in Bit-representation as :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces.ListOfFaces`. INPUT: - - ``facets_input`` -- tuple of facets, each facet a tuple of Vrepr, - Vrepr must be exactly ``range(n_Vrepr)`` - - ``n_Vrepr`` + - ``facets_input`` -- tuple of facets, each facet a tuple of Vrep, + Vrep must be exactly ``range(n_Vrep)`` + - ``n_Vrep`` OUTPUT: @@ -432,30 +432,30 @@ def facets_tuple_to_bit_repr_of_facets(tuple facets_input, size_t n_Vrepr): ....: from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces \ ....: cimport ListOfFaces ....: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: cimport bit_repr_to_Vrepr_list + ....: cimport bit_rep_to_Vrep_list ....: from sage.rings.integer cimport smallInteger ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: from libc.stdint cimport uint64_t ....: - ....: def bit_repr_to_Vrepr_list_wrapper(list_of_faces, index): + ....: def bit_rep_to_Vrep_list_wrapper(list_of_faces, index): ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef size_t *output ....: cdef ListOfFaces faces = list_of_faces ....: output = mem.allocarray(faces.n_atoms, ....: sizeof(size_t)) ....: cdef uint64_t * data = faces.data[index] - ....: length = bit_repr_to_Vrepr_list( + ....: length = bit_rep_to_Vrep_list( ....: data, output, faces.face_length) ....: return tuple(smallInteger(output[i]) for i in range(length)) ....: ''') # long time sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import facets_tuple_to_bit_repr_of_facets + ....: import facets_tuple_to_bit_rep_of_facets sage: bi_pyr = ((0,1,4), (1,2,4), (2,3,4), (3,0,4), ....: (0,1,5), (1,2,5), (2,3,5), (3,0,5)) - sage: facets = facets_tuple_to_bit_repr_of_facets(bi_pyr, 6) + sage: facets = facets_tuple_to_bit_rep_of_facets(bi_pyr, 6) sage: for i in range(8): # long time - ....: print(bit_repr_to_Vrepr_list_wrapper(facets, i)) + ....: print(bit_rep_to_Vrep_list_wrapper(facets, i)) (0, 1, 4) (1, 2, 4) (2, 3, 4) @@ -466,15 +466,15 @@ def facets_tuple_to_bit_repr_of_facets(tuple facets_input, size_t n_Vrepr): (0, 3, 5) """ cdef Py_ssize_t i - cdef ListOfFaces facets = ListOfFaces(len(facets_input), n_Vrepr) + cdef ListOfFaces facets = ListOfFaces(len(facets_input), n_Vrep) cdef size_t face_length = facets.face_length cdef uint64_t **facets_data = facets.data for i in range(len(facets_input)): # filling each facet with the the data from the corresponding facet - Vrepr_list_to_bit_repr(facets_input[i], facets_data[i], face_length) + Vrep_list_to_bit_rep(facets_input[i], facets_data[i], face_length) return facets -def facets_tuple_to_bit_repr_of_Vrepr(tuple facets_input, size_t n_Vrepr): +def facets_tuple_to_bit_rep_of_Vrep(tuple facets_input, size_t n_Vrep): r""" Initialize Vrepresentatives in Bit-representation as :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces.ListOfFaces`. @@ -483,9 +483,9 @@ def facets_tuple_to_bit_repr_of_Vrepr(tuple facets_input, size_t n_Vrepr): INPUT: - - ``facets_input`` -- tuple of facets, each facet a tuple of Vrepr, - Vrepr must be exactly ``range(n_Vrepr)`` - - ``n_Vrepr`` + - ``facets_input`` -- tuple of facets, each facet a tuple of Vrep, + Vrep must be exactly ``range(n_Vrep)`` + - ``n_Vrep`` OUTPUT: @@ -498,30 +498,30 @@ def facets_tuple_to_bit_repr_of_Vrepr(tuple facets_input, size_t n_Vrepr): ....: from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces \ ....: cimport ListOfFaces ....: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: cimport bit_repr_to_Vrepr_list + ....: cimport bit_rep_to_Vrep_list ....: from sage.rings.integer cimport smallInteger ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: from libc.stdint cimport uint64_t ....: - ....: def bit_repr_to_Vrepr_list_wrapper(list_of_faces, index): + ....: def bit_rep_to_Vrep_list_wrapper(list_of_faces, index): ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef size_t *output ....: cdef ListOfFaces faces = list_of_faces ....: output = mem.allocarray(faces.n_atoms, ....: sizeof(size_t)) ....: cdef uint64_t * data = faces.data[index] - ....: length = bit_repr_to_Vrepr_list( + ....: length = bit_rep_to_Vrep_list( ....: data, output, faces.face_length) ....: return tuple(smallInteger(output[i]) for i in range(length)) ....: ''') sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import facets_tuple_to_bit_repr_of_Vrepr + ....: import facets_tuple_to_bit_rep_of_Vrep sage: bi_pyr = ((0,1,4), (1,2,4), (2,3,4), (3,0,4), ....: (0,1,5), (1,2,5), (2,3,5), (3,0,5)) - sage: vertices = facets_tuple_to_bit_repr_of_Vrepr(bi_pyr, 6) + sage: vertices = facets_tuple_to_bit_rep_of_Vrep(bi_pyr, 6) sage: for i in range(6): - ....: print(bit_repr_to_Vrepr_list_wrapper(vertices, i)) + ....: print(bit_rep_to_Vrep_list_wrapper(vertices, i)) (0, 3, 4, 7) (0, 1, 4, 5) (1, 2, 5, 6) @@ -532,50 +532,50 @@ def facets_tuple_to_bit_repr_of_Vrepr(tuple facets_input, size_t n_Vrepr): cdef size_t n_facets = len(facets_input) # Vertices in facet-representation will be a ``ListOfFaces`` - # with number of Vrepr faces and - # number of facets "Vrepr"/atoms. - cdef ListOfFaces Vrepr = ListOfFaces(n_Vrepr, n_facets) - cdef uint64_t **Vrepr_data = Vrepr.data + # with number of Vrep faces and + # number of facets "Vrep"/atoms. + cdef ListOfFaces Vrep = ListOfFaces(n_Vrep, n_facets) + cdef uint64_t **Vrep_data = Vrep.data # Initializing the data of ListOfFaces. - cdef size_t face_length = Vrepr.face_length + cdef size_t face_length = Vrep.face_length cdef size_t i - for i in range(n_Vrepr): - memset(Vrepr_data[i], 0, face_length*8) + for i in range(n_Vrep): + memset(Vrep_data[i], 0, face_length*8) cdef size_t input_facet # will iterate over indices of facets_input cdef size_t position # determines the position in output of entry cdef size_t value # determines which bit will be set in output[position] - cdef size_t input_Vrepr # will iterate over vertices in facet ``input_facet`` + cdef size_t input_Vrep # will iterate over vertices in facet ``input_facet`` for input_facet in range(n_facets): value = input_facet % 64 position = input_facet//64 - for input_Vrepr in facets_input[input_facet]: - # Iff the input-Vrepr is in the input-facet, - # then in facet-representation of the Vrepr - # input-facet is a Vrepr of intput-Vrepr. - Vrepr_data[input_Vrepr][position] += vertex_to_bit_dictionary(value) - return Vrepr - -cdef inline size_t bit_repr_to_Vrepr_list(uint64_t *face, size_t *output, + for input_Vrep in facets_input[input_facet]: + # Iff the input-Vrep is in the input-facet, + # then in facet-representation of the Vrep + # input-facet is a Vrep of intput-Vrep. + Vrep_data[input_Vrep][position] += vertex_to_bit_dictionary(value) + return Vrep + +cdef inline size_t bit_rep_to_Vrep_list(uint64_t *face, size_t *output, size_t face_length) except -1: r""" - Convert a bitrep-representation to a list of Vrepr. Return length of representation. + Convert a bitrep-representation to a list of Vrep. Return length of representation. - Basically this is an inverse to :meth:`Vrepr_list_to_bit_repr`. - Instead of returning a tuple, it stores the Vrepr in ``output``. + Basically this is an inverse to :meth:`Vrep_list_to_bit_rep`. + Instead of returning a tuple, it stores the Vrep in ``output``. INPUT: - ``face`` -- a Bit-representation of a face - - ``output`` -- an array of ``size_t`` long enough to contain all Vrepr + - ``output`` -- an array of ``size_t`` long enough to contain all Vrep of that face (``face_length*64`` will suffice) - ``face_length`` -- the length of ``face`` OUTPUT: - - store Vrepr in ``output`` + - store Vrep in ``output`` - return "length" of ``output`` EXAMPLES:: @@ -584,12 +584,12 @@ cdef inline size_t bit_repr_to_Vrepr_list(uint64_t *face, size_t *output, ....: from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces \ ....: cimport ListOfFaces ....: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: cimport bit_repr_to_Vrepr_list, Vrepr_list_to_bit_repr + ....: cimport bit_rep_to_Vrep_list, Vrep_list_to_bit_rep ....: from sage.rings.integer cimport smallInteger ....: from sage.ext.memory_allocator cimport MemoryAllocator ....: from libc.stdint cimport uint64_t ....: - ....: def bit_repr_to_Vrepr_list_wrapper(tup): + ....: def bit_rep_to_Vrep_list_wrapper(tup): ....: cdef MemoryAllocator mem = MemoryAllocator() ....: cdef size_t *output ....: cdef length = len(tup) @@ -599,27 +599,27 @@ cdef inline size_t bit_repr_to_Vrepr_list(uint64_t *face, size_t *output, ....: data = mem.allocarray(length, 8) ....: for i in range(len(tup)): ....: data[i] = tup[i] - ....: outputlength = bit_repr_to_Vrepr_list( + ....: outputlength = bit_rep_to_Vrep_list( ....: data, output, length) ....: return tuple(smallInteger(output[i]) for i in range(outputlength)) ....: ''') # long time - sage: bit_repr_to_Vrepr_list_wrapper((17, 31)) # long time + sage: bit_rep_to_Vrep_list_wrapper((17, 31)) # long time (59, 63, 123, 124, 125, 126, 127) - sage: bit_repr_to_Vrepr_list_wrapper((13,)) # long time + sage: bit_rep_to_Vrep_list_wrapper((13,)) # long time (60, 61, 63) - sage: bit_repr_to_Vrepr_list_wrapper((0, 61)) # long time + sage: bit_rep_to_Vrep_list_wrapper((0, 61)) # long time (122, 123, 124, 125, 127) TESTS: - Testing that :meth`bit_repr_to_Vrepr_list` is the - inverse to :meth:`Vrepr_list_to_bit_repr`:: + Testing that :meth`bit_rep_to_Vrep_list` is the + inverse to :meth:`Vrep_list_to_bit_rep`:: sage: cython(''' ....: from libc.stdint cimport uint64_t ....: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: cimport bit_repr_to_Vrepr_list, Vrepr_list_to_bit_repr + ....: cimport bit_rep_to_Vrep_list, Vrep_list_to_bit_rep ....: from sage.misc.prandom import randint ....: ....: cdef uint64_t[2] face @@ -629,12 +629,12 @@ cdef inline size_t bit_repr_to_Vrepr_list(uint64_t *face, size_t *output, ....: for _ in range(10): ....: st = set(randint(0,127) for i in range(40)) ....: tup = tuple(sorted(tuple(st))) - ....: Vrepr_list_to_bit_repr(tup, face, 2) - ....: length = bit_repr_to_Vrepr_list(face, output, 2) + ....: Vrep_list_to_bit_rep(tup, face, 2) + ....: length = bit_rep_to_Vrep_list(face, output, 2) ....: tup2 = tuple(output[i] for i in range(length)) ....: if not tup == tup2: - ....: print('``bit_repr_to_Vrepr_list`` does not behave', - ....: 'as the inverse of ``Vrepr_list_to_bit_repr``') + ....: print('``bit_rep_to_Vrep_list`` does not behave', + ....: 'as the inverse of ``Vrep_list_to_bit_rep``') ....: ''') # long time """ cdef size_t i, j @@ -646,7 +646,7 @@ cdef inline size_t bit_repr_to_Vrepr_list(uint64_t *face, size_t *output, for j in range(64): if copy >= vertex_to_bit_dictionary(j): # Then face[i] has the j-th bit set to 1. - # This corresponds to face containing Vrepr i*64 + j. + # This corresponds to face containing Vrep i*64 + j. output[output_length] = i*64 + j output_length += 1 copy -= vertex_to_bit_dictionary(j) diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd index 1d3bacf095f..6ccca1374c9 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd @@ -9,8 +9,8 @@ from .combinatorial_face cimport CombinatorialFace cdef class FaceIterator(SageObject): cdef readonly bint dual # if 1, then iterate over dual Polyhedron cdef uint64_t *face # the current face of the iterator - cdef size_t *atom_repr # a place where atom-representaion of face will be stored - cdef size_t *coatom_repr # a place where coatom-representaion of face will be stored + cdef size_t *atom_rep # a place where atom-representaion of face will be stored + cdef size_t *coatom_rep # a place where coatom-representaion of face will be stored cdef int current_dimension # dimension of current face, dual dimension if ``dual`` cdef int dimension # dimension of the polyhedron cdef int output_dimension # only faces of this (dual?) dimension are considered @@ -63,6 +63,6 @@ cdef class FaceIterator(SageObject): cdef inline CombinatorialFace next_face(self) cdef inline int next_dimension(self) except -1 cdef inline int next_face_loop(self) except -1 - cdef size_t length_atom_repr(self) except -1 - cdef size_t set_coatom_repr(self) except -1 - cdef size_t set_atom_repr(self) except -1 + cdef size_t length_atom_rep(self) except -1 + cdef size_t set_coatom_rep(self) except -1 + cdef size_t set_atom_rep(self) except -1 diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx index 20f1688e5e8..fd169886599 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx @@ -11,14 +11,14 @@ A (slightly generalized) description of the algorithm can be found in [KS2019]_. Terminology in this module: - Coatoms -- the faces from which all others are constructed in - the face iterator. This will be facets or Vrepr. + the face iterator. This will be facets or Vrep. In non-dual mode, faces are constructed as intersections of the facets. In dual mode, the are constructed theoretically as joins of vertices. - The coatoms are reprsented as incidences with the + The coatoms are repsented as incidences with the atoms they contain. -- Atoms -- facets or Vrepr depending on application of algorithm. - Atoms are reprsented as incidences of coatoms they +- Atoms -- facets or Vrep depending on application of algorithm. + Atoms are repsented as incidences of coatoms they are contained in. .. SEEALSO:: @@ -69,33 +69,33 @@ Obtain the Vrepresentation:: sage: it = FaceIterator(C, False) sage: face = next(it) - sage: face.Vrepr() + sage: face.Vrep() (A vertex at (0, -1, 0), A vertex at (0, 0, -1), A vertex at (1, 0, 0)) - sage: face.length_Vrepr() + sage: face.length_Vrep() 3 Obtain the facet-representation:: sage: it = FaceIterator(C, True) sage: face = next(it) - sage: face.Hrepr() + sage: face.Hrep() (An inequality (-1, -1, 1) x + 1 >= 0, An inequality (-1, -1, -1) x + 1 >= 0, An inequality (-1, 1, -1) x + 1 >= 0, An inequality (-1, 1, 1) x + 1 >= 0) - sage: face.Hrepr(names=False) + sage: face.Hrep(names=False) (4, 5, 6, 7) - sage: face.length_Hrepr() + sage: face.length_Hrep() 4 In non-dual mode one can ignore all faces contained in the current face:: sage: it = FaceIterator(C, False) sage: face = next(it) - sage: face.Hrepr(names=False) + sage: face.Hrep(names=False) (7,) sage: it.ignore_subfaces() - sage: [face.Hrepr(names=False) for face in it] + sage: [face.Hrep(names=False) for face in it] [(6,), (5,), (4,), @@ -120,10 +120,10 @@ In dual mode one can ignore all faces that contain the current face:: sage: it = FaceIterator(C, True) sage: face = next(it) - sage: face.Vrepr(names=False) + sage: face.Vrep(names=False) (5,) sage: it.ignore_supfaces() - sage: [face.Vrepr(names=False) for face in it] + sage: [face.Vrep(names=False) for face in it] [(4,), (3,), (2,), @@ -161,9 +161,9 @@ from __future__ import absolute_import, division, print_function from sage.rings.integer cimport smallInteger from cysignals.signals cimport sig_check, sig_on, sig_off -from .conversions cimport bit_repr_to_Vrepr_list +from .conversions cimport bit_rep_to_Vrep_list from .base cimport CombinatorialPolyhedron -from .bit_vector_operations cimport get_next_level, count_atoms, bit_repr_to_coatom_repr +from .bit_vector_operations cimport get_next_level, count_atoms, bit_rep_to_coatom_rep cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython @@ -212,7 +212,7 @@ cdef class FaceIterator(SageObject): sage: P = Polyhedron(rays=[[0,0,1], [0,1,0], [1,0,0]]) sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter() - sage: [face.Vrepr() for face in it] + sage: [face.Vrep() for face in it] [(A vertex at (0, 0, 0), A ray in the direction (0, 1, 0), A ray in the direction (1, 0, 0)), @@ -250,10 +250,10 @@ cdef class FaceIterator(SageObject): sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter(dual=False) sage: face = next(it) - sage: face.Hrepr(names=False) + sage: face.Hrep(names=False) (5,) sage: it.ignore_subfaces() - sage: [face.Hrepr(names=False) for face in it] + sage: [face.Hrep(names=False) for face in it] [(4,), (3,), (2,), @@ -286,9 +286,9 @@ cdef class FaceIterator(SageObject): sage: next(it) A 0-dimensional face of a 3-dimensional combinatorial polyhedron sage: face = next(it) - sage: face.Vrepr(names=False) + sage: face.Vrep(names=False) (6,) - sage: [face.Vrepr(names=False) for face in it] + sage: [face.Vrep(names=False) for face in it] [(5,), (4,), (3,), @@ -443,17 +443,17 @@ cdef class FaceIterator(SageObject): if dual: self.atoms = C.bitrep_facets() - self.coatoms = C.bitrep_Vrepr() + self.coatoms = C.bitrep_Vrep() else: self.coatoms = C.bitrep_facets() - self.atoms = C.bitrep_Vrepr() + self.atoms = C.bitrep_Vrep() self.face_length = self.coatoms.face_length self._V = C.V() self._H = C.H() self._equalities = C.equalities() - self.atom_repr = self._mem.allocarray(self.coatoms.n_atoms, sizeof(size_t)) - self.coatom_repr = self._mem.allocarray(self.coatoms.n_faces, sizeof(size_t)) + self.atom_rep = self._mem.allocarray(self.coatoms.n_atoms, sizeof(size_t)) + self.coatom_rep = self._mem.allocarray(self.coatoms.n_faces, sizeof(size_t)) if self.dimension == 0 or self.coatoms.n_faces == 0: # As we will only yield proper faces, @@ -610,7 +610,7 @@ cdef class FaceIterator(SageObject): sage: it = C.face_iter(dual=False) sage: n_non_simplex_faces = 1 sage: for face in it: - ....: if face.length_Vrepr() > face.dimension() + 1: + ....: if face.length_Vrep() > face.dimension() + 1: ....: n_non_simplex_faces += 1 ....: else: ....: it.ignore_subfaces() @@ -643,7 +643,7 @@ cdef class FaceIterator(SageObject): sage: it = C.face_iter(dual=True) sage: n_faces_with_non_simplex_quotient = 1 sage: for face in it: - ....: if face.length_Hrepr() > C.dimension() - face.dimension() + 1: + ....: if face.length_Hrep() > C.dimension() - face.dimension() + 1: ....: n_faces_with_non_simplex_quotient += 1 ....: else: ....: it.ignore_supfaces() @@ -787,12 +787,12 @@ cdef class FaceIterator(SageObject): self.first_time[self.current_dimension] = True return 0 - cdef size_t length_atom_repr(self) except -1: + cdef size_t length_atom_rep(self) except -1: r""" Compute the number of atoms in the current face by counting the number of set bits. - This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.length_atom_repr` + This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.length_atom_rep` """ if self.face: return count_atoms(self.face, self.face_length) @@ -800,25 +800,25 @@ cdef class FaceIterator(SageObject): # The face was not initialized properly. raise LookupError("``FaceIterator`` does not point to a face") - cdef size_t set_coatom_repr(self) except -1: + cdef size_t set_coatom_rep(self) except -1: r""" - Set ``coatom_repr`` to be the coatom-representation of the current face. + Set ``coatom_rep`` to be the coatom-representation of the current face. Return its length. - This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_coatom_repr` + This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_coatom_rep` """ cdef size_t n_coatoms = self.coatoms.n_faces cdef uint64_t **coatoms = self.coatoms.data cdef size_t face_length = self.face_length - return bit_repr_to_coatom_repr(self.face, coatoms, n_coatoms, - face_length, self.coatom_repr) + return bit_rep_to_coatom_rep(self.face, coatoms, n_coatoms, + face_length, self.coatom_rep) - cdef size_t set_atom_repr(self) except -1: + cdef size_t set_atom_rep(self) except -1: r""" - Set ``atom_repr`` to be the atom-representation of the current face. + Set ``atom_rep`` to be the atom-representation of the current face. Return its length. - This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_atom_repr` + This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_atom_rep` """ cdef size_t face_length = self.face_length - return bit_repr_to_Vrepr_list(self.face, self.atom_repr, face_length) + return bit_rep_to_Vrep_list(self.face, self.atom_rep, face_length) diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx index 32972d51e56..75ab37b3f28 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx @@ -28,35 +28,35 @@ Provide enough space to store `20` faces as incidences to `60` vertices:: Obtain the facets of a polyhedron:: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import incidence_matrix_to_bit_repr_of_facets + ....: import incidence_matrix_to_bit_rep_of_facets sage: P = polytopes.cube() - sage: face_list = incidence_matrix_to_bit_repr_of_facets(P.incidence_matrix()) - sage: face_list = incidence_matrix_to_bit_repr_of_facets(P.incidence_matrix()) + sage: face_list = incidence_matrix_to_bit_rep_of_facets(P.incidence_matrix()) + sage: face_list = incidence_matrix_to_bit_rep_of_facets(P.incidence_matrix()) sage: face_list.compute_dimension() 3 Obtain the Vrepresentation of a polyhedron as facet-incidences:: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import incidence_matrix_to_bit_repr_of_Vrepr + ....: import incidence_matrix_to_bit_rep_of_Vrep sage: P = polytopes.associahedron(['A',3]) - sage: face_list = incidence_matrix_to_bit_repr_of_Vrepr(P.incidence_matrix()) + sage: face_list = incidence_matrix_to_bit_rep_of_Vrep(P.incidence_matrix()) sage: face_list.compute_dimension() 3 Obtain the facets of a polyhedron as :class:`ListOfFaces` from a facet list:: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import facets_tuple_to_bit_repr_of_facets + ....: import facets_tuple_to_bit_rep_of_facets sage: facets = ((0,1,2), (0,1,3), (0,2,3), (1,2,3)) - sage: face_list = facets_tuple_to_bit_repr_of_facets(facets, 4) + sage: face_list = facets_tuple_to_bit_rep_of_facets(facets, 4) Likewise for the Vrepresenatives as facet-incidences:: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import facets_tuple_to_bit_repr_of_Vrepr + ....: import facets_tuple_to_bit_rep_of_Vrep sage: facets = ((0,1,2), (0,1,3), (0,2,3), (1,2,3)) - sage: face_list = facets_tuple_to_bit_repr_of_Vrepr(facets, 4) + sage: face_list = facets_tuple_to_bit_rep_of_Vrep(facets, 4) .. SEEALSO:: @@ -102,10 +102,10 @@ cdef class ListOfFaces: .. SEEALSO:: - :meth:`incidence_matrix_to_bit_repr_of_facets`, - :meth:`incidence_matrix_to_bit_repr_of_Vrepr`, - :meth:`facets_tuple_to_bit_repr_of_facets`, - :meth:`facets_tuple_to_bit_repr_of_Vrepr`, + :meth:`incidence_matrix_to_bit_rep_of_facets`, + :meth:`incidence_matrix_to_bit_rep_of_Vrep`, + :meth:`facets_tuple_to_bit_rep_of_facets`, + :meth:`facets_tuple_to_bit_rep_of_Vrep`, :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator.FaceIterator`, :class:`~sage.geometry.polyhedron.combinatorial_polyhedron.base.CombinatorialPolyhedron`. @@ -183,15 +183,15 @@ cdef class ListOfFaces: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces \ ....: import ListOfFaces sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import facets_tuple_to_bit_repr_of_facets, \ - ....: facets_tuple_to_bit_repr_of_Vrepr + ....: import facets_tuple_to_bit_rep_of_facets, \ + ....: facets_tuple_to_bit_rep_of_Vrep sage: bi_pyr = ((0,1,4), (1,2,4), (2,3,4), (3,0,4), ....: (0,1,5), (1,2,5), (2,3,5), (3,0,5)) - sage: facets = facets_tuple_to_bit_repr_of_facets(bi_pyr, 6) - sage: Vrepr = facets_tuple_to_bit_repr_of_Vrepr(bi_pyr, 6) + sage: facets = facets_tuple_to_bit_rep_of_facets(bi_pyr, 6) + sage: Vrep = facets_tuple_to_bit_rep_of_Vrep(bi_pyr, 6) sage: facets.compute_dimension() 3 - sage: Vrepr.compute_dimension() + sage: Vrep.compute_dimension() 3 ALGORITHM: @@ -217,16 +217,16 @@ cdef class ListOfFaces: sage: from sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces \ ....: import ListOfFaces sage: from sage.geometry.polyhedron.combinatorial_polyhedron.conversions \ - ....: import incidence_matrix_to_bit_repr_of_facets, \ - ....: incidence_matrix_to_bit_repr_of_Vrepr + ....: import incidence_matrix_to_bit_rep_of_facets, \ + ....: incidence_matrix_to_bit_rep_of_Vrep sage: bi_pyr = ((0,1,4), (1,2,4), (2,3,4), (3,0,4), ....: (0,1,5), (1,2,5), (2,3,5), (3,0,5)) sage: for _ in range(10): ....: points = tuple(tuple(randint(-1000,1000) for _ in range(10)) ....: for _ in range(randint(3,15))) ....: P = Polyhedron(vertices=points) - ....: facets = incidence_matrix_to_bit_repr_of_facets(P.incidence_matrix()) - ....: vertices = incidence_matrix_to_bit_repr_of_Vrepr(P.incidence_matrix()) + ....: facets = incidence_matrix_to_bit_rep_of_facets(P.incidence_matrix()) + ....: vertices = incidence_matrix_to_bit_rep_of_Vrep(P.incidence_matrix()) ....: d1 = P.dimension() ....: if d1 == 0: ....: continue diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd index 12b85491a34..1b570d588dd 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd @@ -13,10 +13,10 @@ cdef class PolyhedronFaceLattice: cdef tuple _V, _H, _equalities # some copies from CombinatorialPolyhedron cdef size_t *f_vector # a copy of the f-vector, is reversed if dual cdef size_t *face_counter # how many faces of each dimension have been initialized - cdef size_t *atom_repr # a place where atom-representaion of face will be stored - cdef size_t *coatom_repr # a place where coatom-representaion of face will be stored + cdef size_t *atom_rep # a place where atom-representaion of face will be stored + cdef size_t *coatom_rep # a place where coatom-representaion of face will be stored - # Atoms and coatoms are the Vrepr/facets of the Polyedron. + # Atoms and coatoms are the Vrep/facets of the Polyedron. # If ``dual == 0``, then coatoms are facets, atoms Vrepresentatives and vice versa. cdef ListOfFaces atoms, coatoms @@ -50,8 +50,8 @@ cdef class PolyhedronFaceLattice: cdef inline int is_equal(self, int dimension, size_t index, uint64_t *face) except -1 cdef CombinatorialFace get_face(self, int dimension, size_t index) - cdef size_t set_coatom_repr(self, int dimension, size_t index) except -1 - cdef size_t set_atom_repr(self, int dimension, size_t index) except -1 + cdef size_t set_coatom_rep(self, int dimension, size_t index) except -1 + cdef size_t set_atom_rep(self, int dimension, size_t index) except -1 cdef void incidence_init(self, int dimension_one, int dimension_two) cdef inline bint next_incidence(self, size_t *one, size_t *two) cdef inline bint next_incidence_loop(self, size_t *one, size_t *two) diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx index bb04f35c275..2a2e79f6fea 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx @@ -8,22 +8,22 @@ the face lattice of a polyhedron. Terminology in this module: -- Vrepr -- ``[vertices, rays, lines]`` of the polyhedron. -- Hrepr -- inequalities and equalities of the polyhedron. +- Vrep -- ``[vertices, rays, lines]`` of the polyhedron. +- Hrep -- inequalities and equalities of the polyhedron. - Facets -- facets of the polyhedron. - Coatoms -- the faces from which all others are constructed in - the face iterator. This will be facets or Vrepr. + the face iterator. This will be facets or Vrep. In non-dual mode, faces are constructed as intersections of the facets. In dual mode, the are constructed theoretically as joins of vertices. - The coatoms are reprsented as incidences with the + The coatoms are repsented as incidences with the atoms they contain. -- Atoms -- facets or Vrepr depending on application of algorithm. - Atoms are reprsented as incidences of coatoms they +- Atoms -- facets or Vrep depending on application of algorithm. + Atoms are repsented as incidences of coatoms they are contained in. -- Vrepresentation -- represents a face by a list of VRepr it contains. -- Hrepresentation -- represents a face by a list of Hrepr it is contained in. +- Vrepresentation -- represents a face by a list of Vrep it contains. +- Hrepresentation -- represents a face by a list of Hrep it is contained in. - bit representation -- represents incidences as ``uint64_t``-array, where each Bit represents one incidences. There might be trailing zeros, to fit alignment-requirements. @@ -61,15 +61,15 @@ AUTHOR: from __future__ import absolute_import, division, print_function from .conversions \ - import facets_tuple_to_bit_repr_of_facets, \ - facets_tuple_to_bit_repr_of_Vrepr + import facets_tuple_to_bit_rep_of_facets, \ + facets_tuple_to_bit_rep_of_Vrep from sage.rings.integer cimport smallInteger from libc.string cimport memcmp, memcpy, memset -from .conversions cimport Vrepr_list_to_bit_repr, bit_repr_to_Vrepr_list +from .conversions cimport Vrep_list_to_bit_rep, bit_rep_to_Vrep_list from .base cimport CombinatorialPolyhedron from .face_iterator cimport FaceIterator -from .bit_vector_operations cimport intersection, bit_repr_to_coatom_repr +from .bit_vector_operations cimport intersection, bit_rep_to_coatom_rep cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython @@ -129,7 +129,7 @@ cdef class PolyhedronFaceLattice: self._mem = MemoryAllocator() self.dimension = C.dimension() self.dual = False - if C.bitrep_facets().n_faces > C.bitrep_Vrepr().n_faces: + if C.bitrep_facets().n_faces > C.bitrep_Vrep().n_faces: self.dual = True if C.unbounded(): self.dual = False @@ -157,19 +157,19 @@ cdef class PolyhedronFaceLattice: # We will obtain the coatoms from ``CombinatorialPolyhedron``. self.face_counter[self.dimension] = self.f_vector[self.dimension] - # Initialize atoms, coatoms, ``atom_repr`` and ``coatom_repr``. + # Initialize atoms, coatoms, ``atom_rep`` and ``coatom_rep``. if self.dimension == 0: # In case of the 0-dimensional polyhedron, we have to fix atoms and coatoms. # So far this didn't matter, as we only iterated over proper faces. - self.atoms = facets_tuple_to_bit_repr_of_Vrepr(((),), 1) - self.coatoms = facets_tuple_to_bit_repr_of_facets(((),), 1) + self.atoms = facets_tuple_to_bit_rep_of_Vrep(((),), 1) + self.coatoms = facets_tuple_to_bit_rep_of_facets(((),), 1) self.face_length = self.coatoms.face_length else: self.atoms = face_iter.atoms self.coatoms = face_iter.coatoms cdef size_t n_atoms = self.atoms.n_faces - self.atom_repr = self._mem.allocarray(self.coatoms.n_atoms, sizeof(size_t)) - self.coatom_repr = self._mem.allocarray(self.coatoms.n_faces, sizeof(size_t)) + self.atom_rep = self._mem.allocarray(self.coatoms.n_atoms, sizeof(size_t)) + self.coatom_rep = self._mem.allocarray(self.coatoms.n_faces, sizeof(size_t)) # Initialize the data for ``faces``: cdef ListOfFaces coatoms_mem @@ -190,9 +190,9 @@ cdef class PolyhedronFaceLattice: if self.dimension != 0: # Initialize the empty face. # In case ``dimension == 0``, we would overwrite the coatoms. - Vrepr_list_to_bit_repr((), self.faces[0][0], self.face_length) + Vrep_list_to_bit_rep((), self.faces[0][0], self.face_length) # Intialize the full polyhedron - Vrepr_list_to_bit_repr(tuple(j for j in range(n_atoms)), + Vrep_list_to_bit_rep(tuple(j for j in range(n_atoms)), self.faces[self.dimension + 1][0], self.face_length) @@ -438,12 +438,12 @@ cdef class PolyhedronFaceLattice: sage: C = CombinatorialPolyhedron(P) sage: it = C.face_iter(dimension=1) sage: face = next(it) - sage: face_via_all_faces_from_iterator(it, C).Vrepr() + sage: face_via_all_faces_from_iterator(it, C).Vrep() (A vertex at (3, 1, 4, 2), A vertex at (3, 2, 4, 1)) - sage: face.Vrepr() + sage: face.Vrep() (A vertex at (3, 1, 4, 2), A vertex at (3, 2, 4, 1)) - sage: all(face_via_all_faces_from_iterator(it, C).Vrepr() == - ....: face.Vrepr() for face in it) + sage: all(face_via_all_faces_from_iterator(it, C).Vrep() == + ....: face.Vrep() for face in it) True sage: P = polytopes.twenty_four_cell() @@ -451,12 +451,12 @@ cdef class PolyhedronFaceLattice: sage: it = C.face_iter() sage: face = next(it) sage: while (face.dimension() == 3): face = next(it) - sage: face_via_all_faces_from_iterator(it, C).Vrepr() + sage: face_via_all_faces_from_iterator(it, C).Vrep() (A vertex at (-1/2, 1/2, -1/2, -1/2), A vertex at (-1/2, 1/2, 1/2, -1/2), A vertex at (0, 0, 0, -1)) - sage: all(face_via_all_faces_from_iterator(it, C).Vrepr(False) == - ....: face.Vrepr(False) for face in it) + sage: all(face_via_all_faces_from_iterator(it, C).Vrep(False) == + ....: face.Vrep(False) for face in it) True """ cdef size_t length @@ -465,13 +465,13 @@ cdef class PolyhedronFaceLattice: dimension = self.dimension - 1 - dimension # if dual, the dimensions are reversed return CombinatorialFace(self, dimension=dimension, index=index) - cdef size_t set_coatom_repr(self, int dimension, size_t index) except -1: + cdef size_t set_coatom_rep(self, int dimension, size_t index) except -1: r""" - Set ``atom_repr`` to be the atom-representation of the face + Set ``atom_rep`` to be the atom-representation of the face of dimension ``dimension`` and index ``index``. Return its length. - This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_coatom_repr` + This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_coatom_rep` """ if unlikely(dimension < -1 or dimension > self.dimension): raise ValueError("no face of dimension %s"%dimension) @@ -484,16 +484,16 @@ cdef class PolyhedronFaceLattice: cdef uint64_t **coatoms = self.faces[self.dimension] cdef size_t face_length = self.face_length cdef uint64_t *face = self.faces[dimension+1][index] - return bit_repr_to_coatom_repr(face, coatoms, n_coatoms, - face_length, self.coatom_repr) + return bit_rep_to_coatom_rep(face, coatoms, n_coatoms, + face_length, self.coatom_rep) - cdef size_t set_atom_repr(self, int dimension, size_t index) except -1: + cdef size_t set_atom_rep(self, int dimension, size_t index) except -1: r""" - Set ``atom_repr`` to be the atom-representation of the face + Set ``atom_rep`` to be the atom-representation of the face of dimension ``dimension`` and index ``index``. Return its length. - This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_atom_repr` + This is a shortcut of :class:`sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face.CombinatorialFace.set_atom_rep` """ if unlikely(dimension < -1 or dimension > self.dimension): raise ValueError("no face of dimension %s"%dimension) @@ -502,7 +502,7 @@ cdef class PolyhedronFaceLattice: cdef size_t face_length = self.face_length cdef uint64_t *face = self.faces[dimension+1][index] - return bit_repr_to_Vrepr_list(face, self.atom_repr, face_length) + return bit_rep_to_Vrep_list(face, self.atom_rep, face_length) cdef void incidence_init(self, int dimension_one, int dimension_two): r""" @@ -568,7 +568,7 @@ cdef class PolyhedronFaceLattice: ``two[0]`` will represent the index of a face in ``dimension_two`` according to their order in :class:`PolyhedronFaceLattice`. - Use :meth:`Vrepr` and :meth:`Hrepr` to interpret the output. + Use :meth:`Vrep` and :meth:`Hrep` to interpret the output. ALGORITHM: