diff options
author | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-03-09 06:26:49 +0100 |
---|---|---|
committer | Arnur Nigmetov <nigmetov@tugraz.at> | 2020-03-09 06:26:49 +0100 |
commit | 14e91d6c3ad81a1ec763d75a28f20fb689e5166e (patch) | |
tree | 54dcb2399a2386bc035de932e74e933b8b7537fe /matching/include | |
parent | 490fed367bb97a96b90caa6ef04265c063d91df1 (diff) |
Add tests for module slice restriction.
Diffstat (limited to 'matching/include')
-rw-r--r-- | matching/include/matching_distance.h | 17 | ||||
-rw-r--r-- | matching/include/persistence_module.h | 7 | ||||
-rw-r--r-- | matching/include/persistence_module.hpp | 24 |
3 files changed, 37 insertions, 11 deletions
diff --git a/matching/include/matching_distance.h b/matching/include/matching_distance.h index e82a97c..e1679dc 100644 --- a/matching/include/matching_distance.h +++ b/matching/include/matching_distance.h @@ -149,20 +149,20 @@ namespace md { Real hera_epsilon {0.001}; // relative error in hera call Real delta {0.1}; // relative error for matching distance - int max_depth {6}; // maximal number of refinenemnts - int initialization_depth {3}; + int max_depth {8}; // maximal number of refinenemnts + int initialization_depth {2}; int dim {0}; // in which dim to calculate the distance; use ALL_DIMENSIONS to get max over all dims BoundStrategy bound_strategy {BoundStrategy::local_combined}; TraverseStrategy traverse_strategy {TraverseStrategy::breadth_first}; - bool tolerate_max_iter_exceeded {true}; + bool tolerate_max_iter_exceeded {false}; Real actual_error {std::numeric_limits<Real>::max()}; int actual_max_depth {0}; int n_hera_calls {0}; // for experiments only; is set in matching_distance function, input value is ignored // stop looping over points immediately, if current point's displacement is too large // to prune the cell - // if true, cells are pruned immediately, and bounds may be unreliable - // (we just return something large enough to prune the cell) + // if true, cells are pruned immediately, and bounds may increase + // (just return something large enough to not prune the cell) bool stop_asap { true }; // print statistics on each quad-tree level @@ -188,8 +188,11 @@ namespace md { Real distance(); int get_hera_calls_number() const; -// for tests - make everything public -// private: + +#ifndef MD_TEST_CODE + private: +#endif + DiagramProvider module_a_; DiagramProvider module_b_; diff --git a/matching/include/persistence_module.h b/matching/include/persistence_module.h index 4a261bb..b68c21e 100644 --- a/matching/include/persistence_module.h +++ b/matching/include/persistence_module.h @@ -80,7 +80,9 @@ namespace md { PointVec<Real> positions() const; +#ifndef MD_TEST_CODE private: +#endif PointVec<Real> generators_; std::vector<Relation> relations_; @@ -94,8 +96,13 @@ namespace md { Box<Real> bounding_box_; void init_boundaries(); + void project_generators(const DualPoint<Real>& slice, IndexVec& sorted_indices, RealVec& projections) const; void project_relations(const DualPoint<Real>& slice, IndexVec& sorted_indices, RealVec& projections) const; + + void get_slice_projection_matrix(const DualPoint<Real>& slice, phat::boundary_matrix<>& phat_matrix, + RealVec& gen_projections, RealVec& rel_projections) const; + }; } // namespace md diff --git a/matching/include/persistence_module.hpp b/matching/include/persistence_module.hpp index 128fed9..233a70d 100644 --- a/matching/include/persistence_module.hpp +++ b/matching/include/persistence_module.hpp @@ -116,7 +116,11 @@ namespace md { for(const auto& rel : relations_) { rel_values.push_back(slice.weighted_push(rel.position_)); } + sorted_rel_indices = get_sorted_indices(rel_values); + + spd::debug("rel_values = {}, sorted_rel_indices = {}", container_to_string(rel_values), container_to_string(sorted_rel_indices)); + projections.clear(); projections.reserve(num_rels); for(auto i : sorted_rel_indices) { @@ -125,18 +129,18 @@ namespace md { } } + template<class Real> - Diagram<Real> ModulePresentation<Real>::weighted_slice_diagram(const DualPoint<Real>& slice) const + void ModulePresentation<Real>::get_slice_projection_matrix(const DualPoint<Real>& slice, + phat::boundary_matrix<>& phat_matrix, + RealVec& gen_projections, RealVec& rel_projections) const { spd::debug("Enter weighted_slice_diagram, slice = {}", slice); IndexVec sorted_gen_indices, sorted_rel_indices; - RealVec gen_projections, rel_projections; project_generators(slice, sorted_gen_indices, gen_projections); project_relations(slice, sorted_rel_indices, rel_projections); - phat::boundary_matrix<> phat_matrix; - phat_matrix.set_num_cols(relations_.size()); for(Index i = 0; i < (Index) relations_.size(); i++) { @@ -149,6 +153,18 @@ namespace md { phat_matrix.set_dim(i, 0); phat_matrix.set_col(i, current_relation); } + } + + + template<class Real> + Diagram<Real> ModulePresentation<Real>::weighted_slice_diagram(const DualPoint<Real>& slice) const + { + spd::debug("Enter weighted_slice_diagram, slice = {}", slice); + + RealVec gen_projections, rel_projections; + phat::boundary_matrix<> phat_matrix; + + get_slice_projection_matrix(slice, phat_matrix, gen_projections, rel_projections); phat::persistence_pairs phat_persistence_pairs; phat::compute_persistence_pairs<phat::twist_reduction>(phat_persistence_pairs, phat_matrix); |