summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Spatial_searching/example/CMakeLists.txt2
-rw-r--r--src/Spatial_searching/test/CMakeLists.txt2
-rw-r--r--src/Subsampling/include/gudhi/choose_n_farthest_points.h20
-rw-r--r--src/Subsampling/test/test_choose_n_farthest_points.cpp55
4 files changed, 11 insertions, 68 deletions
diff --git a/src/Spatial_searching/example/CMakeLists.txt b/src/Spatial_searching/example/CMakeLists.txt
index e73b201c..6238a0ec 100644
--- a/src/Spatial_searching/example/CMakeLists.txt
+++ b/src/Spatial_searching/example/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6)
project(Spatial_searching_examples)
if(CGAL_FOUND)
- if (NOT CGAL_VERSION VERSION_LESS 4.9.0)
+ if (NOT CGAL_VERSION VERSION_LESS 4.8.1)
if (EIGEN3_FOUND)
add_executable( Spatial_searching_example_spatial_searching example_spatial_searching.cpp )
target_link_libraries(Spatial_searching_example_spatial_searching ${CGAL_LIBRARY})
diff --git a/src/Spatial_searching/test/CMakeLists.txt b/src/Spatial_searching/test/CMakeLists.txt
index 7f443b79..2c685c72 100644
--- a/src/Spatial_searching/test/CMakeLists.txt
+++ b/src/Spatial_searching/test/CMakeLists.txt
@@ -11,7 +11,7 @@ if (GPROF_PATH)
endif()
if(CGAL_FOUND)
- if (NOT CGAL_VERSION VERSION_LESS 4.9.0)
+ if (NOT CGAL_VERSION VERSION_LESS 4.8.1)
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
diff --git a/src/Subsampling/include/gudhi/choose_n_farthest_points.h b/src/Subsampling/include/gudhi/choose_n_farthest_points.h
index 9b45c640..40c7808d 100644
--- a/src/Subsampling/include/gudhi/choose_n_farthest_points.h
+++ b/src/Subsampling/include/gudhi/choose_n_farthest_points.h
@@ -60,16 +60,11 @@ void choose_n_farthest_points(Kernel const &k,
std::size_t final_size,
std::size_t starting_point,
OutputIterator output_it) {
- std::size_t nb_points = boost::size(input_pts);
- 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 nb_points = boost::size(input_pts);
+ assert(nb_points >= final_size);
+
std::size_t current_number_of_landmarks = 0; // counter for landmarks
const double infty = std::numeric_limits<double>::infinity(); // infinity (see next entry)
std::vector< double > dist_to_L(nb_points, infty); // vector of current distances to L from input_pts
@@ -112,16 +107,11 @@ 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(0, (input_pts.size() - 1));
- std::size_t starting_point = dis(gen);
-
+ 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);
}
diff --git a/src/Subsampling/test/test_choose_n_farthest_points.cpp b/src/Subsampling/test/test_choose_n_farthest_points.cpp
index 0bc0dff4..d064899a 100644
--- a/src/Subsampling/test/test_choose_n_farthest_points.cpp
+++ b/src/Subsampling/test/test_choose_n_farthest_points.cpp
@@ -39,65 +39,18 @@ typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
typedef typename K::FT FT;
typedef typename K::Point_d Point_d;
-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;
+BOOST_AUTO_TEST_CASE(test_choose_farthest_point) {
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) {
- std::vector<FT> point({i, j, k, l});
- points.push_back(Point_d(point.begin(), point.end()));
- }
+ for (FT l = 0; l < 5; l += 1.0)
+ points.push_back(Point_d(std::vector<FT>({i, j, k, l})));
landmarks.clear();
- Kernel k;
+ K 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();
-
}