diff options
author | Gard Spreemann <gspreemann@gmail.com> | 2018-06-15 12:42:55 +0200 |
---|---|---|
committer | Gard Spreemann <gspreemann@gmail.com> | 2018-06-15 12:42:55 +0200 |
commit | c31bac6af57af917b8f799d0c21eb6af34ee1f6e (patch) | |
tree | 5a9603a4ec016f1aa09c7da52510790680c790c3 /cython/include/Persistent_cohomology_interface.h | |
parent | 02de1136cf9850803cb1e1ac1141f11b50be2992 (diff) | |
parent | 41482b4260b4aff3d6803e340d5c94fbefb9af67 (diff) |
Merge branch 'dfsg/latest' into debian/sid
Diffstat (limited to 'cython/include/Persistent_cohomology_interface.h')
-rw-r--r-- | cython/include/Persistent_cohomology_interface.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/cython/include/Persistent_cohomology_interface.h b/cython/include/Persistent_cohomology_interface.h index 55028fd0..8cf71a4e 100644 --- a/cython/include/Persistent_cohomology_interface.h +++ b/cython/include/Persistent_cohomology_interface.h @@ -4,7 +4,7 @@ * * Author(s): Vincent Rouvreau * - * Copyright (C) 2016 INRIA + * Copyright (C) 2016 Inria * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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_; |