From db1398bcf173f372fc3ef7a410e4e72b0192f8cc Mon Sep 17 00:00:00 2001 From: skachano Date: Fri, 20 Jan 2017 15:24:36 +0000 Subject: non-Euclidean example works, but the test not anymore git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1975 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 251638e6417f1059529d57a8a87364a17cf9f5a2 --- src/Witness_complex/example/example_nearest_landmark_table.cpp | 10 ++++------ .../include/gudhi/Active_witness/Active_witness.h | 2 +- .../include/gudhi/Active_witness/Active_witness_iterator.h | 5 +++-- src/Witness_complex/include/gudhi/Witness_complex.h | 2 +- src/Witness_complex/test/test_simple_witness_complex.cpp | 4 ++-- 5 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src/Witness_complex') diff --git a/src/Witness_complex/example/example_nearest_landmark_table.cpp b/src/Witness_complex/example/example_nearest_landmark_table.cpp index 00ec17e0..becf74e7 100644 --- a/src/Witness_complex/example/example_nearest_landmark_table.cpp +++ b/src/Witness_complex/example/example_nearest_landmark_table.cpp @@ -17,6 +17,7 @@ #include #include #include +#include int main(int argc, char * const argv[]) { typedef std::vector> Nearest_landmark_range; @@ -26,21 +27,18 @@ int main(int argc, char * const argv[]) { Gudhi::Simplex_tree<> simplex_tree; Nearest_landmark_table nlt; - // Example contains 10 witnesses and 5 landmarks + // Example contains 5 witnesses and 5 landmarks Nearest_landmark_range w0 = {std::make_pair(0,0), std::make_pair(1,1), std::make_pair(2,2), std::make_pair(3,3), std::make_pair(4,4)}; nlt.push_back(w0); Nearest_landmark_range w1 = {std::make_pair(1,0), std::make_pair(2,1), std::make_pair(3,2), std::make_pair(4,3), std::make_pair(0,4)}; nlt.push_back(w1); Nearest_landmark_range w2 = {std::make_pair(2,0), std::make_pair(3,1), std::make_pair(4,2), std::make_pair(0,3), std::make_pair(1,4)}; nlt.push_back(w2); Nearest_landmark_range w3 = {std::make_pair(3,0), std::make_pair(4,1), std::make_pair(0,2), std::make_pair(1,3), std::make_pair(2,4)}; nlt.push_back(w3); Nearest_landmark_range w4 = {std::make_pair(4,0), std::make_pair(0,1), std::make_pair(1,2), std::make_pair(2,3), std::make_pair(3,4)}; nlt.push_back(w4); - Nearest_landmark_range x0 = {std::make_pair(0,0), std::make_pair(4,1), std::make_pair(3,2), std::make_pair(2,3), std::make_pair(1,4)}; nlt.push_back(x0); - Nearest_landmark_range x1 = {std::make_pair(1,0), std::make_pair(0,1), std::make_pair(4,2), std::make_pair(3,3), std::make_pair(2,4)}; nlt.push_back(x1); - Nearest_landmark_range x2 = {std::make_pair(2,0), std::make_pair(1,1), std::make_pair(0,2), std::make_pair(4,3), std::make_pair(3,4)}; nlt.push_back(x2); - Nearest_landmark_range x3 = {std::make_pair(3,0), std::make_pair(2,1), std::make_pair(1,2), std::make_pair(0,3), std::make_pair(4,4)}; nlt.push_back(x3); - Nearest_landmark_range x4 = {std::make_pair(4,0), std::make_pair(3,1), std::make_pair(2,2), std::make_pair(1,3), std::make_pair(0,4)}; nlt.push_back(x4); Witness_complex witness_complex(nlt); witness_complex.create_complex(simplex_tree, 4.1); + std::cout << "Number of simplices: " << simplex_tree.num_simplices() << std::endl; + Gudhi::persistent_cohomology::Persistent_cohomology, Gudhi::persistent_cohomology::Field_Zp > pcoh(simplex_tree); // initializes the coefficient field for homology pcoh.init_coefficients(11); diff --git a/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h index debbd286..c3edc0b7 100644 --- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h +++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness.h @@ -50,7 +50,7 @@ public: INS_iterator iterator_end_; Active_witness(INS_range search_range) - : search_range_(search_range), iterator_last_(search_range.begin()), iterator_end_(search_range.end()) + : search_range_(search_range), iterator_last_(search_range_.begin()), iterator_end_(search_range_.end()) { nearest_landmark_table_.push_back(*iterator_last_); } diff --git a/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h index 5b040914..b0a88662 100644 --- a/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h +++ b/src/Witness_complex/include/gudhi/Active_witness/Active_witness_iterator.h @@ -86,12 +86,13 @@ private : // if the id of the current landmark is the same as the last one if (lh_->first == aw_->iterator_last_->first) { // if the next iterator is end, lh_it = end pointer - if (++(aw_->iterator_last_) == aw_->iterator_end_) { + INS_iterator next_it = aw_->iterator_last_; next_it++; + if (next_it == aw_->iterator_end_) { is_end_ = true; return; } else { - //aw_->iterator_last_ = ++(aw_->iterator_last_); + ++(aw_->iterator_last_); aw_->nearest_landmark_table_.push_back(*(aw_->iterator_last_)); } } diff --git a/src/Witness_complex/include/gudhi/Witness_complex.h b/src/Witness_complex/include/gudhi/Witness_complex.h index 3305a8e2..576b8b0d 100644 --- a/src/Witness_complex/include/gudhi/Witness_complex.h +++ b/src/Witness_complex/include/gudhi/Witness_complex.h @@ -62,7 +62,7 @@ private: typedef Landmark_id Vertex_handle; private: - Nearest_landmark_table_& nearest_landmark_table_; + Nearest_landmark_table_ nearest_landmark_table_; public: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/Witness_complex/test/test_simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp index 2d4134f4..b47ebe4d 100644 --- a/src/Witness_complex/test/test_simple_witness_complex.cpp +++ b/src/Witness_complex/test/test_simple_witness_complex.cpp @@ -31,6 +31,7 @@ typedef Gudhi::spatial_searching::Kd_tree_search Kd_tree; typedef Kd_tree::INS_range Nearest_landmark_range; typedef std::vector Nearest_landmark_table; typedef Gudhi::witness_complex::Witness_complex WitnessComplex; +typedef Gudhi::witness_complex::Strong_witness_complex StrongWitnessComplex; /* All landmarks and witnesses are taken on the grid in the following manner. @@ -117,8 +118,7 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) { // Strong complex : non-Euclidean version - EuclideanStrongWitnessComplex strong_witness_complex(landmarks, - witnesses); + StrongWitnessComplex strong_witness_complex(nearest_landmark_table); strong_witness_complex.create_complex(strong_relaxed_complex_ne, 9.1); strong_witness_complex.create_complex(strong_relaxed_complex2_ne, 9.1, 2); -- cgit v1.2.3