Loading...
Searching...
No Matches
pick_n_random_points.h
1/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2 * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3 * Author(s): Siargey Kachanovich
4 *
5 * Copyright (C) 2016 Inria
6 *
7 * Modification(s):
8 * - 2026/04 Vincent Rouvreau: Remove non c++17 code and use Gudhi::random
9 * - YYYY/MM Author: Description of the modification
10 */
11
12#ifndef PICK_N_RANDOM_POINTS_H_
13#define PICK_N_RANDOM_POINTS_H_
14
15#ifdef GUDHI_SUBSAMPLING_PROFILING
16# include <gudhi/Clock.h>
17#endif
18#include <gudhi/random.h>
19
20#include <cstddef> // for std::size_t
21#include <algorithm> // for std::sample
22
23
24namespace Gudhi {
25
26namespace subsampling {
27
36template <typename Point_container,
37typename OutputIterator>
38void pick_n_random_points(Point_container const &points,
39 std::size_t final_size,
40 OutputIterator output_it) {
41#ifdef GUDHI_SUBSAMPLING_PROFILING
42 Gudhi::Clock t;
43#endif
44
45 std::sample(std::begin(points), std::end(points), output_it, final_size, Gudhi::random::get_default_random());
46
47#ifdef GUDHI_SUBSAMPLING_PROFILING
48 t.end();
49 std::cerr << "Random landmark choice took " << t.num_seconds()
50 << " seconds." << std::endl;
51#endif
52}
53
54} // namespace subsampling
55
56} // namespace Gudhi
57
58#endif // PICK_N_RANDOM_POINTS_H_
GUDHI_RANDOM_DLL_API Random_generator & get_default_random()
Returns a thread-local default random number generator instance.
Definition random.h:88
void pick_n_random_points(Point_container const &points, std::size_t final_size, OutputIterator output_it)
Subsample a point set by picking random vertices.
Definition pick_n_random_points.h:38
Gudhi namespace.
Definition SimplicialComplexForAlpha.h:14