diff options
author | Ulrich Bauer <mail@ulrich-bauer.org> | 2016-11-25 21:13:37 -0500 |
---|---|---|
committer | Ulrich Bauer <mail@ulrich-bauer.org> | 2016-11-25 21:13:37 -0500 |
commit | 924727f6b8fa9f7aca2b187e69121b55b3a22f04 (patch) | |
tree | 6f418343d364ce5974dc47d897ba620032d093ed | |
parent | 52dde5bdb7c643ec28bb8d4d3fc38582ebc2d95a (diff) | |
parent | 35aa9fb73163ef7c8b98f9913fa38dfef1ada692 (diff) |
Merge branch 'dev' into sparse-distance-matrix
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | ripser.cpp | 24 |
2 files changed, 22 insertions, 9 deletions
@@ -1,7 +1,7 @@ build: ripser -all: ripser ripser-coeff ripser-reduction ripser-debug +all: ripser ripser-coeff ripser-reduction ripser-coeff-reduction ripser-debug ripser: ripser.cpp @@ -13,9 +13,12 @@ ripser-coeff: ripser.cpp ripser-reduction: ripser.cpp c++ -std=c++11 ripser.cpp -o ripser-reduction -Ofast -D NDEBUG -D ASSEMBLE_REDUCTION_MATRIX +ripser-coeff-reduction: ripser.cpp + c++ -std=c++11 ripser.cpp -o ripser-coeff-reduction -Ofast -D NDEBUG -D USE_COEFFICIENTS -D ASSEMBLE_REDUCTION_MATRIX + ripser-debug: ripser.cpp c++ -std=c++11 ripser.cpp -o ripser-debug -g clean: - rm -f ripser ripser-coeff ripser-reduction ripser-debug + rm -f ripser ripser-coeff ripser-reduction ripser-coeff-reduction ripser-debug @@ -136,13 +136,13 @@ std::vector<index_t> vertices_of_simplex(const index_t simplex_index, const inde } #ifdef USE_COEFFICIENTS -struct entry_t { +struct __attribute__((packed)) entry_t { 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"); @@ -606,7 +606,7 @@ void compute_pairs(std::vector<diameter_index_t>& columns_to_reduce, hash_map<in auto column_to_reduce = columns_to_reduce[i]; #ifdef ASSEMBLE_REDUCTION_MATRIX - std::priority_queue<diameter_entry_t, std::vector<diameter_entry_t>, smaller_index<diameter_entry_t>> + std::priority_queue<diameter_entry_t, std::vector<diameter_entry_t>, greater_diameter_or_smaller_index<diameter_entry_t>> reduction_column; #endif @@ -632,21 +632,26 @@ void compute_pairs(std::vector<diameter_index_t>& columns_to_reduce, hash_map<in #ifdef ASSEMBLE_REDUCTION_MATRIX // initialize reduction_coefficients as identity matrix reduction_coefficients.append_column(); - reduction_coefficients.push_back(diameter_entry_t(column_to_reduce, 1)); -#else +#endif #ifdef USE_COEFFICIENTS reduction_coefficients.push_back(diameter_entry_t(column_to_reduce, 1)); #endif -#endif - + bool might_be_apparent_pair = (i == j); do { const coefficient_t factor = modulus - get_coefficient(pivot); #ifdef ASSEMBLE_REDUCTION_MATRIX +#ifdef USE_COEFFICIENTS auto coeffs_begin = reduction_coefficients.cbegin(j), coeffs_end = reduction_coefficients.cend(j); #else + std::vector<diameter_entry_t> coeffs(0); + coeffs.push_back(columns_to_reduce[j]); + for (auto it = reduction_coefficients.cbegin(j); it != reduction_coefficients.cend(j); ++it) coeffs.push_back(*it); + auto coeffs_begin = coeffs.begin(), coeffs_end = coeffs.end(); +#endif +#else #ifdef USE_COEFFICIENTS auto coeffs_begin = &reduction_coefficients[j], coeffs_end = &reduction_coefficients[j] + 1; #else @@ -719,7 +724,12 @@ void compute_pairs(std::vector<diameter_index_t>& columns_to_reduce, hash_map<in #ifdef ASSEMBLE_REDUCTION_MATRIX // replace current column of reduction_coefficients (with a single diagonal 1 entry) // by reduction_column (possibly with a different entry on the diagonal) +#ifdef USE_COEFFICIENTS reduction_coefficients.pop_back(); +#else + pop_pivot(reduction_column, modulus); +#endif + while (true) { diameter_entry_t e = pop_pivot(reduction_column, modulus); if (get_index(e) == -1) break; |