From ae89a8b44ef95e3e8d94d7bc8edb69cc33a119f1 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 31 Jan 2020 23:36:27 +0100 Subject: [PATCH] remove empty folder in combinatorial polyhedron --- src/module_list.py | 22 +++++--- .../combinatorial_face.pyx | 15 +++++- .../face_iterator.pyx | 52 ++++++++++++++++++- .../list_of_faces.pyx | 49 ++++++++++++++++- .../polyhedron_face_lattice.pyx | 16 +++++- 5 files changed, 142 insertions(+), 12 deletions(-) diff --git a/src/module_list.py b/src/module_list.py index a535785d23d..f8aaa1a976e 100644 --- a/src/module_list.py +++ b/src/module_list.py @@ -302,20 +302,28 @@ def uname_specific(name, value, alternative): sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx']), Extension('sage.geometry.polyhedron.combinatorial_polyhedron.list_of_faces', - sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx']), - - Extension('sage.geometry.polyhedron.combinatorial_polyhedron.bit_vector_operations.cc', - sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc'], + sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx'], + depends = ['sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc'], + language="c++", extra_compile_args=['-std=c++11']), Extension('sage.geometry.polyhedron.combinatorial_polyhedron.face_iterator', - sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx']), + sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx'], + depends = ['sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc'], + language="c++", + extra_compile_args=['-std=c++11']), Extension('sage.geometry.polyhedron.combinatorial_polyhedron.polyhedron_face_lattice', - sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx']), + sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx'], + depends = ['sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc'], + language="c++", + extra_compile_args=['-std=c++11']), Extension('sage.geometry.polyhedron.combinatorial_polyhedron.combinatorial_face', - sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx']), + sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx'], + depends = ['sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc'], + language="c++", + extra_compile_args=['-std=c++11']), Extension('sage.geometry.polyhedron.combinatorial_polyhedron.conversions', sources = ['sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx']), diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx index 8ee80ca7f71..aed7215d546 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx @@ -70,10 +70,23 @@ import numbers from sage.rings.integer cimport smallInteger from .conversions cimport bit_repr_to_Vrepr_list from .base cimport CombinatorialPolyhedron -from .bit_vector_operations cimport count_atoms, bit_repr_to_coatom_repr from .polyhedron_face_lattice cimport PolyhedronFaceLattice from libc.string cimport memcpy +cdef extern from "bit_vector_operations.cc": + cdef size_t count_atoms(uint64_t *A, size_t face_length) +# Return the number of atoms/vertices in A. +# 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( + 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. +# ``face_length`` is the length of ``face`` and ``coatoms[i]`` +# in terms of uint64_t. +# ``n_coatoms`` length of ``coatoms``. + cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx index e2978baf132..a615fb96137 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx @@ -161,7 +161,57 @@ 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 .base cimport CombinatorialPolyhedron -from .bit_vector_operations cimport get_next_level, count_atoms, bit_repr_to_coatom_repr + +cdef extern from "bit_vector_operations.cc": + cdef size_t get_next_level( + uint64_t **faces, const size_t n_faces, uint64_t **nextfaces, + uint64_t **nextfaces2, uint64_t **visited_all, + size_t n_visited_all, size_t face_length) +# Set ``newfaces`` to be the facets of ``faces[n_faces -1]`` +# that are not contained in a face of ``visited_all``. + +# INPUT: + +# - ``maybe_newfaces`` -- quasi of type ``uint64_t[n_faces -1][face_length]``, +# needs to be ``chunksize``-Bit aligned +# - ``newfaces`` -- quasi of type ``*uint64_t[n_faces -1] +# - ``visited_all`` -- quasi of type ``*uint64_t[n_visited_all] +# - ``face_length`` -- length of the faces + +# OUTPUT: + +# - return number of ``newfaces`` +# - set ``newfaces`` to point to the new faces + +# ALGORITHM: + +# To get all facets of ``faces[n_faces-1]``, we would have to: +# - Intersect the first ``n_faces-1`` faces of ``faces`` with the last face. +# - Add all the intersection of ``visited_all`` with the last face +# - Out of both the inclusion-maximal ones are of codimension 1, i.e. facets. + +# As we have visited all faces of ``visited_all``, we alter the algorithm +# to not revisit: +# Step 1: Intersect the first ``n_faces-1`` faces of ``faces`` with the last face. +# Step 2: Out of thosse the inclusion-maximal ones are some of the facets. +# At least we obtain all of those, that we have not already visited. +# Maybe, we get some more. +# Step 3: Only keep those that we have not already visited. +# We obtain exactly the facets of ``faces[n_faces-1]`` that we have +# not visited yet. + + cdef size_t count_atoms(uint64_t *A, size_t face_length) +# Return the number of atoms/vertices in A. +# 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( + 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. +# ``face_length`` is the length of ``face`` and ``coatoms[i]`` +# in terms of uint64_t. +# ``n_coatoms`` length of ``coatoms``. cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython 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 f20416a74f5..ac939d85a57 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx @@ -11,7 +11,7 @@ to bit-representations of vertices stored in :class:`ListOfFaces`. Moreover, :class:`ListOfFaces` calculates the dimension of a polyhedron, assuming the faces are the facets of this polyhedron. -Each face is stored over-aligned according to :meth:`~sage.geometry.polyhedron.combinatorial_polyhedron.bit_vector_operations.chunktype`. +Each face is stored over-aligned according to the ``chunktype``. .. SEEALSO:: @@ -83,7 +83,52 @@ AUTHOR: from sage.structure.element import is_Matrix from cysignals.signals cimport sig_on, sig_off -from .bit_vector_operations cimport chunksize, get_next_level, count_atoms + +cdef extern from "bit_vector_operations.cc": + # Any Bit-representation is assumed to be `chunksize`-Bit aligned. + cdef const size_t chunksize + + cdef size_t get_next_level( + uint64_t **faces, const size_t n_faces, uint64_t **nextfaces, + uint64_t **nextfaces2, uint64_t **visited_all, + size_t n_visited_all, size_t face_length) +# Set ``newfaces`` to be the facets of ``faces[n_faces -1]`` +# that are not contained in a face of ``visited_all``. + +# INPUT: + +# - ``maybe_newfaces`` -- quasi of type ``uint64_t[n_faces -1][face_length]``, +# needs to be ``chunksize``-Bit aligned +# - ``newfaces`` -- quasi of type ``*uint64_t[n_faces -1] +# - ``visited_all`` -- quasi of type ``*uint64_t[n_visited_all] +# - ``face_length`` -- length of the faces + +# OUTPUT: + +# - return number of ``newfaces`` +# - set ``newfaces`` to point to the new faces + +# ALGORITHM: + +# To get all facets of ``faces[n_faces-1]``, we would have to: +# - Intersect the first ``n_faces-1`` faces of ``faces`` with the last face. +# - Add all the intersection of ``visited_all`` with the last face +# - Out of both the inclusion-maximal ones are of codimension 1, i.e. facets. + +# As we have visited all faces of ``visited_all``, we alter the algorithm +# to not revisit: +# Step 1: Intersect the first ``n_faces-1`` faces of ``faces`` with the last face. +# Step 2: Out of thosse the inclusion-maximal ones are some of the facets. +# At least we obtain all of those, that we have not already visited. +# Maybe, we get some more. +# Step 3: Only keep those that we have not already visited. +# We obtain exactly the facets of ``faces[n_faces-1]`` that we have +# not visited yet. + + cdef size_t count_atoms(uint64_t *A, size_t face_length) +# Return the number of atoms/vertices in A. +# This is the number of set bits in A. +# ``face_length`` is the length of A in terms of uint64_t. cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython 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 397ad5f2003..46cb53594ab 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx @@ -68,7 +68,21 @@ from libc.string cimport memcmp, memcpy, memset from .conversions cimport Vrepr_list_to_bit_repr, bit_repr_to_Vrepr_list from .base cimport CombinatorialPolyhedron from .face_iterator cimport FaceIterator -from .bit_vector_operations cimport intersection, bit_repr_to_coatom_repr + +cdef extern from "bit_vector_operations.cc": + cdef void intersection(uint64_t *A, uint64_t *B, uint64_t *C, + size_t face_length) +# Return ``A & ~B == 0``. +# A is not subset of B, iff there is a vertex in A, which is not in B. +# ``face_length`` is the length of A and B in terms of uint64_t. + + cdef size_t bit_repr_to_coatom_repr( + 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. +# ``face_length`` is the length of ``face`` and ``coatoms[i]`` +# in terms of uint64_t. +# ``n_coatoms`` length of ``coatoms``. cdef extern from "Python.h": int unlikely(int) nogil # Defined by Cython