diff options
author | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-10-06 17:19:44 +0000 |
---|---|---|
committer | vrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2016-10-06 17:19:44 +0000 |
commit | 5592d57180bee4cdedbe2e99ffd873184e889559 (patch) | |
tree | a6d2acbd2fd7fd58edaffd75b6f742ba54250ba9 /src/Subsampling/include/gudhi/pick_n_random_points.h | |
parent | 7e417a80188b8ed4051f73f26e9899f94c33dc1e (diff) |
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
Diffstat (limited to 'src/Subsampling/include/gudhi/pick_n_random_points.h')
-rw-r--r-- | src/Subsampling/include/gudhi/pick_n_random_points.h | 53 |
1 files changed, 26 insertions, 27 deletions
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 <typename Point_container, - typename OutputIterator> - 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 <typename Point_container, +typename OutputIterator> +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<int> landmarks(nbP); - std::iota(landmarks.begin(), landmarks.end(), 0); + std::size_t nbP = boost::size(points); + assert(nbP >= final_size); + std::vector<int> 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 |