summaryrefslogtreecommitdiff
path: root/src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-06-16 08:49:28 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2016-06-16 08:49:28 +0000
commit3c00d75d416bda60c1dd2b9ab3505fb52bd7627a (patch)
tree864d62ef8401c2a55bd4a6b9191f7a06f6200ac0 /src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h
parent0d6ae28db21f3c8529d4eb5dc22d02b74000f162 (diff)
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
Diffstat (limited to 'src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h')
-rw-r--r--src/Persistent_cohomology/include/gudhi/Persistent_cohomology.h16
1 files changed, 11 insertions, 5 deletions
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<int> 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<int> 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;