From 3c00d75d416bda60c1dd2b9ab3505fb52bd7627a Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 16 Jun 2016 08:49:28 +0000 Subject: Fix after code review git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/get_persistence@1299 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 2c58cbcd94f72930f8516121f47cace95a84511c --- .../include/gudhi/Persistent_cohomology.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h index efa9a367..a7d1e463 100644 --- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h +++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h @@ -594,7 +594,7 @@ class Persistent_cohomology { } /** @brief Returns Betti numbers. - * @return A vector of persistent Betti numbers. + * @return A vector of Betti numbers. */ std::vector betti_numbers() const { // Init Betti numbers vector with zeros until Simplicial complex dimension @@ -632,7 +632,7 @@ class Persistent_cohomology { /** @brief Returns the persistent Betti numbers. * @param[in] from The persistence birth limit to be added in the number \f$(persistent birth \leq from)\f$. - * @param[in] to The persistence death limit to be added in the number \f$(persistent death > from)\f$. + * @param[in] to The persistence death limit to be added in the number \f$(persistent death > to)\f$. * @return A vector of persistent Betti numbers. */ std::vector persistent_betti_numbers(Filtration_value from, Filtration_value to) const { @@ -641,7 +641,10 @@ class Persistent_cohomology { for (auto pair : persistent_pairs_) { // Count persistence intervals that covers the given interval - if (cpx_->filtration(get<0>(pair)) <= from && cpx_->filtration(get<1>(pair)) > to) { + // null_simplex test : if the function is called with to=+infinity, we still get something useful. And it will + // still work if we change the complex filtration function to reject null simplices. + if (cpx_->filtration(get<0>(pair)) <= from && + (get<1>(pair) == cpx_->null_simplex() || cpx_->filtration(get<1>(pair)) > to)) { // Increment corresponding betti number betti_numbers[cpx_->dimension(get<0>(pair))] += 1; } @@ -652,7 +655,7 @@ class Persistent_cohomology { /** @brief Returns the persistent Betti number of the dimension passed by parameter. * @param[in] dimension The Betti number dimension to get. * @param[in] from The persistence birth limit to be added in the number \f$(persistent birth \leq from)\f$. - * @param[in] to The persistence death limit to be added in the number \f$(persistent death > from)\f$. + * @param[in] to The persistence death limit to be added in the number \f$(persistent death > to)\f$. * @return Persistent Betti number of the given dimension */ int persistent_betti_number(int dimension, Filtration_value from, Filtration_value to) const { @@ -660,7 +663,10 @@ class Persistent_cohomology { for (auto pair : persistent_pairs_) { // Count persistence intervals that covers the given interval - if (cpx_->filtration(get<0>(pair)) <= from && cpx_->filtration(get<1>(pair)) > to) { + // null_simplex test : if the function is called with to=+infinity, we still get something useful. And it will + // still work if we change the complex filtration function to reject null simplices. + if (cpx_->filtration(get<0>(pair)) <= from && + (get<1>(pair) == cpx_->null_simplex() || cpx_->filtration(get<1>(pair)) > to)) { if (cpx_->dimension(get<0>(pair)) == dimension) { // Increment betti number found ++betti_number; -- cgit v1.2.3