diff options
author | Ulrich Bauer <mail@ulrich-bauer.org> | 2019-07-04 11:30:59 +0200 |
---|---|---|
committer | Ulrich Bauer <mail@ulrich-bauer.org> | 2019-07-04 13:23:55 +0200 |
commit | 5a4347c13b25151970ddf04c83cb69baa6c2cc8b (patch) | |
tree | 9d483837f1894fe2aa8065a6f518ef869637a3c3 | |
parent | 58ec7d588df15d60b72c9f22870ec894ca5d364b (diff) |
simplified pop_pivot for F_2 coefficients
-rw-r--r-- | ripser.cpp | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -36,9 +36,9 @@ */ -#define USE_COEFFICIENTS +//#define USE_COEFFICIENTS -//#define INDICATE_PROGRESS +#define INDICATE_PROGRESS #define PRINT_PERSISTENCE_PAIRS //#define USE_GOOGLE_HASHMAP @@ -345,8 +345,8 @@ public: }; template <typename Column> diameter_entry_t pop_pivot(Column& column, coefficient_t modulus) { -#ifdef USE_COEFFICIENTS diameter_entry_t pivot(-1); +#ifdef USE_COEFFICIENTS while (!column.empty()) { if (get_coefficient(pivot) == 0) pivot = column.top(); @@ -359,19 +359,16 @@ template <typename Column> diameter_entry_t pop_pivot(Column& column, coefficien } if (get_coefficient(pivot) == 0) pivot = -1; #else - if (column.empty()) return diameter_entry_t(-1); - - auto pivot = column.top(); - column.pop(); - while (!column.empty() && get_index(column.top()) == get_index(pivot)) { + while (!column.empty()) { + pivot = column.top(); column.pop(); - if (column.empty()) - return diameter_entry_t(-1); - else { - pivot = column.top(); + if (!column.empty()) { + if (get_index(column.top()) != get_index(pivot)) + return pivot; column.pop(); } } + pivot = -1; #endif return pivot; } |