diff options
author | Arnur Nigmetov <anigmetov@lbl.gov> | 2021-05-07 22:38:27 -0700 |
---|---|---|
committer | Arnur Nigmetov <anigmetov@lbl.gov> | 2021-05-07 22:40:37 -0700 |
commit | 2ed9afc052bee7956f6abb195947de1f80cb9d91 (patch) | |
tree | 15211941e0b14ffa2b80ce4de5b66bf89068ac20 /matching/include/phat/compute_persistence_pairs.h | |
parent | b528c4067a8aac346eb307d3c23b82d5953cfe2d (diff) |
Fix bugs in matching distance for modules.
1. Twist reduction should not be used for modules, clearing makes no
sense and creates erroneous points. Just use standard reduction.
2. Infinite points for modules (gens/relations case) are treated
slightly differently.
Diffstat (limited to 'matching/include/phat/compute_persistence_pairs.h')
-rw-r--r-- | matching/include/phat/compute_persistence_pairs.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/matching/include/phat/compute_persistence_pairs.h b/matching/include/phat/compute_persistence_pairs.h index 06f5372..bd5e3ac 100644 --- a/matching/include/phat/compute_persistence_pairs.h +++ b/matching/include/phat/compute_persistence_pairs.h @@ -93,7 +93,7 @@ namespace phat { } template< typename ReductionAlgorithm, typename Representation > - void compute_persistence_pairs( persistence_pairs& pairs, boundary_matrix< Representation >& boundary_matrix ) { + void compute_persistence_pairs( persistence_pairs& pairs, boundary_matrix< Representation >& boundary_matrix, bool for_persistence_module = false ) { ReductionAlgorithm reduce; reduce( boundary_matrix ); pairs.clear(); @@ -107,10 +107,19 @@ namespace phat { 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); + if (for_persistence_module) { + // infinite pairs for modules: if generator is not matched to relation, it lives forever + for( index idx = 0; idx < boundary_matrix.get_num_rows(0); idx++ ) { + if(max_indices.count(idx) == 0 ) { + pairs.append_pair( idx, k_infinity_index); + } + } + } else { + // 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); + } } } } |