Wildmeshing Toolkit
random_seed.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <random>
4
5
namespace
wmtk::utils
{
6
7
class
RandomSeedSingleton
8
{
9
public
:
10
static
RandomSeedSingleton
&
instance
()
11
{
12
static
RandomSeedSingleton
_instance;
13
return
_instance;
14
}
15
16
inline
void
set_seed
(uint64_t val) {
m_gen
.seed(val); std::srand(val); }
17
inline
unsigned
int
get_seed
() {
return
m_gen
(); }
18
19
private
:
20
RandomSeedSingleton
()
21
{
22
std::random_device rd;
23
set_seed
(rd());
24
}
25
26
std::mt19937
m_gen
;
27
};
28
29
30
inline
unsigned
int
get_random_seed
()
31
{
32
return
RandomSeedSingleton::instance
().
get_seed
();
33
}
34
35
inline
void
set_random_seed
(uint64_t val)
36
{
37
RandomSeedSingleton::instance
().
set_seed
(val);
38
}
39
40
}
// namespace wmtk::utils
wmtk::utils::RandomSeedSingleton
Definition:
random_seed.hpp:8
wmtk::utils::RandomSeedSingleton::instance
static RandomSeedSingleton & instance()
Definition:
random_seed.hpp:10
wmtk::utils::RandomSeedSingleton::get_seed
unsigned int get_seed()
Definition:
random_seed.hpp:17
wmtk::utils::RandomSeedSingleton::RandomSeedSingleton
RandomSeedSingleton()
Definition:
random_seed.hpp:20
wmtk::utils::RandomSeedSingleton::m_gen
std::mt19937 m_gen
Definition:
random_seed.hpp:26
wmtk::utils::RandomSeedSingleton::set_seed
void set_seed(uint64_t val)
Definition:
random_seed.hpp:16
wmtk::utils
Definition:
Tuple.hpp:22
wmtk::utils::get_random_seed
unsigned int get_random_seed()
Definition:
random_seed.hpp:30
wmtk::utils::set_random_seed
void set_random_seed(uint64_t val)
Definition:
random_seed.hpp:35
src
wmtk
utils
random_seed.hpp
Generated by
1.9.1