summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Bauer <mail@ulrich-bauer.org>2018-05-24 16:07:29 -0400
committerUlrich Bauer <mail@ulrich-bauer.org>2018-05-24 16:07:29 -0400
commit2ec7e4d5d3dcd3d3970abe48129dc8db1737441d (patch)
treeee30a82f52b8d1dde713d8e2acf6d853f7f253bc
parent533d2a9d8abd820e21986a46fb626bf25c9e1c2f (diff)
parent27934c38ac8cc367bf62a72e287bc55b2eb96e1e (diff)
Merge branch 'sparse-distance-matrix' into representative-cocycles
# Conflicts: # ripser.cpp
-rw-r--r--ripser.cpp75
1 files changed, 39 insertions, 36 deletions
diff --git a/ripser.cpp b/ripser.cpp
index aa0a8cb..dc3ae94 100644
--- a/ripser.cpp
+++ b/ripser.cpp
@@ -377,12 +377,6 @@ public:
}
};
-template <typename Heap>
-void push_entry(Heap& column, index_t i, coefficient_t c, value_t diameter) {
- entry_t e = make_entry(i, c);
- column.push(std::make_pair(diameter, e));
-}
-
template <typename DistanceMatrix> class ripser {
DistanceMatrix dist;
index_t n, dim_max;
@@ -532,35 +526,7 @@ public:
#endif
Column& working_coboundary, const index_t& dim,
hash_map<index_t, index_t>& pivot_column_index,
- bool& might_be_apparent_pair) {
- for (auto it = column_begin; it != column_end; ++it) {
- diameter_entry_t simplex = *it;
- set_coefficient(simplex, get_coefficient(simplex) * factor_column_to_add % modulus);
-
-#ifdef ASSEMBLE_REDUCTION_MATRIX
- working_reduction_column.push(simplex);
-#endif
-
- coface_entries.clear();
- simplex_coboundary_enumerator cofaces(simplex, dim, *this);
- while (cofaces.has_next()) {
- diameter_entry_t coface = cofaces.next();
- if (get_diameter(coface) <= threshold) {
- coface_entries.push_back(coface);
- if (might_be_apparent_pair && (get_diameter(simplex) == get_diameter(coface))) {
- if (pivot_column_index.find(get_index(coface)) ==
- pivot_column_index.end()) {
- return coface;
- }
- might_be_apparent_pair = false;
- }
- }
- }
- for (auto coface : coface_entries) working_coboundary.push(coface);
- }
-
- return get_pivot(working_coboundary, modulus);
- }
+ bool& might_be_apparent_pair);
template<typename Chain>
void print_chain(Chain& cycle, index_t dim) {
@@ -688,7 +654,7 @@ public:
} else {
#ifdef PRINT_PERSISTENCE_PAIRS
value_t death = get_diameter(pivot);
- if (diameter != death) {
+ if (death > diameter * ratio) {
#ifdef INDICATE_PROGRESS
std::cout << "\033[K";
#endif
@@ -813,6 +779,43 @@ public:
}
};
+template <typename DistanceMatrix>
+template <typename Column, typename Iterator>
+diameter_entry_t ripser<DistanceMatrix>::add_coboundary_and_get_pivot(
+ Iterator column_begin, Iterator column_end, coefficient_t factor_column_to_add,
+#ifdef ASSEMBLE_REDUCTION_MATRIX
+ Column& working_reduction_column,
+#endif
+ Column& working_coboundary, const index_t& dim, hash_map<index_t, index_t>& pivot_column_index,
+ bool& might_be_apparent_pair) {
+ for (auto it = column_begin; it != column_end; ++it) {
+ diameter_entry_t simplex = *it;
+ set_coefficient(simplex, get_coefficient(simplex) * factor_column_to_add % modulus);
+
+#ifdef ASSEMBLE_REDUCTION_MATRIX
+ working_reduction_column.push(simplex);
+#endif
+
+ coface_entries.clear();
+ simplex_coboundary_enumerator cofaces(simplex, dim, *this);
+ while (cofaces.has_next()) {
+ diameter_entry_t coface = cofaces.next();
+ if (get_diameter(coface) <= threshold) {
+ coface_entries.push_back(coface);
+ if (might_be_apparent_pair && (get_diameter(simplex) == get_diameter(coface))) {
+ if (pivot_column_index.find(get_index(coface)) == pivot_column_index.end()) {
+ return coface;
+ }
+ might_be_apparent_pair = false;
+ }
+ }
+ }
+ for (auto coface : coface_entries) working_coboundary.push(coface);
+ }
+
+ return get_pivot(working_coboundary, modulus);
+}
+
template <> class ripser<sparse_distance_matrix>::simplex_coboundary_enumerator {
private:
const ripser& parent;