shuffle.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2018-2021, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <algorithm>
9 #include <cstddef>
10 #include <random>
11 
12 namespace ML {
13 namespace Solver {
14 
15 template <typename math_t>
16 void initShuffle(std::vector<math_t>& rand_indices, std::mt19937& g, math_t random_state = 0)
17 {
18  g.seed((int)random_state);
19  for (std::size_t i = 0; i < rand_indices.size(); ++i)
20  rand_indices[i] = i;
21 }
22 
23 template <typename math_t>
24 void shuffle(std::vector<math_t>& rand_indices, std::mt19937& g)
25 {
26  std::shuffle(rand_indices.begin(), rand_indices.end(), g);
27 }
28 
29 }; // namespace Solver
30 }; // namespace ML
31 // end namespace ML
void shuffle(std::vector< math_t > &rand_indices, std::mt19937 &g)
Definition: shuffle.h:24
void initShuffle(std::vector< math_t > &rand_indices, std::mt19937 &g, math_t random_state=0)
Definition: shuffle.h:16
Definition: dbscan.hpp:18