From ee65fce990b1dc683e1220c18c5f404a82373e55 Mon Sep 17 00:00:00 2001 From: Arnur Nigmetov Date: Tue, 14 Jan 2020 16:17:43 +0100 Subject: Interim: matching distance for modules 1. Templatize DistanceCalculator (DiagramProvider) 2. Add BifiltrationProxy with the same interface as ModulePresentation (dimension fixed). 3. Call Hera with relative error. 4. Add class ModulePresentation. To-Do: reading module presentations from Rivet format. --- matching/include/phat/compute_persistence_pairs.h | 11 ++++++++++- matching/include/phat/helpers/misc.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'matching/include/phat') 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 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 #include #include +#include // 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::max(); } // OpenMP (proxy) functions -- cgit v1.2.3