summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Bauer <mail@ulrich-bauer.org>2018-01-24 15:16:34 +0100
committerUlrich Bauer <mail@ulrich-bauer.org>2018-02-07 16:47:55 +0100
commit0ed8c7932825572e49fa5abd50f2338cb66d7fd0 (patch)
treee30c7dc39518f3be0aaa33e26e203f8ed7fb46f0
parent9eae733cca3ac379ca447d5abb7289cc37bbeafc (diff)
simplified control flow
-rw-r--r--ripser.cpp76
1 files changed, 37 insertions, 39 deletions
diff --git a/ripser.cpp b/ripser.cpp
index 9085ec2..bc97752 100644
--- a/ripser.cpp
+++ b/ripser.cpp
@@ -619,13 +619,12 @@ public:
#endif
#endif
- pivot = add_coboundary_and_get_pivot(reduction_column_begin, reduction_column_end,
- factor_column_to_add,
+ pivot = add_coboundary_and_get_pivot(
+ reduction_column_begin, reduction_column_end, factor_column_to_add,
#ifdef ASSEMBLE_REDUCTION_MATRIX
- working_reduction_column,
+ working_reduction_column,
#endif
- working_coboundary, dim, pivot_column_index,
- might_be_apparent_pair);
+ working_coboundary, dim, pivot_column_index, might_be_apparent_pair);
if (get_index(pivot) != -1) {
auto pair = pivot_column_index.find(get_index(pivot));
@@ -633,59 +632,58 @@ public:
if (pair != pivot_column_index.end()) {
index_column_to_add = pair->second;
factor_column_to_add = modulus - get_coefficient(pivot);
- continue;
- }
- } else {
+ } else {
#ifdef PRINT_PERSISTENCE_PAIRS
+ value_t death = get_diameter(pivot);
+ if (diameter != death) {
#ifdef INDICATE_PROGRESS
- std::cout << "\033[K";
-#endif
- std::cout << " [" << diameter << ", )" << std::endl << std::flush;
+ std::cout << "\033[K";
#endif
- break;
- }
-
-#ifdef PRINT_PERSISTENCE_PAIRS
- value_t death = get_diameter(pivot);
- if (diameter != death) {
-#ifdef INDICATE_PROGRESS
- std::cout << "\033[K";
-#endif
- std::cout << " [" << diameter << "," << death << ")" << std::endl << std::flush;
- }
+ std::cout << " [" << diameter << "," << death << ")" << std::endl
+ << std::flush;
+ }
#endif
-
- pivot_column_index.insert(std::make_pair(get_index(pivot), index_column_to_reduce));
+ pivot_column_index.insert(
+ std::make_pair(get_index(pivot), index_column_to_reduce));
#ifdef USE_COEFFICIENTS
- const coefficient_t inverse = multiplicative_inverse[get_coefficient(pivot)];
+ const coefficient_t inverse =
+ multiplicative_inverse[get_coefficient(pivot)];
#endif
#ifdef ASSEMBLE_REDUCTION_MATRIX
-// replace current column of reduction_matrix (with a single diagonal 1 entry)
-// by reduction_column (possibly with a different entry on the diagonal)
+ // replace current column of reduction_matrix (with a single diagonal 1
+ // entry) by reduction_column (possibly with a different entry on the
+ // diagonal)
#ifdef USE_COEFFICIENTS
- reduction_matrix.pop_back();
+ reduction_matrix.pop_back();
#else
- pop_pivot(working_reduction_column, modulus);
+ pop_pivot(working_reduction_column, modulus);
#endif
- while (true) {
- diameter_entry_t e = pop_pivot(working_reduction_column, modulus);
- if (get_index(e) == -1) break;
+ while (true) {
+ diameter_entry_t e = pop_pivot(working_reduction_column, modulus);
+ if (get_index(e) == -1) break;
#ifdef USE_COEFFICIENTS
- set_coefficient(e, inverse * get_coefficient(e) % modulus);
- assert(get_coefficient(e) > 0);
+ set_coefficient(e, inverse * get_coefficient(e) % modulus);
+ assert(get_coefficient(e) > 0);
#endif
- reduction_matrix.push_back(e);
- }
+ reduction_matrix.push_back(e);
+ }
#else
#ifdef USE_COEFFICIENTS
- reduction_matrix.pop_back();
- reduction_matrix.push_back(diameter_entry_t(column_to_reduce, inverse));
+ reduction_matrix.pop_back();
+ reduction_matrix.push_back(diameter_entry_t(column_to_reduce, inverse));
#endif
#endif
- break;
+ break;
+ }
+ } else {
+#ifdef PRINT_PERSISTENCE_PAIRS
+ std::cout << " [" << diameter << ", )" << std::endl << std::flush;
+#endif
+ break;
+ }
}
}