From 96b7e2ec76b94aa8d609c816f3adab63f0b6caa9 Mon Sep 17 00:00:00 2001 From: skachano Date: Fri, 24 Jun 2016 14:08:26 +0000 Subject: Removed headers in the examples git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1339 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 835003033dc15ce8fd2d8efdc7bfdf3e0be7760d --- .../include/gudhi/choose_by_farthest_point.h | 102 ++++----------------- 1 file changed, 16 insertions(+), 86 deletions(-) (limited to 'src/Subsampling/include') diff --git a/src/Subsampling/include/gudhi/choose_by_farthest_point.h b/src/Subsampling/include/gudhi/choose_by_farthest_point.h index d1db0d1a..8dea19be 100644 --- a/src/Subsampling/include/gudhi/choose_by_farthest_point.h +++ b/src/Subsampling/include/gudhi/choose_by_farthest_point.h @@ -45,6 +45,7 @@ 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 `points` and * outputs it in the output iterator `output_it`. * @@ -53,11 +54,11 @@ namespace subsampling { template < typename Kernel, typename Point_container, typename OutputIterator> - void choose_by_farthest_point_old( Kernel& k, - Point_container const &points, - int final_size, - int starting_point, - OutputIterator output_it) + void choose_by_farthest_point( Kernel& k, + Point_container const &points, + int final_size, + int starting_point, + OutputIterator output_it) { typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object(); @@ -92,101 +93,30 @@ namespace subsampling { } } - template < typename Kernel, - typename Point_container, - typename OutputIterator> - void choose_by_farthest_point_old( Kernel& k, - Point_container const &points, - int 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_by_farthest_point_old(k, points, final_size, starting_point, output_it); - } - + /** + * \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 `points` and + * outputs it in the output iterator `output_it`. + * + */ template < typename Kernel, typename Point_container, typename OutputIterator> void choose_by_farthest_point( Kernel& k, Point_container const &points, int final_size, - int starting_point, OutputIterator output_it) { - // typedef typename Kernel::Point_d Point_d; - // typedef typename Kernel::FT FT; - // typedef CGAL::Search_traits< - // FT, Point_d, - // typename Kernel::Cartesian_const_iterator_d, - // typename Kernel::Construct_cartesian_const_iterator_d> Traits_base; - - // typedef CGAL::Search_traits_adapter< std::ptrdiff_t, Point_d*, Traits_base > STraits; - // typedef CGAL::Fuzzy_sphere< STraits > Fuzzy_sphere; - - typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object(); - - int nb_points = boost::size(points); - assert(nb_points >= final_size); - - Clock t; - Gudhi::spatial_searching::Spatial_tree_data_structure< Kernel, Point_container> tree(points); - t.end(); - //std::cout << "Constructed the Kd tree: " << t.num_seconds() << " s." << std::endl; - - //CGAL::Fuzzy_sphere< CGAL::Search_trai> - - int current_number_of_landmarks = 0; // counter for landmarks - const double infty = std::numeric_limits::infinity(); // infinity (see next entry) - double curr_max_dist = infty; // used for defining the furhest point from L - std::vector< double > dist_to_L(nb_points, infty); // vector of current distances to L from points - - // Choose randomly the first landmark - int 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++ = points[curr_max_w]; - // std::cout << curr_max_w << "\n"; - //for (auto& p : points) { - auto search = tree.query_incremental_ANN(points[curr_max_w]); - auto search_it = search.begin(); - while (search_it != search.end() && search_it->second <= curr_max_dist ) { - //std::cout << search_it->second << " " << curr_max_dist << "\n"; - if (dist_to_L[search_it->first] > search_it->second) - dist_to_L[search_it->first] = search_it->second; - search_it++; - } - // choose the next curr_max_w - curr_max_dist = 0; - for (unsigned 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; - } - } - } - - template < typename Kernel, - typename Point_container, - typename OutputIterator> - void choose_by_farthest_point( Kernel& k, - Point_container const &points, - int 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_by_farthest_point_old(k, points, final_size, starting_point, output_it); + choose_by_farthest_point(k, points, final_size, starting_point, output_it); } - } // namespace subsampling -- cgit v1.2.3