diff options
-rw-r--r-- | ripser.cpp | 10 | ||||
-rw-r--r-- | ripser.xcodeproj/project.pbxproj | 3 |
2 files changed, 9 insertions, 4 deletions
@@ -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<std::vector<index_t>> B; @@ -132,18 +132,22 @@ std::vector<index_t> 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); } diff --git a/ripser.xcodeproj/project.pbxproj b/ripser.xcodeproj/project.pbxproj index 980df17..04bc3a6 100644 --- a/ripser.xcodeproj/project.pbxproj +++ b/ripser.xcodeproj/project.pbxproj @@ -209,9 +209,10 @@ buildSettings = { GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", - FILE_FORMAT_DISTANCE_MATRIX, + _FILE_FORMAT_DISTANCE_MATRIX, _FILE_FORMAT_LOWER_DISTANCE_MATRIX, _FILE_FORMAT_POINT_CLOUD, + USE_COEFFICIENTS, ); PRODUCT_NAME = "$(TARGET_NAME)"; }; |