summaryrefslogtreecommitdiff
path: root/src/python/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/include')
-rw-r--r--src/python/include/Persistent_cohomology_interface.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/python/include/Persistent_cohomology_interface.h b/src/python/include/Persistent_cohomology_interface.h
index 8c79e6f3..77555349 100644
--- a/src/python/include/Persistent_cohomology_interface.h
+++ b/src/python/include/Persistent_cohomology_interface.h
@@ -63,7 +63,6 @@ persistent_cohomology::Persistent_cohomology<FilteredComplex, persistent_cohomol
auto persistent_pairs = persistent_cohomology::Persistent_cohomology<FilteredComplex,
persistent_cohomology::Field_Zp>::get_persistent_pairs();
std::sort(std::begin(persistent_pairs), std::end(persistent_pairs), cmp);
-
std::vector<std::pair<int, std::pair<double, double>>> persistence;
for (auto pair : persistent_pairs) {
persistence.push_back(std::make_pair(stptr_->dimension(get<0>(pair)),
@@ -73,6 +72,43 @@ persistent_cohomology::Persistent_cohomology<FilteredComplex, persistent_cohomol
return persistence;
}
+ std::vector<std::vector<int>> cofaces_of_cubical_persistence_pairs() {
+
+ // Warning: this function is meant to be used with CubicalComplex only!!
+
+ auto pairs = persistent_cohomology::Persistent_cohomology<FilteredComplex,
+ persistent_cohomology::Field_Zp>::get_persistent_pairs();
+
+ // Gather all top-dimensional cells and store their simplex handles
+ std::vector<int> max_splx; for (auto splx : stptr_->top_dimensional_cells_range()){
+ max_splx.push_back(splx);
+ }
+ // Sort these simplex handles and compute the ordering function
+ // This function allows to go directly from the simplex handle to the position of the corresponding top-dimensional cell in the input data
+ std::map<int, int> order; std::sort(max_splx.begin(), max_splx.end());
+ for (unsigned int i = 0; i < max_splx.size(); i++) order.insert(std::make_pair(max_splx[i], i));
+
+ std::vector<std::vector<int>> persistence_pairs;
+ for (auto pair : pairs) {
+ int h = stptr_->dimension(get<0>(pair));
+ // Recursively get the top-dimensional cell / coface associated to the persistence generator
+ int face0 = stptr_->get_top_dimensional_coface_of_a_cell(get<0>(pair));
+ // Retrieve the index of the corresponding top-dimensional cell in the input data
+ int splx0 = order[face0];
+
+ int splx1 = -1;
+ if (isfinite(stptr_->filtration(get<1>(pair)))){
+ // Recursively get the top-dimensional cell / coface associated to the persistence generator
+ int face1 = stptr_->get_top_dimensional_coface_of_a_cell(get<1>(pair));
+ // Retrieve the index of the corresponding top-dimensional cell in the input data
+ splx1 = order[face1];
+ }
+ std::vector<int> vect{ h, splx0, splx1};
+ persistence_pairs.push_back(vect);
+ }
+ return persistence_pairs;
+ }
+
std::vector<std::pair<std::vector<int>, std::vector<int>>> persistence_pairs() {
auto pairs = persistent_cohomology::Persistent_cohomology<FilteredComplex,
persistent_cohomology::Field_Zp>::get_persistent_pairs();