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

Commit

Permalink
abbreavations: Hrepr -> Hrep, Vrepr -> Vrep etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Sep 10, 2019
1 parent 07e4ea7 commit c18a757
Show file tree
Hide file tree
Showing 13 changed files with 413 additions and 413 deletions.
14 changes: 7 additions & 7 deletions src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)

Expand Down
222 changes: 111 additions & 111 deletions src/sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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){
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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))
Expand All @@ -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.
Expand All @@ -424,92 +424,92 @@ 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)
"""
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.
Expand All @@ -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 = <size_t *> 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 = <size_t *> 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 = <size_t *> 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 = <size_t *> self._mem.allocarray(self.coatoms.n_atoms, sizeof(size_t))
return bit_rep_to_Vrep_list(self.face, self.atom_rep, face_length)

Loading

0 comments on commit c18a757

Please sign in to comment.