algorithms
2.2.0
Framework-independent algorithms for the EIC
Toggle main menu visibility
Loading...
Searching...
No Matches
random.cpp
Go to the documentation of this file.
1
#include <
algorithms/random.h
>
2
3
namespace
algorithms
{
4
5
// FIXME fix the CMake setup so these are properly found in Gaudi...
6
#if 0
7
void
RandomSvc::init
() {
8
if
(m_seed.hasValue()) {
9
info
() <<
"Custom random seed requested: "
<< m_seed <<
endmsg
;
10
m_gen =
createEngine
(m_seed);
11
}
12
}
13
void
RandomSvc::init
(
const
RandomEngineCB
& gen) {
14
init
();
15
info
() <<
"Loading external generator function."
<<
endmsg
;
16
m_gen = gen;
17
if
(m_seed.hasValue()) {
18
warning
() <<
"Custom random seed request ignored when using external generator function"
19
<<
endmsg
;
20
}
21
}
22
RandomEngineCB
RandomSvc::createEngine
(
const
size_t
seed) {
23
// Each engine has its own state, shared by all copies of the callback
24
struct
Engine {
25
std::mutex m;
26
std::mt19937_64 gen;
27
};
28
auto
engine = std::make_shared<Engine>();
29
engine->gen.seed(seed);
30
return
[engine](
const
size_t
size) {
31
std::lock_guard<std::mutex> lock{engine->m};
32
std::vector<value_type> ret(size);
33
// pass the generator by reference, so its state advances
34
std::generate(ret.begin(), ret.end(), std::ref(engine->gen));
35
return
ret;
36
};
37
}
38
#endif
39
}
// namespace algorithms
algorithms::LoggerMixin::endmsg
static std::ostream & endmsg(std::ostream &os)
Definition
logger.h:244
algorithms::LoggerMixin::warning
detail::LoggerStream warning() const
Definition
logger.h:197
algorithms::LoggerMixin::info
detail::LoggerStream info() const
Definition
logger.h:198
algorithms::RandomSvc::init
void init()
Definition
random.h:77
algorithms::RandomSvc::createEngine
RandomEngineCB createEngine(const size_t seed=1)
Definition
random.h:96
algorithms
Definition
algorithm.h:52
algorithms::RandomEngineCB
detail::CachedBitGenerator::GenFunc RandomEngineCB
Definition
random.h:24
random.h
core
src
random.cpp
Generated by
1.17.0