From 7a6a20ef738a1abe182e775dc8c9a1267ee11e63 Mon Sep 17 00:00:00 2001 From: Ulrich Bauer Date: Mon, 23 May 2016 17:08:09 +0200 Subject: cleanup pop_pivot code --- ripser.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'ripser.cpp') diff --git a/ripser.cpp b/ripser.cpp index 8ca512e..f3596df 100644 --- a/ripser.cpp +++ b/ripser.cpp @@ -358,14 +358,14 @@ typedef compressed_distance_matrix_adapter typedef compressed_distance_matrix_adapter compressed_upper_distance_matrix_adapter; -#ifdef USE_COEFFICIENTS -template inline diameter_entry_t pop_pivot(Heap& column, coefficient_t modulus) { +template 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 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 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 inline diameter_entry_t get_pivot(Heap& column, coefficient_t modulus) { diameter_entry_t result = pop_pivot(column, modulus); -- cgit v1.2.3