diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-05-30 21:13:34 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-05-30 21:13:34 +0000 |
commit | 7332184fd63e8ebbe7e9fcb0d4a2a694e9c54296 (patch) | |
tree | 178bca6c0fabe13784c1fb695a1713d722c681d9 /src/cython/include/Persistent_cohomology_interface.h | |
parent | 1f1033f14cef0b5b602a23c9f35659fa0168f1b4 (diff) | |
parent | 01cfd13aa84317debb4bf681309533b693322131 (diff) |
Merge branch python_2.1.0_fix_vincent
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@3496 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: d4f09bc2e10151cec21fe3026e8dc1a530d15563
Diffstat (limited to 'src/cython/include/Persistent_cohomology_interface.h')
-rw-r--r-- | src/cython/include/Persistent_cohomology_interface.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/cython/include/Persistent_cohomology_interface.h b/src/cython/include/Persistent_cohomology_interface.h index a86b1187..dee5e487 100644 --- a/src/cython/include/Persistent_cohomology_interface.h +++ b/src/cython/include/Persistent_cohomology_interface.h @@ -85,6 +85,32 @@ persistent_cohomology::Persistent_cohomology<FilteredComplex, persistent_cohomol return persistence; } + 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(); + + std::vector<std::pair<std::vector<int>, std::vector<int>>> persistence_pairs; + persistence_pairs.reserve(pairs.size()); + for (auto pair : pairs) { + std::vector<int> birth; + if (get<0>(pair) != stptr_->null_simplex()) { + for (auto vertex : stptr_->simplex_vertex_range(get<0>(pair))) { + birth.push_back(vertex); + } + } + + std::vector<int> death; + if (get<1>(pair) != stptr_->null_simplex()) { + for (auto vertex : stptr_->simplex_vertex_range(get<1>(pair))) { + death.push_back(vertex); + } + } + + persistence_pairs.push_back(std::make_pair(birth,death)); + } + return persistence_pairs; + } + private: // A copy FilteredComplex* stptr_; |