diff options
author | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-06-22 09:42:57 +0000 |
---|---|---|
committer | skachano <skachano@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-06-22 09:42:57 +0000 |
commit | 83dd60a38920cdf85e4c1108404cfa7c294f98e2 (patch) | |
tree | f838d233a7039e85251f22ab0788af313b2bae47 /src/Subsampling/include | |
parent | 4ef423a7a1140f1fe1a2ce1f1bbee03990638be1 (diff) |
Took into account Clément's remarks
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/subsampling_and_spatialsearching@1328 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 6f1db13d0e8cec8e64c5bb30da53b72b00446de3
Diffstat (limited to 'src/Subsampling/include')
-rw-r--r-- | src/Subsampling/include/gudhi/choose_by_farthest_point.h | 31 | ||||
-rw-r--r-- | src/Subsampling/include/gudhi/pick_random_points.h (renamed from src/Subsampling/include/gudhi/Pick_random_points.h) | 22 |
2 files changed, 28 insertions, 25 deletions
diff --git a/src/Subsampling/include/gudhi/choose_by_farthest_point.h b/src/Subsampling/include/gudhi/choose_by_farthest_point.h index 2918983f..52647c16 100644 --- a/src/Subsampling/include/gudhi/choose_by_farthest_point.h +++ b/src/Subsampling/include/gudhi/choose_by_farthest_point.h @@ -31,32 +31,29 @@ #include <random> namespace Gudhi { - + +namespace subsampling { /** - * \ingroup witness_complex - * \brief Landmark choice strategy by iteratively adding the farthest witness from the - * current landmark set as the new landmark. - * \details It chooses nbL landmarks from a random access range `points` and - * writes {witness}*{closest landmarks} matrix in `knn`. - * - * The type KNearestNeighbors can be seen as - * Witness_range<Closest_landmark_range<Vertex_handle>>, where - * Witness_range and Closest_landmark_range are random access ranges + * \ingroup subsampling + * \brief Subsample by a greedy strategy of iteratively adding the farthest point from the + * current chosen point set to the subsampling. + * \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 nbL, - OutputIterator output_it) + void choose_by_farthest_point( Kernel& k, + Point_container const &points, + int final_size, + OutputIterator output_it) { typename Kernel::Squared_distance_d sqdist = k.squared_distance_d_object(); int nb_points = boost::size(points); - assert(nb_points >= nbL); + assert(nb_points >= final_size); int current_number_of_landmarks = 0; // counter for landmarks double curr_max_dist = 0; // used for defining the furhest point from L @@ -69,7 +66,7 @@ namespace Gudhi { std::uniform_int_distribution<> dis(1, 6); int curr_max_w = dis(gen); - for (current_number_of_landmarks = 0; current_number_of_landmarks != nbL; current_number_of_landmarks++) { + 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"; @@ -89,6 +86,8 @@ namespace Gudhi { } } } + +} // namespace subsampling } // namespace Gudhi diff --git a/src/Subsampling/include/gudhi/Pick_random_points.h b/src/Subsampling/include/gudhi/pick_random_points.h index 98902264..732ae3f7 100644 --- a/src/Subsampling/include/gudhi/Pick_random_points.h +++ b/src/Subsampling/include/gudhi/pick_random_points.h @@ -34,26 +34,28 @@ namespace Gudhi { +namespace subsampling { + /** - * \ingroup witness_complex - * \brief Landmark choice strategy by taking random vertices for landmarks. + * \ingroup subsampling + * \brief Subsample a point set by picking random vertices. * - * \details It chooses nbL distinct landmarks from a random access range `points` - * and outputs them to an output iterator. + * \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 <typename Point_container, typename OutputIterator> void pick_random_points(Point_container const &points, - unsigned nbL, + unsigned final_size, OutputIterator output_it) { -#ifdef GUDHI_LM_PROFILING +#ifdef GUDHI_SUBS_PROFILING Gudhi::Clock t; #endif unsigned nbP = boost::size(points); - assert(nbP >= nbL); + assert(nbP >= final_size); std::vector<int> landmarks(nbP); std::iota(landmarks.begin(), landmarks.end(), 0); @@ -61,18 +63,20 @@ namespace Gudhi { std::mt19937 g(rd()); std::shuffle(landmarks.begin(), landmarks.end(), g); - landmarks.resize(nbL); + landmarks.resize(final_size); for (int l: landmarks) *output_it++ = points[l]; -#ifdef GUDHI_LM_PROFILING +#ifdef GUDHI_SUBS_PROFILING t.end(); std::cerr << "Random landmark choice took " << t.num_seconds() << " seconds." << std::endl; #endif } +} // namesapce subsampling + } // namespace Gudhi #endif // PICK_RANDOM_POINTS_H_ |