diff options
Diffstat (limited to 'src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h')
-rw-r--r-- | src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h index b31df6a4..b3339b7d 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h @@ -110,7 +110,7 @@ class Persistent_cohomology { cell_pool_() { if (cpx_->num_simplices() > std::numeric_limits<Simplex_key>::max()) { // num_simplices must be strictly lower than the limit, because a value is reserved for null_key. - throw std::out_of_range ("The number of simplices is more than Simplex_key type numeric limit."); + throw std::out_of_range("The number of simplices is more than Simplex_key type numeric limit."); } Simplex_key idx_fil = 0; for (auto sh : cpx_->filtration_simplex_range()) { @@ -300,8 +300,7 @@ class Persistent_cohomology { // with multiplicity. We used to sum the coefficients directly in // annotations_in_boundary by using a map, we now do it later. typedef std::pair<Column *, int> annotation_t; - // Danger: not thread-safe! - static std::vector<annotation_t> annotations_in_boundary; + thread_local std::vector<annotation_t> annotations_in_boundary; annotations_in_boundary.clear(); int sign = 1 - 2 * (dim_sigma % 2); // \in {-1,1} provides the sign in the // alternate sum in the boundary. @@ -690,6 +689,22 @@ class Persistent_cohomology { return persistent_pairs_; } + /** @brief Returns persistence intervals for a given dimension. + * @param[in] dimension Dimension to get the birth and death pairs from. + * @return A vector of persistence intervals (birth and death) on a fixed dimension. + */ + std::vector< std::pair< Filtration_value , Filtration_value > > + intervals_in_dimension(int dimension) { + std::vector< std::pair< Filtration_value , Filtration_value > > result; + // auto && pair, to avoid unnecessary copying + for (auto && pair : persistent_pairs_) { + if (cpx_->dimension(get<0>(pair)) == dimension) { + result.emplace_back(cpx_->filtration(get<0>(pair)), cpx_->filtration(get<1>(pair))); + } + } + return result; + } + private: /* * Structure representing a cocycle. |