From 099ce879f4c729ec1fcbb148477aae64750bd90b Mon Sep 17 00:00:00 2001 From: Ulrich Bauer Date: Thu, 25 Aug 2016 23:17:00 +0200 Subject: packed entry_t --- ripser.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ripser.cpp') diff --git a/ripser.cpp b/ripser.cpp index b4b528c..d3b969a 100644 --- a/ripser.cpp +++ b/ripser.cpp @@ -47,7 +47,7 @@ typedef float value_t; // typedef uint16_t value_t; typedef long index_t; -typedef long coefficient_t; +typedef short coefficient_t; class binomial_coeff_table { std::vector> B; @@ -132,18 +132,22 @@ std::vector vertices_of_simplex(const index_t simplex_index, const inde #ifdef USE_COEFFICIENTS struct entry_t { - index_t index; + index_t index : 8 * (sizeof(index_t) - sizeof(coefficient_t)); coefficient_t coefficient; entry_t(index_t _index, coefficient_t _coefficient) : index(_index), coefficient(_coefficient) {} entry_t(index_t _index) : index(_index), coefficient(1) {} entry_t() : index(0), coefficient(1) {} -}; +} __attribute__((packed)); + +static_assert(sizeof(entry_t) == sizeof(index_t), "size of entry_t is not the same as index_t"); + entry_t make_entry(index_t _index, coefficient_t _coefficient) { return entry_t(_index, _coefficient); } index_t get_index(entry_t e) { return e.index; } index_t get_coefficient(entry_t e) { return e.coefficient; } void set_coefficient(entry_t& e, const coefficient_t c) { e.coefficient = c; } + bool operator==(const entry_t& e1, const entry_t& e2) { return get_index(e1) == get_index(e2) && get_coefficient(e1) == get_coefficient(e2); } -- cgit v1.2.3