diff options
author | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-12-06 08:37:33 +0000 |
---|---|---|
committer | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-12-06 08:37:33 +0000 |
commit | 4e5416f5d030a57c1aad3303dd19c9aba56013fd (patch) | |
tree | 541d683facff03e0c4f7b1a9f508674e2d9095ba | |
parent | 2ef24de87b91f0e71177b3190affb0263f09379b (diff) | |
parent | 5ab0326c35a5f379f528d30f34ed37db1b62ffcc (diff) |
merged trunk to the branch
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/relaxed-witness@1822 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: c909312a3141cea6bbfaab670be873f7e1c4957a
6 files changed, 90 insertions, 30 deletions
diff --git a/data/points/COIL_database/README b/data/points/COIL_database/README index 70e013d7..32d059cf 100644 --- a/data/points/COIL_database/README +++ b/data/points/COIL_database/README @@ -1,5 +1,7 @@ The datasets in this folder come from the Columbia University Image Library (COIL-100) dataset. +Ambient dimension is 16384 (128*128) + References: http://www.cs.columbia.edu/CAVE/software/softlib/coil-100.php diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h index 40c7808d..9b45c640 100644 --- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h +++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h @@ -60,10 +60,15 @@ void choose_n_farthest_points(Kernel const &k, 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); + if (final_size > nb_points) + final_size = nb_points; + + // Tests to the limit + if (final_size < 1) + return; + + typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object(); std::size_t current_number_of_landmarks = 0; // counter for landmarks const double infty = std::numeric_limits<double>::infinity(); // infinity (see next entry) @@ -107,11 +112,16 @@ void choose_n_farthest_points(Kernel const& k, Point_container const &input_pts, unsigned final_size, OutputIterator output_it) { + // Tests to the limit + if ((final_size < 1) || (input_pts.size() == 0)) + return; + // 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); + std::uniform_int_distribution<> dis(0, (input_pts.size() - 1)); + std::size_t starting_point = dis(gen); + choose_n_farthest_points(k, input_pts, final_size, starting_point, output_it); } diff --git a/src/Subsampling/test/test_choose_n_farthest_points.cpp b/src/Subsampling/test/test_choose_n_farthest_points.cpp index d064899a..0bc0dff4 100644 --- a/src/Subsampling/test/test_choose_n_farthest_points.cpp +++ b/src/Subsampling/test/test_choose_n_farthest_points.cpp @@ -39,18 +39,65 @@ typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K; typedef typename K::FT FT; typedef typename K::Point_d Point_d; -BOOST_AUTO_TEST_CASE(test_choose_farthest_point) { +typedef boost::mpl::list<CGAL::Epick_d<CGAL::Dynamic_dimension_tag>, CGAL::Epick_d<CGAL::Dimension_tag<4>>> list_of_tested_kernels; + +BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point, Kernel, list_of_tested_kernels) { + typedef typename Kernel::FT FT; + typedef typename Kernel::Point_d Point_d; std::vector< Point_d > points, landmarks; // Add grid points (625 points) for (FT i = 0; i < 5; i += 1.0) for (FT j = 0; j < 5; j += 1.0) for (FT k = 0; k < 5; k += 1.0) - for (FT l = 0; l < 5; l += 1.0) - points.push_back(Point_d(std::vector<FT>({i, j, k, l}))); + for (FT l = 0; l < 5; l += 1.0) { + std::vector<FT> point({i, j, k, l}); + points.push_back(Point_d(point.begin(), point.end())); + } landmarks.clear(); - K k; + Kernel k; Gudhi::subsampling::choose_n_farthest_points(k, points, 100, std::back_inserter(landmarks)); BOOST_CHECK(landmarks.size() == 100); + for (auto landmark : landmarks) + { + // Check all landmarks are in points + BOOST_CHECK(std::find (points.begin(), points.end(), landmark) != points.end()); + } +} + +BOOST_AUTO_TEST_CASE_TEMPLATE(test_choose_farthest_point_limits, Kernel, list_of_tested_kernels) { + typedef typename Kernel::FT FT; + typedef typename Kernel::Point_d Point_d; + std::vector< Point_d > points, landmarks; + landmarks.clear(); + Kernel k; + // Choose -1 farthest points in an empty point cloud + Gudhi::subsampling::choose_n_farthest_points(k, points, -1, std::back_inserter(landmarks)); + BOOST_CHECK(landmarks.size() == 0); + landmarks.clear(); + // Choose 0 farthest points in an empty point cloud + Gudhi::subsampling::choose_n_farthest_points(k, points, 0, std::back_inserter(landmarks)); + BOOST_CHECK(landmarks.size() == 0); + landmarks.clear(); + // Choose 1 farthest points in an empty point cloud + Gudhi::subsampling::choose_n_farthest_points(k, points, 1, std::back_inserter(landmarks)); + BOOST_CHECK(landmarks.size() == 0); + landmarks.clear(); + + std::vector<FT> point({0.0, 0.0, 0.0, 0.0}); + points.push_back(Point_d(point.begin(), point.end())); + // Choose -1 farthest points in an empty point cloud + Gudhi::subsampling::choose_n_farthest_points(k, points, -1, std::back_inserter(landmarks)); + BOOST_CHECK(landmarks.size() == 1); + landmarks.clear(); + // Choose 0 farthest points in a one point cloud + Gudhi::subsampling::choose_n_farthest_points(k, points, 0, std::back_inserter(landmarks)); + BOOST_CHECK(landmarks.size() == 0); + landmarks.clear(); + // Choose 1 farthest points in a one point cloud + Gudhi::subsampling::choose_n_farthest_points(k, points, 1, std::back_inserter(landmarks)); + BOOST_CHECK(landmarks.size() == 1); + landmarks.clear(); + } diff --git a/src/Tangential_complex/benchmark/CMakeLists.txt b/src/Tangential_complex/benchmark/CMakeLists.txt index a217d6e6..56dd8128 100644 --- a/src/Tangential_complex/benchmark/CMakeLists.txt +++ b/src/Tangential_complex/benchmark/CMakeLists.txt @@ -16,7 +16,7 @@ if(CGAL_FOUND) if (EIGEN3_FOUND) add_executable(Tangential_complex_benchmark benchmark_tc.cpp) target_link_libraries(Tangential_complex_benchmark - ${Boost_DATE_TIME_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) + ${Boost_DATE_TIME_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY}) if (TBB_FOUND) target_link_libraries(Tangential_complex_benchmark ${TBB_LIBRARIES}) endif(TBB_FOUND) diff --git a/src/Tangential_complex/include/gudhi/Tangential_complex.h b/src/Tangential_complex/include/gudhi/Tangential_complex.h index 7cf5c498..e748d3b7 100644 --- a/src/Tangential_complex/include/gudhi/Tangential_complex.h +++ b/src/Tangential_complex/include/gudhi/Tangential_complex.h @@ -121,11 +121,12 @@ class Vertex_data { * \tparam Triangulation_ is the type used for storing the local regular triangulations. We highly recommend to use the default value (`CGAL::Regular_triangulation`). * */ -template < -typename Kernel_, // ambiant kernel -typename DimensionTag, // intrinsic dimension -typename Concurrency_tag = CGAL::Parallel_tag, -typename Triangulation_ = CGAL::Default +template +< + typename Kernel_, // ambiant kernel + typename DimensionTag, // intrinsic dimension + typename Concurrency_tag = CGAL::Parallel_tag, + typename Triangulation_ = CGAL::Default > class Tangential_complex { typedef Kernel_ K; @@ -136,19 +137,20 @@ class Tangential_complex { typedef typename CGAL::Default::Get < - Triangulation_, - CGAL::Regular_triangulation - < - CGAL::Epick_d<DimensionTag>, - CGAL::Triangulation_data_structure - < - typename CGAL::Epick_d<DimensionTag>::Dimension, - CGAL::Triangulation_vertex<CGAL::Regular_triangulation_traits_adapter< - CGAL::Epick_d<DimensionTag> >, Vertex_data >, - CGAL::Triangulation_full_cell<CGAL::Regular_triangulation_traits_adapter< - CGAL::Epick_d<DimensionTag> > > - > - > + Triangulation_, + CGAL::Regular_triangulation + < + CGAL::Epick_d<DimensionTag>, + CGAL::Triangulation_data_structure + < + typename CGAL::Epick_d<DimensionTag>::Dimension, + CGAL::Triangulation_vertex + < + CGAL::Regular_triangulation_traits_adapter< CGAL::Epick_d<DimensionTag> >, Vertex_data + >, + CGAL::Triangulation_full_cell<CGAL::Regular_triangulation_traits_adapter< CGAL::Epick_d<DimensionTag> > > + > + > >::type Triangulation; typedef typename Triangulation::Geom_traits Tr_traits; typedef typename Triangulation::Weighted_point Tr_point; diff --git a/src/Tangential_complex/include/gudhi/Tangential_complex/config.h b/src/Tangential_complex/include/gudhi/Tangential_complex/config.h index 98a1b14f..ffefcd6b 100644 --- a/src/Tangential_complex/include/gudhi/Tangential_complex/config.h +++ b/src/Tangential_complex/include/gudhi/Tangential_complex/config.h @@ -26,8 +26,7 @@ #include <cstddef> // ========================= Debugging & profiling ============================= -#define GUDHI_TC_PROFILING -#define DEBUG_TRACES +// #define GUDHI_TC_PROFILING // #define GUDHI_TC_VERY_VERBOSE // #define GUDHI_TC_PERFORM_EXTRA_CHECKS // #define GUDHI_TC_SHOW_DETAILED_STATS_FOR_INCONSISTENCIES |