From d68d79f7274ecc01ec539f74e04e9e4f940751ba Mon Sep 17 00:00:00 2001 From: skachano Date: Tue, 4 Oct 2016 09:07:21 +0000 Subject: Changed the second choose_n_farthest_points' incostistencies git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1614 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 285b607d598b0f50efd6d4f1f3d4e38dfc2d097a --- src/Subsampling/include/gudhi/choose_n_farthest_points.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index 8bfb38a4..d0f7377a 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -105,9 +105,9 @@ namespace subsampling { template < typename Kernel, typename Point_container, typename OutputIterator> - void choose_n_farthest_points( Kernel& k, + void choose_n_farthest_points( Kernel const& k, Point_container const &input_pts, - int final_size, + unsigned final_size, OutputIterator output_it) { // Choose randomly the first landmark -- cgit v1.2.3 From 9356208327a9784b570b96ce5007f785c2abebef Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 4 Oct 2016 13:55:48 +0000 Subject: Don't use Point_d(std::array... git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1624 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b91315785cc6fbab1843b8f0e2d1778e920998b9 --- src/Subsampling/example/example_choose_n_farthest_points.cpp | 2 +- src/Subsampling/example/example_pick_n_random_points.cpp | 2 +- src/Subsampling/example/example_sparsify_point_set.cpp | 2 +- src/Subsampling/test/test_sparsify_point_set.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Subsampling/example/example_choose_n_farthest_points.cpp b/src/Subsampling/example/example_choose_n_farthest_points.cpp index 9955d0ec..7afc8033 100644 --- a/src/Subsampling/example/example_choose_n_farthest_points.cpp +++ b/src/Subsampling/example/example_choose_n_farthest_points.cpp @@ -17,7 +17,7 @@ int main (void) std::vector points; for (int i = 0 ; i < 500 ; ++i) - points.push_back(Point_d(std::array({rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1)}))); + points.push_back(Point_d(rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1))); K k; std::vector results; diff --git a/src/Subsampling/example/example_pick_n_random_points.cpp b/src/Subsampling/example/example_pick_n_random_points.cpp index d2f063ba..e0d3b789 100644 --- a/src/Subsampling/example/example_pick_n_random_points.cpp +++ b/src/Subsampling/example/example_pick_n_random_points.cpp @@ -17,7 +17,7 @@ int main (void) std::vector points; for (int i = 0 ; i < 500 ; ++i) - points.push_back(Point_d(std::array({rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1)}))); + points.push_back(Point_d(rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1))); K k; std::vector results; diff --git a/src/Subsampling/example/example_sparsify_point_set.cpp b/src/Subsampling/example/example_sparsify_point_set.cpp index cb5ccf0b..7c8cf8b0 100644 --- a/src/Subsampling/example/example_sparsify_point_set.cpp +++ b/src/Subsampling/example/example_sparsify_point_set.cpp @@ -17,7 +17,7 @@ int main (void) std::vector points; for (int i = 0 ; i < 500 ; ++i) - points.push_back(Point_d(std::array({rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1)}))); + points.push_back(Point_d(rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1))); K k; std::vector results; diff --git a/src/Subsampling/test/test_sparsify_point_set.cpp b/src/Subsampling/test/test_sparsify_point_set.cpp index 61f6fa18..9eebbcc8 100644 --- a/src/Subsampling/test/test_sparsify_point_set.cpp +++ b/src/Subsampling/test/test_sparsify_point_set.cpp @@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(test_sparsify_point_set) std::vector points; for (int i = 0 ; i < 500 ; ++i) - points.push_back(Point_d(std::array({rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1)}))); + points.push_back(Point_d(rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1))); K k; std::vector results; -- cgit v1.2.3 From e7edd8a70065e882da088de12aba86d3a8d82bb7 Mon Sep 17 00:00:00 2001 From: cjamin Date: Tue, 4 Oct 2016 13:56:12 +0000 Subject: Use std::size_t instead of unsigned git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1625 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: cfc0013c1247512eb4899809975266a971d57c34 --- src/Subsampling/include/gudhi/pick_n_random_points.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Subsampling/include/gudhi/pick_n_random_points.h b/src/Subsampling/include/gudhi/pick_n_random_points.h index 4ca1fafc..b8f4900a 100644 --- a/src/Subsampling/include/gudhi/pick_n_random_points.h +++ b/src/Subsampling/include/gudhi/pick_n_random_points.h @@ -25,6 +25,7 @@ #include +#include #include // random_device, mt19937 #include // shuffle #include // iota @@ -48,13 +49,13 @@ namespace subsampling { template void pick_n_random_points(Point_container const &points, - unsigned final_size, + std::size_t final_size, OutputIterator output_it) { #ifdef GUDHI_SUBS_PROFILING Gudhi::Clock t; #endif - unsigned nbP = boost::size(points); + std::size_t nbP = boost::size(points); assert(nbP >= final_size); std::vector landmarks(nbP); std::iota(landmarks.begin(), landmarks.end(), 0); -- cgit v1.2.3 From 404297f53b222f34a436638117ffb1affca18e7b Mon Sep 17 00:00:00 2001 From: skachano Date: Wed, 5 Oct 2016 09:36:37 +0000 Subject: Warning FT and include array in 2 files git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1642 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: f25797a941de0f814b2bb1d16a0a3b31cd848282 --- src/Subsampling/example/example_choose_n_farthest_points.cpp | 2 -- src/Subsampling/example/example_pick_n_random_points.cpp | 2 -- 2 files changed, 4 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Subsampling/example/example_choose_n_farthest_points.cpp b/src/Subsampling/example/example_choose_n_farthest_points.cpp index 7afc8033..4bcb0eb9 100644 --- a/src/Subsampling/example/example_choose_n_farthest_points.cpp +++ b/src/Subsampling/example/example_choose_n_farthest_points.cpp @@ -3,14 +3,12 @@ #include #include -#include #include #include int main (void) { typedef CGAL::Epick_d > K; - typedef typename K::FT FT; typedef typename K::Point_d Point_d; CGAL::Random rd; diff --git a/src/Subsampling/example/example_pick_n_random_points.cpp b/src/Subsampling/example/example_pick_n_random_points.cpp index e0d3b789..7b4379e4 100644 --- a/src/Subsampling/example/example_pick_n_random_points.cpp +++ b/src/Subsampling/example/example_pick_n_random_points.cpp @@ -3,14 +3,12 @@ #include #include -#include #include #include int main (void) { typedef CGAL::Epick_d > K; - typedef typename K::FT FT; typedef typename K::Point_d Point_d; CGAL::Random rd; -- cgit v1.2.3 From 9f0861b57c2479ffece89e2e4e949a66ef9b47ed Mon Sep 17 00:00:00 2001 From: skachano Date: Wed, 5 Oct 2016 09:56:06 +0000 Subject: Changed unsigned to std::size_t git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1643 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 7282a69d4d3bde59727b42b309ddb6b7e1a5a548 --- src/Subsampling/include/gudhi/choose_n_farthest_points.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index d0f7377a..a4719f56 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -56,27 +56,27 @@ namespace subsampling { typename OutputIterator> void choose_n_farthest_points( Kernel const &k, Point_container const &input_pts, - unsigned final_size, - unsigned starting_point, + std::size_t final_size, + std::size_t starting_point, OutputIterator output_it) { typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object(); - int nb_points = boost::size(input_pts); + std::size_t nb_points = boost::size(input_pts); assert(nb_points >= final_size); - unsigned current_number_of_landmarks = 0; // counter for landmarks + std::size_t current_number_of_landmarks = 0; // counter for landmarks double curr_max_dist = 0; // used for defining the furhest point from L const double infty = std::numeric_limits::infinity(); // infinity (see next entry) std::vector< double > dist_to_L(nb_points, infty); // vector of current distances to L from input_pts - int curr_max_w = starting_point; + std::size_t curr_max_w = starting_point; for (current_number_of_landmarks = 0; current_number_of_landmarks != final_size; current_number_of_landmarks++) { // curr_max_w at this point is the next landmark *output_it++ = input_pts[curr_max_w]; // std::cout << curr_max_w << "\n"; - unsigned i = 0; + std::size_t i = 0; for (auto& p : input_pts) { double curr_dist = sqdist(p, *(std::begin(input_pts) + curr_max_w)); if (curr_dist < dist_to_L[i]) -- cgit v1.2.3 From fb71b41cb649e0c2242bd1997cb5e7285c1633a6 Mon Sep 17 00:00:00 2001 From: cjamin Date: Thu, 6 Oct 2016 07:38:18 +0000 Subject: is not used anymore git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1651 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 20e9d24cb091c436d951b8a396b684a849231bc4 --- src/Spatial_searching/test/test_Kd_tree_search.cpp | 1 - src/Subsampling/example/example_sparsify_point_set.cpp | 1 - src/Subsampling/test/test_sparsify_point_set.cpp | 1 - 3 files changed, 3 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Spatial_searching/test/test_Kd_tree_search.cpp b/src/Spatial_searching/test/test_Kd_tree_search.cpp index df00d2b9..16b72c68 100644 --- a/src/Spatial_searching/test/test_Kd_tree_search.cpp +++ b/src/Spatial_searching/test/test_Kd_tree_search.cpp @@ -29,7 +29,6 @@ #include #include -#include #include BOOST_AUTO_TEST_CASE(test_Kd_tree_search) diff --git a/src/Subsampling/example/example_sparsify_point_set.cpp b/src/Subsampling/example/example_sparsify_point_set.cpp index 7c8cf8b0..ccf83bc0 100644 --- a/src/Subsampling/example/example_sparsify_point_set.cpp +++ b/src/Subsampling/example/example_sparsify_point_set.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include diff --git a/src/Subsampling/test/test_sparsify_point_set.cpp b/src/Subsampling/test/test_sparsify_point_set.cpp index 9eebbcc8..04a055ff 100644 --- a/src/Subsampling/test/test_sparsify_point_set.cpp +++ b/src/Subsampling/test/test_sparsify_point_set.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include -- cgit v1.2.3 From a1d8a8b08002d7d2067b76b7109cae4c20618540 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Oct 2016 10:50:47 +0000 Subject: Add unitary tests in make test target Fix doxygen warning fix compilation warning (typedef not used) git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1652 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: d080543ea90aa089e2f09933a44156f07ae82eb4 --- src/Spatial_searching/example/CMakeLists.txt | 12 +++--------- src/Spatial_searching/test/CMakeLists.txt | 13 ++++--------- src/Subsampling/doc/Intro_subsampling.h | 2 +- src/Subsampling/example/CMakeLists.txt | 22 ++++++++++------------ .../example/example_sparsify_point_set.cpp | 1 - src/Subsampling/test/CMakeLists.txt | 20 ++++++++++++-------- src/Subsampling/test/test_sparsify_point_set.cpp | 1 - 7 files changed, 30 insertions(+), 41 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Spatial_searching/example/CMakeLists.txt b/src/Spatial_searching/example/CMakeLists.txt index 3c3970d8..6238a0ec 100644 --- a/src/Spatial_searching/example/CMakeLists.txt +++ b/src/Spatial_searching/example/CMakeLists.txt @@ -3,17 +3,11 @@ project(Spatial_searching_examples) if(CGAL_FOUND) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) - message(STATUS "CGAL version: ${CGAL_VERSION}.") - if (EIGEN3_FOUND) add_executable( Spatial_searching_example_spatial_searching example_spatial_searching.cpp ) target_link_libraries(Spatial_searching_example_spatial_searching ${CGAL_LIBRARY}) - else() - message(WARNING "Eigen3 not found. Version 3.1.0 is required for the Tangential_complex examples.") + add_test(Spatial_searching_example_spatial_searching + ${CMAKE_CURRENT_BINARY_DIR}/Spatial_searching_example_spatial_searching) endif() - else() - message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile Spatial_searching examples. Version 4.8.1 is required.") - endif () -else() - message(WARNING "CGAL not found. It is required for the Spatial_searching examples.") + endif() endif() diff --git a/src/Spatial_searching/test/CMakeLists.txt b/src/Spatial_searching/test/CMakeLists.txt index 0f2c5ae4..2c685c72 100644 --- a/src/Spatial_searching/test/CMakeLists.txt +++ b/src/Spatial_searching/test/CMakeLists.txt @@ -12,19 +12,14 @@ endif() if(CGAL_FOUND) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) - message(STATUS "CGAL version: ${CGAL_VERSION}.") - if (EIGEN3_FOUND) - add_executable( Spatial_searching_test_Kd_tree_search test_Kd_tree_search.cpp ) target_link_libraries(Spatial_searching_test_Kd_tree_search ${CGAL_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - else() - message(WARNING "Eigen3 not found. Version 3.1.0 is required for the Spatial_searching tests.") + + add_test(Spatial_searching_test_Kd_tree_search ${CMAKE_CURRENT_BINARY_DIR}/Spatial_searching_test_Kd_tree_search + # XML format for Jenkins xUnit plugin + --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/Spatial_searching_UT.xml --log_level=test_suite --report_level=no) endif() - else() - message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile Subsampling tests. Version 4.8.1 is required.") endif () -else() - message(WARNING "CGAL not found. It is required for the Spatial_searching tests.") endif() diff --git a/src/Subsampling/doc/Intro_subsampling.h b/src/Subsampling/doc/Intro_subsampling.h index f8eb2fdd..c84616dd 100644 --- a/src/Subsampling/doc/Intro_subsampling.h +++ b/src/Subsampling/doc/Intro_subsampling.h @@ -34,7 +34,7 @@ namespace subsampling { * * @{ * - * \section introduction Introduction + * \section subsamplingintroduction Introduction * * This Gudhi component offers methods to subsample a set of points. * diff --git a/src/Subsampling/example/CMakeLists.txt b/src/Subsampling/example/CMakeLists.txt index 81b39d6e..54349f0c 100644 --- a/src/Subsampling/example/CMakeLists.txt +++ b/src/Subsampling/example/CMakeLists.txt @@ -3,20 +3,18 @@ project(Subsampling_examples) if(CGAL_FOUND) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) - message(STATUS "CGAL version: ${CGAL_VERSION}.") - if (EIGEN3_FOUND) + add_executable(Subsampling_example_pick_n_random_points example_pick_n_random_points.cpp) + add_executable(Subsampling_example_choose_n_farthest_points example_choose_n_farthest_points.cpp) + add_executable(Subsampling_example_sparsify_point_set example_sparsify_point_set.cpp) + target_link_libraries(Subsampling_example_sparsify_point_set ${CGAL_LIBRARY}) - add_executable(Subsampling_example_pick_n_random_points example_pick_n_random_points.cpp) - add_executable(Subsampling_example_choose_n_farthest_points example_choose_n_farthest_points.cpp) - add_executable(Subsampling_example_sparsify_point_set example_sparsify_point_set.cpp) - target_link_libraries(Subsampling_example_sparsify_point_set ${CGAL_LIBRARY}) - else() - message(WARNING "Eigen3 not found. Version 3.1.0 is required for Subsampling feature.") + add_test(Subsampling_example_pick_n_random_points + ${CMAKE_CURRENT_BINARY_DIR}/Subsampling_example_pick_n_random_points) + add_test(Subsampling_example_choose_n_farthest_points + ${CMAKE_CURRENT_BINARY_DIR}/Subsampling_example_choose_n_farthest_points) + add_test(Subsampling_example_sparsify_point_set + ${CMAKE_CURRENT_BINARY_DIR}/Subsampling_example_sparsify_point_set) endif() - else() - message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile Subsampling examples. Version 4.8.1 is required.") endif () -else() - message(WARNING "CGAL not found. It is required for the Subsampling examples.") endif() diff --git a/src/Subsampling/example/example_sparsify_point_set.cpp b/src/Subsampling/example/example_sparsify_point_set.cpp index ccf83bc0..ad68b4c1 100644 --- a/src/Subsampling/example/example_sparsify_point_set.cpp +++ b/src/Subsampling/example/example_sparsify_point_set.cpp @@ -9,7 +9,6 @@ int main (void) { typedef CGAL::Epick_d > K; - typedef typename K::FT FT; typedef typename K::Point_d Point_d; CGAL::Random rd; diff --git a/src/Subsampling/test/CMakeLists.txt b/src/Subsampling/test/CMakeLists.txt index 91d4ed8f..3a2fb649 100644 --- a/src/Subsampling/test/CMakeLists.txt +++ b/src/Subsampling/test/CMakeLists.txt @@ -12,8 +12,6 @@ endif() if(CGAL_FOUND) if (NOT CGAL_VERSION VERSION_LESS 4.8.1) - message(STATUS "CGAL version: ${CGAL_VERSION}.") - if (EIGEN3_FOUND) add_executable( Subsampling_test_pick_n_random_points test_pick_n_random_points.cpp ) target_link_libraries(Subsampling_test_pick_n_random_points ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) @@ -23,12 +21,18 @@ if(CGAL_FOUND) add_executable(Subsampling_test_sparsify_point_set test_sparsify_point_set.cpp) target_link_libraries(Subsampling_test_sparsify_point_set ${CGAL_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) - else() - message(WARNING "Eigen3 not found. Version 3.1.0 is required for Subsampling feature.") + + add_test(Subsampling_test_pick_n_random_points ${CMAKE_CURRENT_BINARY_DIR}/Subsampling_test_pick_n_random_points + # XML format for Jenkins xUnit plugin + --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/Subsampling_test_pick_n_random_points_UT.xml --log_level=test_suite --report_level=no) + + add_test(Subsampling_test_choose_n_farthest_points ${CMAKE_CURRENT_BINARY_DIR}/Subsampling_test_choose_n_farthest_points + # XML format for Jenkins xUnit plugin + --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/Subsampling_test_choose_n_farthest_points_UT.xml --log_level=test_suite --report_level=no) + + add_test(Subsampling_test_sparsify_point_set ${CMAKE_CURRENT_BINARY_DIR}/Subsampling_test_sparsify_point_set + # XML format for Jenkins xUnit plugin + --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/Subsampling_test_sparsify_point_set_UT.xml --log_level=test_suite --report_level=no) endif() - else() - message(WARNING "CGAL version: ${CGAL_VERSION} is too old to compile Subsampling tests. Version 4.8.1 is required.") endif () -else() - message(WARNING "CGAL not found. It is required for the Subsampling tests.") endif() diff --git a/src/Subsampling/test/test_sparsify_point_set.cpp b/src/Subsampling/test/test_sparsify_point_set.cpp index 04a055ff..f993d6d6 100644 --- a/src/Subsampling/test/test_sparsify_point_set.cpp +++ b/src/Subsampling/test/test_sparsify_point_set.cpp @@ -35,7 +35,6 @@ BOOST_AUTO_TEST_CASE(test_sparsify_point_set) { typedef CGAL::Epick_d > K; - typedef typename K::FT FT; typedef typename K::Point_d Point_d; CGAL::Random rd; -- cgit v1.2.3 From ad4a82843c8268a9e9d12e607a13ee323831b597 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Oct 2016 15:13:10 +0000 Subject: Fix cpplint git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1660 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 8a8a944168adfddbf848c122fb9d9cf78b75d36c --- src/Subsampling/include/gudhi/pick_n_random_points.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Subsampling/include/gudhi/pick_n_random_points.h b/src/Subsampling/include/gudhi/pick_n_random_points.h index b8f4900a..52842a54 100644 --- a/src/Subsampling/include/gudhi/pick_n_random_points.h +++ b/src/Subsampling/include/gudhi/pick_n_random_points.h @@ -20,8 +20,10 @@ * along with this program. If not, see . */ -#ifndef PICK_RANDOM_POINTS_H_ -#define PICK_RANDOM_POINTS_H_ +#ifndef PICK_N_RANDOM_POINTS_H_ +#define PICK_N_RANDOM_POINTS_H_ + +#include #include @@ -30,7 +32,7 @@ #include // shuffle #include // iota #include -#include +#include namespace Gudhi { @@ -62,13 +64,13 @@ namespace subsampling { std::random_device rd; std::mt19937 g(rd()); - + std::shuffle(landmarks.begin(), landmarks.end(), g); landmarks.resize(final_size); for (int l: landmarks) *output_it++ = points[l]; - + #ifdef GUDHI_SUBS_PROFILING t.end(); std::cerr << "Random landmark choice took " << t.num_seconds() @@ -76,8 +78,8 @@ namespace subsampling { #endif } -} // namesapce subsampling - +} // namespace subsampling + } // namespace Gudhi -#endif // PICK_RANDOM_POINTS_H_ +#endif // PICK_N_RANDOM_POINTS_H_ -- cgit v1.2.3 From 3ed1e6ab9d5c122427e0a7308bd5b5a2d49d7557 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Oct 2016 15:23:28 +0000 Subject: Fix cpplint git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1661 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 880ca1a8686938b8ce5f0498848583fa258df4a0 --- src/Subsampling/include/gudhi/sparsify_point_set.h | 28 ++++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Subsampling/include/gudhi/sparsify_point_set.h b/src/Subsampling/include/gudhi/sparsify_point_set.h index 607555b4..edb9869b 100644 --- a/src/Subsampling/include/gudhi/sparsify_point_set.h +++ b/src/Subsampling/include/gudhi/sparsify_point_set.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef GUDHI_SPARSIFY_POINT_SET_H -#define GUDHI_SPARSIFY_POINT_SET_H +#ifndef SPARSIFY_POINT_SET_H_ +#define SPARSIFY_POINT_SET_H_ #include #ifdef GUDHI_SUBSAMPLING_PROFILING @@ -60,8 +60,7 @@ void sparsify_point_set( const Kernel &k, Point_range const& input_pts, typename Kernel::FT min_squared_dist, - OutputIterator output_it) -{ + OutputIterator output_it) { typedef typename Gudhi::spatial_searching::Kd_tree_search< Kernel, Point_range> Points_ds; @@ -80,8 +79,7 @@ sparsify_point_set( std::size_t pt_idx = 0; for (typename Point_range::const_iterator it_pt = input_pts.begin() ; it_pt != input_pts.end(); - ++it_pt, ++pt_idx) - { + ++it_pt, ++pt_idx) { if (dropped_points[pt_idx]) continue; @@ -90,19 +88,17 @@ sparsify_point_set( auto ins_range = points_ds.query_incremental_nearest_neighbors(*it_pt); // If another point Q is closer that min_squared_dist, mark Q to be dropped - for (auto const& neighbor : ins_range) - { + for (auto const& neighbor : ins_range) { std::size_t neighbor_point_idx = neighbor.first; // If the neighbor is too close, we drop the neighbor - if (neighbor.second < min_squared_dist) - { - // N.B.: If neighbor_point_idx < pt_idx, + if (neighbor.second < min_squared_dist) { + // N.B.: If neighbor_point_idx < pt_idx, // dropped_points[neighbor_point_idx] is already true but adding a // test doesn't make things faster, so why bother? dropped_points[neighbor_point_idx] = true; - } - else + } else { break; + } } } @@ -113,7 +109,7 @@ sparsify_point_set( #endif } -} // namespace subsampling -} // namespace Gudhi +} // namespace subsampling +} // namespace Gudhi -#endif // GUDHI_POINT_CLOUD_H +#endif // SPARSIFY_POINT_SET_H_ -- cgit v1.2.3 From 7e417a80188b8ed4051f73f26e9899f94c33dc1e Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Oct 2016 17:13:24 +0000 Subject: fix cpplint git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1663 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 78cab9749df2feaf6d47bf253d4449b043e026e7 --- .../example/example_choose_n_farthest_points.cpp | 14 +++++++------- src/Subsampling/example/example_pick_n_random_points.cpp | 14 +++++++------- src/Subsampling/example/example_sparsify_point_set.cpp | 14 +++++++------- src/Subsampling/test/test_choose_n_farthest_points.cpp | 9 ++++----- 4 files changed, 25 insertions(+), 26 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Subsampling/example/example_choose_n_farthest_points.cpp b/src/Subsampling/example/example_choose_n_farthest_points.cpp index 4bcb0eb9..533aba74 100644 --- a/src/Subsampling/example/example_choose_n_farthest_points.cpp +++ b/src/Subsampling/example/example_choose_n_farthest_points.cpp @@ -6,16 +6,16 @@ #include #include -int main (void) -{ - typedef CGAL::Epick_d > K; - typedef typename K::Point_d Point_d; - +int main(void) { + typedef CGAL::Epick_d > K; + typedef typename K::Point_d Point_d; + CGAL::Random rd; std::vector points; - for (int i = 0 ; i < 500 ; ++i) - points.push_back(Point_d(rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1))); + for (int i = 0; i < 500; ++i) + points.push_back(Point_d(rd.get_double(-1., 1), rd.get_double(-1., 1), + rd.get_double(-1., 1), rd.get_double(-1., 1))); K k; std::vector results; diff --git a/src/Subsampling/example/example_pick_n_random_points.cpp b/src/Subsampling/example/example_pick_n_random_points.cpp index 7b4379e4..1e38e405 100644 --- a/src/Subsampling/example/example_pick_n_random_points.cpp +++ b/src/Subsampling/example/example_pick_n_random_points.cpp @@ -6,16 +6,16 @@ #include #include -int main (void) -{ - typedef CGAL::Epick_d > K; - typedef typename K::Point_d Point_d; - +int main(void) { + typedef CGAL::Epick_d > K; + typedef typename K::Point_d Point_d; + CGAL::Random rd; std::vector points; - for (int i = 0 ; i < 500 ; ++i) - points.push_back(Point_d(rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1))); + for (int i = 0; i < 500; ++i) + points.push_back(Point_d(rd.get_double(-1., 1), rd.get_double(-1., 1), + rd.get_double(-1., 1), rd.get_double(-1., 1))); K k; std::vector results; diff --git a/src/Subsampling/example/example_sparsify_point_set.cpp b/src/Subsampling/example/example_sparsify_point_set.cpp index ad68b4c1..b35a18d9 100644 --- a/src/Subsampling/example/example_sparsify_point_set.cpp +++ b/src/Subsampling/example/example_sparsify_point_set.cpp @@ -6,16 +6,16 @@ #include #include -int main (void) -{ - typedef CGAL::Epick_d > K; - typedef typename K::Point_d Point_d; - +int main(void) { + typedef CGAL::Epick_d > K; + typedef typename K::Point_d Point_d; + CGAL::Random rd; std::vector points; - for (int i = 0 ; i < 500 ; ++i) - points.push_back(Point_d(rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1),rd.get_double(-1.,1))); + for (int i = 0; i < 500; ++i) + points.push_back(Point_d(rd.get_double(-1., 1), rd.get_double(-1., 1), + rd.get_double(-1., 1), rd.get_double(-1., 1))); K k; std::vector results; diff --git a/src/Subsampling/test/test_choose_n_farthest_points.cpp b/src/Subsampling/test/test_choose_n_farthest_points.cpp index f79a4dfb..d064899a 100644 --- a/src/Subsampling/test/test_choose_n_farthest_points.cpp +++ b/src/Subsampling/test/test_choose_n_farthest_points.cpp @@ -35,10 +35,9 @@ #include -typedef CGAL::Epick_d K; -typedef typename K::FT FT; -typedef typename K::Point_d Point_d; - +typedef CGAL::Epick_d K; +typedef typename K::FT FT; +typedef typename K::Point_d Point_d; BOOST_AUTO_TEST_CASE(test_choose_farthest_point) { std::vector< Point_d > points, landmarks; @@ -52,6 +51,6 @@ BOOST_AUTO_TEST_CASE(test_choose_farthest_point) { landmarks.clear(); K k; Gudhi::subsampling::choose_n_farthest_points(k, points, 100, std::back_inserter(landmarks)); - + BOOST_CHECK(landmarks.size() == 100); } -- cgit v1.2.3 From 5592d57180bee4cdedbe2e99ffd873184e889559 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Oct 2016 17:19:44 +0000 Subject: fixcpplint git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1667 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: c6974fc881cae681326777d1e6f8bd7f475f235e --- .../include/gudhi/choose_n_farthest_points.h | 153 ++++++++++----------- .../include/gudhi/pick_n_random_points.h | 53 ++++--- src/Subsampling/include/gudhi/sparsify_point_set.h | 18 +-- 3 files changed, 111 insertions(+), 113 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index a4719f56..60816a29 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -37,89 +37,88 @@ #include // for sort #include #include +#include // for numeric_limits<> namespace Gudhi { namespace subsampling { - /** - * \ingroup subsampling - * \brief Subsample by a greedy strategy of iteratively adding the farthest point from the - * current chosen point set to the subsampling. - * The iteration starts with the landmark `starting point`. - * \details It chooses `final_size` points from a random access range `input_pts` and - * outputs it in the output iterator `output_it`. - * - */ - - template < typename Kernel, - typename Point_container, - typename OutputIterator> - void choose_n_farthest_points( Kernel const &k, - Point_container const &input_pts, - std::size_t final_size, - std::size_t starting_point, - OutputIterator output_it) - { - typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object(); - - std::size_t nb_points = boost::size(input_pts); - assert(nb_points >= final_size); - - std::size_t current_number_of_landmarks = 0; // counter for landmarks - double curr_max_dist = 0; // used for defining the furhest point from L - const double infty = std::numeric_limits::infinity(); // infinity (see next entry) - std::vector< double > dist_to_L(nb_points, infty); // vector of current distances to L from input_pts - - std::size_t curr_max_w = starting_point; - - for (current_number_of_landmarks = 0; current_number_of_landmarks != final_size; current_number_of_landmarks++) { - // curr_max_w at this point is the next landmark - *output_it++ = input_pts[curr_max_w]; - // std::cout << curr_max_w << "\n"; - std::size_t i = 0; - for (auto& p : input_pts) { - double curr_dist = sqdist(p, *(std::begin(input_pts) + curr_max_w)); - if (curr_dist < dist_to_L[i]) - dist_to_L[i] = curr_dist; - ++i; - } - // choose the next curr_max_w - curr_max_dist = 0; - for (i = 0; i < dist_to_L.size(); i++) - if (dist_to_L[i] > curr_max_dist) { - curr_max_dist = dist_to_L[i]; - curr_max_w = i; - } + +/** + * \ingroup subsampling + * \brief Subsample by a greedy strategy of iteratively adding the farthest point from the + * current chosen point set to the subsampling. + * The iteration starts with the landmark `starting point`. + * \details It chooses `final_size` points from a random access range `input_pts` and + * outputs it in the output iterator `output_it`. + * + */ +template < typename Kernel, +typename Point_container, +typename OutputIterator> +void choose_n_farthest_points(Kernel const &k, + Point_container const &input_pts, + std::size_t final_size, + std::size_t starting_point, + OutputIterator output_it) { + typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object(); + + std::size_t nb_points = boost::size(input_pts); + assert(nb_points >= final_size); + + std::size_t current_number_of_landmarks = 0; // counter for landmarks + double curr_max_dist = 0; // used for defining the furhest point from L + const double infty = std::numeric_limits::infinity(); // infinity (see next entry) + std::vector< double > dist_to_L(nb_points, infty); // vector of current distances to L from input_pts + + std::size_t curr_max_w = starting_point; + + for (current_number_of_landmarks = 0; current_number_of_landmarks != final_size; current_number_of_landmarks++) { + // curr_max_w at this point is the next landmark + *output_it++ = input_pts[curr_max_w]; + // std::cout << curr_max_w << "\n"; + std::size_t i = 0; + for (auto& p : input_pts) { + double curr_dist = sqdist(p, *(std::begin(input_pts) + curr_max_w)); + if (curr_dist < dist_to_L[i]) + dist_to_L[i] = curr_dist; + ++i; } + // choose the next curr_max_w + curr_max_dist = 0; + for (i = 0; i < dist_to_L.size(); i++) + if (dist_to_L[i] > curr_max_dist) { + curr_max_dist = dist_to_L[i]; + curr_max_w = i; + } } - - /** - * \ingroup subsampling - * \brief Subsample by a greedy strategy of iteratively adding the farthest point from the - * current chosen point set to the subsampling. - * The iteration starts with a random landmark. - * \details It chooses `final_size` points from a random access range `input_pts` and - * outputs it in the output iterator `output_it`. - * - */ - template < typename Kernel, - typename Point_container, - typename OutputIterator> - void choose_n_farthest_points( Kernel const& k, - Point_container const &input_pts, - unsigned final_size, - OutputIterator output_it) - { - // Choose randomly the first landmark - std::random_device rd; - std::mt19937 gen(rd()); - std::uniform_int_distribution<> dis(1, 6); - int starting_point = dis(gen); - choose_n_farthest_points(k, input_pts, final_size, starting_point, output_it); - } - -} // namespace subsampling - +} + +/** + * \ingroup subsampling + * \brief Subsample by a greedy strategy of iteratively adding the farthest point from the + * current chosen point set to the subsampling. + * The iteration starts with a random landmark. + * \details It chooses `final_size` points from a random access range `input_pts` and + * outputs it in the output iterator `output_it`. + * + */ +template < typename Kernel, +typename Point_container, +typename OutputIterator> +void choose_n_farthest_points(Kernel const& k, + Point_container const &input_pts, + unsigned final_size, + OutputIterator output_it) { + // Choose randomly the first landmark + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> dis(1, 6); + int starting_point = dis(gen); + choose_n_farthest_points(k, input_pts, final_size, starting_point, output_it); +} + +} // namespace subsampling + } // namespace Gudhi #endif // CHOOSE_N_FARTHEST_POINTS_H_ diff --git a/src/Subsampling/include/gudhi/pick_n_random_points.h b/src/Subsampling/include/gudhi/pick_n_random_points.h index 52842a54..e89b2b2d 100644 --- a/src/Subsampling/include/gudhi/pick_n_random_points.h +++ b/src/Subsampling/include/gudhi/pick_n_random_points.h @@ -38,45 +38,44 @@ namespace Gudhi { namespace subsampling { - - /** - * \ingroup subsampling - * \brief Subsample a point set by picking random vertices. - * - * \details It chooses `final_size` distinct points from a random access range `points` - * and outputs them to the output iterator `output_it`. - * Point_container::iterator should be ValueSwappable and RandomAccessIterator. - */ - - template - void pick_n_random_points(Point_container const &points, + +/** + * \ingroup subsampling + * \brief Subsample a point set by picking random vertices. + * + * \details It chooses `final_size` distinct points from a random access range `points` + * and outputs them to the output iterator `output_it`. + * Point_container::iterator should be ValueSwappable and RandomAccessIterator. + */ +template +void pick_n_random_points(Point_container const &points, std::size_t final_size, OutputIterator output_it) { #ifdef GUDHI_SUBS_PROFILING - Gudhi::Clock t; + Gudhi::Clock t; #endif - std::size_t nbP = boost::size(points); - assert(nbP >= final_size); - std::vector landmarks(nbP); - std::iota(landmarks.begin(), landmarks.end(), 0); + std::size_t nbP = boost::size(points); + assert(nbP >= final_size); + std::vector landmarks(nbP); + std::iota(landmarks.begin(), landmarks.end(), 0); - std::random_device rd; - std::mt19937 g(rd()); + std::random_device rd; + std::mt19937 g(rd()); - std::shuffle(landmarks.begin(), landmarks.end(), g); - landmarks.resize(final_size); + std::shuffle(landmarks.begin(), landmarks.end(), g); + landmarks.resize(final_size); - for (int l: landmarks) - *output_it++ = points[l]; + for (int l : landmarks) + *output_it++ = points[l]; #ifdef GUDHI_SUBS_PROFILING - t.end(); - std::cerr << "Random landmark choice took " << t.num_seconds() + t.end(); + std::cerr << "Random landmark choice took " << t.num_seconds() << " seconds." << std::endl; #endif - } +} } // namespace subsampling diff --git a/src/Subsampling/include/gudhi/sparsify_point_set.h b/src/Subsampling/include/gudhi/sparsify_point_set.h index edb9869b..7ff11b4c 100644 --- a/src/Subsampling/include/gudhi/sparsify_point_set.h +++ b/src/Subsampling/include/gudhi/sparsify_point_set.h @@ -32,6 +32,7 @@ #include namespace Gudhi { + namespace subsampling { /** @@ -54,15 +55,14 @@ namespace subsampling { * @param[in] min_squared_dist Minimum squared distance separating the output points. * @param[out] output_it The output iterator. */ - template void sparsify_point_set( - const Kernel &k, Point_range const& input_pts, - typename Kernel::FT min_squared_dist, - OutputIterator output_it) { + const Kernel &k, Point_range const& input_pts, + typename Kernel::FT min_squared_dist, + OutputIterator output_it) { typedef typename Gudhi::spatial_searching::Kd_tree_search< - Kernel, Point_range> Points_ds; + Kernel, Point_range> Points_ds; typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object(); @@ -77,9 +77,9 @@ sparsify_point_set( // Parse the input points, and add them if they are not too close to // the other points std::size_t pt_idx = 0; - for (typename Point_range::const_iterator it_pt = input_pts.begin() ; - it_pt != input_pts.end(); - ++it_pt, ++pt_idx) { + for (typename Point_range::const_iterator it_pt = input_pts.begin(); + it_pt != input_pts.end(); + ++it_pt, ++pt_idx) { if (dropped_points[pt_idx]) continue; @@ -105,7 +105,7 @@ sparsify_point_set( #ifdef GUDHI_SUBSAMPLING_PROFILING t.end(); std::cerr << "Point set sparsified in " << t.num_seconds() - << " seconds." << std::endl; + << " seconds." << std::endl; #endif } -- cgit v1.2.3 From 6af3c873fadc3eae10aa964dd0105ef095201911 Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 6 Oct 2016 17:40:50 +0000 Subject: cpplint fixes git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1668 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: b24e2b03fc9a8898f5c3d6bf1cf36a2e60442673 --- src/Spatial_searching/include/gudhi/Kd_tree_search.h | 4 ++-- src/Subsampling/include/gudhi/choose_n_farthest_points.h | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/Subsampling') diff --git a/src/Spatial_searching/include/gudhi/Kd_tree_search.h b/src/Spatial_searching/include/gudhi/Kd_tree_search.h index ab266161..6728d56e 100644 --- a/src/Spatial_searching/include/gudhi/Kd_tree_search.h +++ b/src/Spatial_searching/include/gudhi/Kd_tree_search.h @@ -235,7 +235,7 @@ class Kd_tree_search { /// \brief Search incrementally for the farthest neighbors from a query point. /// @param[in] p The query point. /// @param[in] eps Approximation factor. - /// @return A range containing the neighbors sorted by their distance to p. + /// @return A range containing the neighbors sorted by their distance to p. /// All the neighbors are not computed by this function, but they will be /// computed incrementally when the iterator on the range is incremented. INS_range query_incremental_farthest_neighbors(const Point &p, FT eps = FT(0)) const { @@ -261,4 +261,4 @@ class Kd_tree_search { } // namespace spatial_searching } // namespace Gudhi -#endif // KD_TREE_SEARCH_H_ +#endif // KD_TREE_SEARCH_H_ diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index 60816a29..40c7808d 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -66,7 +66,6 @@ void choose_n_farthest_points(Kernel const &k, assert(nb_points >= final_size); std::size_t current_number_of_landmarks = 0; // counter for landmarks - double curr_max_dist = 0; // used for defining the furhest point from L const double infty = std::numeric_limits::infinity(); // infinity (see next entry) std::vector< double > dist_to_L(nb_points, infty); // vector of current distances to L from input_pts @@ -75,7 +74,6 @@ void choose_n_farthest_points(Kernel const &k, for (current_number_of_landmarks = 0; current_number_of_landmarks != final_size; current_number_of_landmarks++) { // curr_max_w at this point is the next landmark *output_it++ = input_pts[curr_max_w]; - // std::cout << curr_max_w << "\n"; std::size_t i = 0; for (auto& p : input_pts) { double curr_dist = sqdist(p, *(std::begin(input_pts) + curr_max_w)); @@ -84,7 +82,7 @@ void choose_n_farthest_points(Kernel const &k, ++i; } // choose the next curr_max_w - curr_max_dist = 0; + double curr_max_dist = 0; // used for defining the furhest point from L for (i = 0; i < dist_to_L.size(); i++) if (dist_to_L[i] > curr_max_dist) { curr_max_dist = dist_to_L[i]; @@ -109,7 +107,7 @@ void choose_n_farthest_points(Kernel const& k, Point_container const &input_pts, unsigned final_size, OutputIterator output_it) { - // Choose randomly the first landmark + // Choose randomly the first landmark std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> dis(1, 6); -- cgit v1.2.3