diff options
author | Ulrich Bauer <ulrich.bauer@tum.de> | 2016-05-23 17:08:09 +0200 |
---|---|---|
committer | Ulrich Bauer <ulrich.bauer@tum.de> | 2016-05-23 17:08:09 +0200 |
commit | 7a6a20ef738a1abe182e775dc8c9a1267ee11e63 (patch) | |
tree | 886a33eca548cde0294a01cb46dfe49f1ac55a56 /ripser.cpp | |
parent | 999cdfcbe48436b7255a95d77add8bcf31ed6c81 (diff) |
cleanup pop_pivot code
Diffstat (limited to 'ripser.cpp')
-rw-r--r-- | ripser.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
@@ -358,14 +358,14 @@ typedef compressed_distance_matrix_adapter<LOWER_TRIANGULAR> typedef compressed_distance_matrix_adapter<UPPER_TRIANGULAR> compressed_upper_distance_matrix_adapter; -#ifdef USE_COEFFICIENTS -template <typename Heap> inline diameter_entry_t pop_pivot(Heap& column, coefficient_t modulus) { +template <typename Heap> inline diameter_entry_t pop_pivot(Heap& column, coefficient_t modulus) { if (column.empty()) return diameter_entry_t(-1); else { auto pivot = column.top(); - + +#ifdef USE_COEFFICIENTS coefficient_t coefficient = 0; do { coefficient = (coefficient + get_coefficient(column.top())) % modulus; @@ -380,33 +380,22 @@ template <typename Heap> inline diameter_entry_t pop_pivot(Heap& column, coeffic } } while (!column.empty() && get_index(column.top()) == get_index(pivot)); if (get_index(pivot) != -1) { set_coefficient(pivot, coefficient); } - return pivot; - } -} - #else - -template <typename Heap> inline diameter_entry_t pop_pivot(Heap& column, coefficient_t modulus) { - - if (column.empty()) - return -1; - else { - auto pivot = column.top(); column.pop(); while (!column.empty() && get_index(column.top()) == get_index(pivot)) { column.pop(); if (column.empty()) - return -1; + return diameter_entry_t(-1); else { pivot = column.top(); column.pop(); } } +#endif return pivot; } } -#endif template <typename Heap> inline diameter_entry_t get_pivot(Heap& column, coefficient_t modulus) { diameter_entry_t result = pop_pivot(column, modulus); |