-
Notifications
You must be signed in to change notification settings - Fork 0
/
RanluxppCompatEngine.h
222 lines (173 loc) · 7.48 KB
/
RanluxppCompatEngine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef RanluxppCompatEngine_h
#define RanluxppCompatEngine_h
#include <cstdint>
#include <memory>
template <int w, int p, int u = 0> class RanluxppCompatEngineImpl;
template <int p> class RanluxppCompatEngineJames final {
private:
using ImplType = RanluxppCompatEngineImpl<24, p>;
std::unique_ptr<ImplType> fImpl;
public:
RanluxppCompatEngineJames(uint64_t seed = 314159265);
virtual ~RanluxppCompatEngineJames();
/// Generate a floating point random number with 24 bits of randomness
double Rndm();
/// Generate a floating point random number with 24 bits of randomness
double operator()();
/// Generate a random integer value with 24 bits
uint64_t IntRndm();
/// Initialize and seed the state of the generator
void SetSeed(uint64_t seed);
/// Skip `n` random numbers without generating them
void Skip(uint64_t n);
};
/// Compatibility engine for original RANLUX implementation by James, luxury
/// level 3 (p = 223). The sequence of numbers also matches `gsl_rng_ranlux`.
using RanluxppCompatEngineJamesP3 = RanluxppCompatEngineJames<223>;
/// Compatibility engine for original RANLUX implementation by James, luxury
/// level 4 (p = 389). The sequence of numbers also matches `gsl_rng_ranlux389`.
using RanluxppCompatEngineJamesP4 = RanluxppCompatEngineJames<389>;
extern template class RanluxppCompatEngineJames<223>;
extern template class RanluxppCompatEngineJames<389>;
/// Compatibility engine for `gsl_rng_ranlxs*` from the GNU Scientific Library.
template <int p> class RanluxppCompatEngineGslRanlxs final {
private:
using ImplType = RanluxppCompatEngineImpl<24, p>;
std::unique_ptr<ImplType> fImpl;
public:
RanluxppCompatEngineGslRanlxs(uint64_t seed = 1);
virtual ~RanluxppCompatEngineGslRanlxs();
/// Generate a floating point random number with 24 bits of randomness
double Rndm();
/// Generate a floating point random number with 24 bits of randomness
double operator()();
/// Generate a random integer value with 24 bits
uint64_t IntRndm();
/// Initialize and seed the state of the generator
void SetSeed(uint64_t seed);
/// Skip `n` random numbers without generating them
void Skip(uint64_t n);
};
using RanluxppCompatEngineGslRanlxs0 = RanluxppCompatEngineGslRanlxs<218>;
using RanluxppCompatEngineGslRanlxs1 = RanluxppCompatEngineGslRanlxs<404>;
using RanluxppCompatEngineGslRanlxs2 = RanluxppCompatEngineGslRanlxs<794>;
extern template class RanluxppCompatEngineGslRanlxs<218>;
extern template class RanluxppCompatEngineGslRanlxs<404>;
extern template class RanluxppCompatEngineGslRanlxs<794>;
/// Compatibility engine for `gsl_rng_ranlxd*` from the GNU Scientific Library.
template <int p> class RanluxppCompatEngineGslRanlxd final {
private:
using ImplType = RanluxppCompatEngineImpl<48, p>;
std::unique_ptr<ImplType> fImpl;
public:
RanluxppCompatEngineGslRanlxd(uint64_t seed = 1);
virtual ~RanluxppCompatEngineGslRanlxd();
/// Generate a floating point random number with 48 bits of randomness
double Rndm();
/// Generate a floating point random number with 48 bits of randomness
double operator()();
/// Generate a random integer value with 48 bits
uint64_t IntRndm();
/// Initialize and seed the state of the generator
void SetSeed(uint64_t seed);
/// Skip `n` random numbers without generating them
void Skip(uint64_t n);
};
using RanluxppCompatEngineGslRanlxd1 = RanluxppCompatEngineGslRanlxd<404>;
using RanluxppCompatEngineGslRanlxd2 = RanluxppCompatEngineGslRanlxd<794>;
extern template class RanluxppCompatEngineGslRanlxd<404>;
extern template class RanluxppCompatEngineGslRanlxd<794>;
template <int w, int p> class RanluxppCompatEngineLuescherImpl;
/// Compatibility engine for Lüscher's ranlxs implementation written in C.
template <int p> class RanluxppCompatEngineLuescherRanlxs final {
private:
using ImplType = RanluxppCompatEngineLuescherImpl<24, p>;
std::unique_ptr<ImplType> fImpl;
public:
RanluxppCompatEngineLuescherRanlxs(uint64_t seed = 314159265);
virtual ~RanluxppCompatEngineLuescherRanlxs();
/// Generate a floating point random number with 24 bits of randomness
double Rndm();
/// Generate a floating point random number with 24 bits of randomness
double operator()();
/// Generate a random integer value with 24 bits
uint64_t IntRndm();
/// Initialize and seed the state of the generator
void SetSeed(uint64_t seed);
/// Skip `n` random numbers without generating them
void Skip(uint64_t n);
};
using RanluxppCompatEngineLuescherRanlxs0 =
RanluxppCompatEngineLuescherRanlxs<218>;
using RanluxppCompatEngineLuescherRanlxs1 =
RanluxppCompatEngineLuescherRanlxs<404>;
using RanluxppCompatEngineLuescherRanlxs2 =
RanluxppCompatEngineLuescherRanlxs<794>;
extern template class RanluxppCompatEngineLuescherRanlxs<218>;
extern template class RanluxppCompatEngineLuescherRanlxs<404>;
extern template class RanluxppCompatEngineLuescherRanlxs<794>;
/// Compatibility engine for Lüscher's ranlxd implementation written in C.
template <int p> class RanluxppCompatEngineLuescherRanlxd final {
private:
using ImplType = RanluxppCompatEngineLuescherImpl<48, p>;
std::unique_ptr<ImplType> fImpl;
public:
RanluxppCompatEngineLuescherRanlxd(uint64_t seed = 314159265);
virtual ~RanluxppCompatEngineLuescherRanlxd();
/// Generate a floating point random number with 48 bits of randomness
double Rndm();
/// Generate a floating point random number with 48 bits of randomness
double operator()();
/// Generate a random integer value with 48 bits
uint64_t IntRndm();
/// Initialize and seed the state of the generator
void SetSeed(uint64_t seed);
/// Skip `n` random numbers without generating them
void Skip(uint64_t n);
};
using RanluxppCompatEngineLuescherRanlxd1 =
RanluxppCompatEngineLuescherRanlxd<404>;
using RanluxppCompatEngineLuescherRanlxd2 =
RanluxppCompatEngineLuescherRanlxd<794>;
extern template class RanluxppCompatEngineLuescherRanlxd<404>;
extern template class RanluxppCompatEngineLuescherRanlxd<794>;
/// Compatibility engine for `std::ranlux24` from the C++ standard.
class RanluxppCompatEngineStdRanlux24 final {
private:
using ImplType = RanluxppCompatEngineImpl<24, 223, 23>;
std::unique_ptr<ImplType> fImpl;
public:
RanluxppCompatEngineStdRanlux24(uint64_t seed = 19780503);
virtual ~RanluxppCompatEngineStdRanlux24();
/// Generate a floating point random number with 24 bits of randomness
double Rndm();
/// Generate a floating point random number with 24 bits of randomness
double operator()();
/// Generate a random integer value with 24 bits
uint64_t IntRndm();
/// Initialize and seed the state of the generator
void SetSeed(uint64_t seed);
/// Skip `n` random numbers without generating them
void Skip(uint64_t n);
};
/// Compatibility engine for `std::ranlux48` from the C++ standard.
class RanluxppCompatEngineStdRanlux48 final {
private:
using ImplType = RanluxppCompatEngineImpl<48, 2 * 389, 11>;
std::unique_ptr<ImplType> fImpl;
public:
RanluxppCompatEngineStdRanlux48(uint64_t seed = 19780503);
virtual ~RanluxppCompatEngineStdRanlux48();
/// Generate a floating point random number with 48 bits of randomness
double Rndm();
/// Generate a floating point random number with 48 bits of randomness
double operator()();
/// Generate a random integer value with 48 bits
uint64_t IntRndm();
/// Initialize and seed the state of the generator
void SetSeed(uint64_t seed);
/// Skip `n` random numbers without generating them
void Skip(uint64_t n);
};
#endif // RanluxppCompatEngine_h