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

Commit

Permalink
merge in #30040
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem committed Aug 28, 2020
2 parents 59f6a12 + accea52 commit 56ba0e0
Showing 1 changed file with 59 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,48 @@ 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){
/*
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);
}

size_t get_next_level(\
uint64_t **faces, size_t n_faces, uint64_t **maybe_newfaces, \
uint64_t **newfaces, uint64_t **visited_all, \
Expand Down Expand Up @@ -118,7 +160,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.
Expand All @@ -138,56 +180,23 @@ size_t get_next_level(\
is_not_newface[j] = 0;
}


// For each face we will do Step 2 and Step 3.
for (size_t j = 0; j < n_faces-1; j++){
if (in_simple_face){
// Shortcut:
// Check if the atom representation is zero.
if (is_zero(maybe_newfaces[j], face_length)){
//
// and
//
// Step 3:
if (is_zero(maybe_newfaces[j], face_length) || \
is_contained_in_one(maybe_newfaces[j], visited_all, n_visited_all, face_length))
is_not_newface[j] = 1;
continue;
}
} else {
// 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;
}
// Step 2 and 3.
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;
}
}

Expand Down Expand Up @@ -248,26 +257,14 @@ size_t get_next_level_simple(\
for (size_t j = 0; j < n_faces-1; j++){
// Step 2:
// Check if the atom representation is zero.
if (is_zero(maybe_newfaces[j], face_length)){
//
// and
//
// Step 3:
if (is_zero(maybe_newfaces[j], face_length) || \
contains_one(maybe_newfaces_coatom_rep[j], visited_all_coatom_rep, n_visited_all, face_length_coatom_rep))
is_not_newface[j] = 1;
continue;
}

if (is_not_newface[j]) {
// No further tests needed, if it is empty.
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(visited_all_coatom_rep[k], maybe_newfaces_coatom_rep[j], face_length_coatom_rep)){
// If so, we don't want to revisit.
is_not_newface[j] = 1;
break;
}
}
}

// Set ``newfaces`` to point to the correct ones.
Expand Down

0 comments on commit 56ba0e0

Please sign in to comment.