summaryrefslogtreecommitdiff
path: root/matching/include/phat
diff options
context:
space:
mode:
Diffstat (limited to 'matching/include/phat')
-rw-r--r--matching/include/phat/compute_persistence_pairs.h11
-rw-r--r--matching/include/phat/helpers/misc.h3
2 files changed, 13 insertions, 1 deletions
diff --git a/matching/include/phat/compute_persistence_pairs.h b/matching/include/phat/compute_persistence_pairs.h
index 48be65c..06f5372 100644
--- a/matching/include/phat/compute_persistence_pairs.h
+++ b/matching/include/phat/compute_persistence_pairs.h
@@ -97,14 +97,23 @@ namespace phat {
ReductionAlgorithm reduce;
reduce( boundary_matrix );
pairs.clear();
+ std::set<index> max_indices;
+ // finite pairs
for( index idx = 0; idx < boundary_matrix.get_num_cols(); idx++ ) {
if( !boundary_matrix.is_empty( idx ) ) {
index birth = boundary_matrix.get_max_index( idx );
+ max_indices.insert(birth);
index death = idx;
pairs.append_pair( birth, death );
}
}
- }
+ // infinite pairs: column idx is 0, and row idx does not contain a lowest one
+ for( index idx = 0; idx < boundary_matrix.get_num_cols(); idx++ ) {
+ if(boundary_matrix.is_empty(idx) && max_indices.count(idx) == 0 ) {
+ pairs.append_pair( idx, k_infinity_index);
+ }
+ }
+ }
template< typename ReductionAlgorithm, typename Representation >
void compute_persistence_pairs_dualized( persistence_pairs& pairs, boundary_matrix< Representation >& boundary_matrix ) {
diff --git a/matching/include/phat/helpers/misc.h b/matching/include/phat/helpers/misc.h
index 3e1ed56..5a5c682 100644
--- a/matching/include/phat/helpers/misc.h
+++ b/matching/include/phat/helpers/misc.h
@@ -35,6 +35,7 @@
#include <cmath>
#include <cstdlib>
#include <iterator>
+#include <limits>
// VS2008 and below unfortunately do not support stdint.h
#if defined(_MSC_VER)&& _MSC_VER < 1600
@@ -55,6 +56,8 @@ namespace phat {
typedef int64_t index;
typedef int8_t dimension;
typedef std::vector< index > column;
+
+ constexpr index k_infinity_index = std::numeric_limits<index>::max();
}
// OpenMP (proxy) functions