From be5f5cb93477df12b388ff9af7ea1ac403be8356 Mon Sep 17 00:00:00 2001 From: Ulrich Bauer Date: Fri, 28 Jun 2019 20:50:56 +0200 Subject: unsigned coeffs --- ripser.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ripser.cpp b/ripser.cpp index 2455291..9b16200 100644 --- a/ripser.cpp +++ b/ripser.cpp @@ -62,7 +62,7 @@ template class hash_map : public std::unordered_map typedef float value_t; typedef int64_t index_t; -typedef int16_t coefficient_t; +typedef uint16_t coefficient_t; class binomial_coeff_table { std::vector> B; @@ -670,7 +670,7 @@ public: for (index_t w : vertices) coface_diameter = std::max(coface_diameter, dist(v, w)); index_t coface_index = idx_above + binomial_coeff(v--, k + 1) + idx_below; coefficient_t coface_coefficient = - (k & 1 ? -1 + modulus : 1) * get_coefficient(simplex) % modulus; + (k & 1 ? modulus - 1 : 1) * get_coefficient(simplex) % modulus; return diameter_entry_t(coface_diameter, coface_index, coface_coefficient); } }; @@ -733,7 +733,7 @@ public: value_t coface_diameter = std::max(get_diameter(simplex), get_diameter(neighbor)); index_t coface_index = idx_above + binomial_coeff(get_index(neighbor), k + 1) + idx_below; coefficient_t coface_coefficient = - (k & 1 ? -1 + modulus : 1) * get_coefficient(simplex) % modulus; + (k & 1 ? modulus - 1 : 1) * get_coefficient(simplex) % modulus; return diameter_entry_t(coface_diameter, coface_index, coface_coefficient); } }; -- cgit v1.2.3