From 20a39b679f660e6b59ba7db4f7c302ab454fe28b Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 28 Aug 2020 16:13:55 +0200 Subject: [PATCH 1/3] outsource inclusion maximal --- .../bit_vector_operations.cc | 89 +++++++++++-------- 1 file changed, 50 insertions(+), 39 deletions(-) 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 b9c88f8dc24..d100a18668e 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc @@ -66,6 +66,52 @@ inline size_t count_atoms(uint64_t* A, size_t face_length){ return count; } + +inline int is_contained_in_one(uint64_t *face, uint64_t **faces, size_t n_faces, size_t face_length){ + /* + Return whether ``face`` is contained in one of ``faces``. + */ + for(size_t i = 0; i < n_faces; i++){ + if (is_subset(face, faces[i], face_length)) + return 1; + } + return 0; +} + +inline int is_contained_in_one(uint64_t *face, uint64_t **faces, size_t n_faces, size_t face_length, size_t skip){ + /* + Return whether ``face`` is contained in one of ``faces``. + + Skips ``faces[skip]``. + */ + return is_contained_in_one(face, faces, skip, face_length) || \ + is_contained_in_one(face, faces+skip+1, n_faces-skip-1, face_length); +} + +inline int contains_one(uint64_t *face, uint64_t **faces, size_t n_faces, size_t face_length){ + /* + Return whether ``face`` contains in one of ``faces``. + */ + for(size_t i = 0; i < n_faces; i++){ + if (is_subset(faces[i], face, face_length)) + return 1; + } + return 0; +} + +inline int contains_one(uint64_t *face, uint64_t **faces, size_t n_faces, size_t face_length, size_t skip){ + /* + Return whether ``face`` is contains in one of ``faces``. + + Skips ``faces[skip]``. + */ + return contains_one(face, faces, skip, face_length) || \ + contains_one(face, faces+skip+1, n_faces-skip-1, face_length); +} + +void set_not_inclusion_maximal(uint64_t **faces, size_t n_faces, int *is_not_maximal){ +} + size_t get_next_level(\ uint64_t **faces, const size_t n_faces, uint64_t **maybe_newfaces, \ uint64_t **newfaces, uint64_t **visited_all, \ @@ -97,7 +143,7 @@ size_t get_next_level(\ 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. + Step 2: Out of those 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. @@ -117,44 +163,9 @@ size_t get_next_level(\ // For each face we will Step 2 and Step 3. for (size_t j = 0; j < n_faces-1; j++){ - // Step 2a: - for(size_t k = 0; k < j; k++){ - // Testing if maybe_newfaces[j] is contained in different nextface. - if(is_subset(maybe_newfaces[j], maybe_newfaces[k],face_length)){ - // If so, it is not inclusion-maximal and hence not of codimension 1. - is_not_newface[j] = 1; - break; - } - } - if (is_not_newface[j]) { - // No further tests needed, if it is not of codimension 1. - continue; - } - - // Step 2b: - for(size_t k = j+1; k < n_faces-1; k++){ - // Testing if maybe_newfaces[j] is contained in different nextface. - if(is_subset(maybe_newfaces[j],maybe_newfaces[k], face_length)){ - // If so, it is not inclusion-maximal and hence not of codimension 1. - is_not_newface[j] = 1; - break; - } - } - if (is_not_newface[j]) { - // No further tests needed, if it is not of codimension 1. - continue; - } - - // Step 3: - for (size_t k = 0; k < n_visited_all; k++){ - // Testing if maybe_newfaces[j] is contained in one, - // we have already completely visited. - if(is_subset(maybe_newfaces[j], visited_all[k], face_length)){ - // If so, we don't want to revisit. - is_not_newface[j] = 1; - break; - } - } + if (is_contained_in_one(maybe_newfaces[j], maybe_newfaces, n_faces-1, face_length, j) || \ + is_contained_in_one(maybe_newfaces[j], visited_all, n_visited_all, face_length)) + is_not_newface[j] = 1; } // Set ``newfaces`` to point to the correct ones. From b672fcaf65e2219644166a6ed5d8e29c13b4d67d Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 28 Aug 2020 16:23:56 +0200 Subject: [PATCH 2/3] removed redundant function --- .../combinatorial_polyhedron/bit_vector_operations.cc | 3 --- 1 file changed, 3 deletions(-) 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 d100a18668e..d959204f6c0 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc @@ -109,9 +109,6 @@ inline int contains_one(uint64_t *face, uint64_t **faces, size_t n_faces, size_t contains_one(face, faces+skip+1, n_faces-skip-1, face_length); } -void set_not_inclusion_maximal(uint64_t **faces, size_t n_faces, int *is_not_maximal){ -} - size_t get_next_level(\ uint64_t **faces, const size_t n_faces, uint64_t **maybe_newfaces, \ uint64_t **newfaces, uint64_t **visited_all, \ From accea52802a9bcf8f3aea69bd4489ecdcaad94e8 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 28 Aug 2020 16:30:35 +0200 Subject: [PATCH 3/3] missing } --- .../polyhedron/combinatorial_polyhedron/bit_vector_operations.cc | 1 + 1 file changed, 1 insertion(+) 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 aa870d0e04b..928b0bf10ba 100644 --- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc +++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/bit_vector_operations.cc @@ -84,6 +84,7 @@ inline int is_zero(uint64_t *A, size_t face_length){ } } return 1; +} inline int is_contained_in_one(uint64_t *face, uint64_t **faces, size_t n_faces, size_t face_length){ /*