1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/* Copyright 2013 IST Austria
Contributed by: Ulrich Bauer, Michael Kerber, Jan Reininghaus
This file is part of PHAT.
PHAT is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PHAT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with PHAT. If not, see <http://www.gnu.org/licenses/>. */
#pragma once
#include <phat/persistence_pairs.h>
#include <phat/boundary_matrix.h>
#include <phat/helpers/dualize.h>
#include <phat/algorithms/twist_reduction.h>
namespace phat {
template< typename ReductionAlgorithm, typename Representation >
void compute_persistence_pairs( persistence_pairs& pairs, boundary_matrix< Representation >& boundary_matrix ) {
ReductionAlgorithm reduce;
reduce( boundary_matrix );
pairs.clear();
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 );
index death = idx;
pairs.append_pair( birth, death );
}
}
}
template< typename ReductionAlgorithm, typename Representation >
void compute_persistence_pairs_dualized( persistence_pairs& pairs, boundary_matrix< Representation >& boundary_matrix ) {
dualize( boundary_matrix );
compute_persistence_pairs< ReductionAlgorithm >( pairs, boundary_matrix );
dualize_persistence_pairs( pairs, boundary_matrix.get_num_cols() );
}
template< typename Representation >
void compute_persistence_pairs( persistence_pairs& pairs, boundary_matrix< Representation >& boundary_matrix ) {
phat::compute_persistence_pairs< twist_reduction >( pairs, boundary_matrix );
}
template< typename Representation >
void compute_persistence_pairs_dualized( persistence_pairs& pairs, boundary_matrix< Representation >& boundary_matrix ) {
compute_persistence_pairs_dualized< twist_reduction >( pairs, boundary_matrix );
}
}
|