Logo ROOT  
Reference Guide
RanluxppEngine.h
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: Jonas Hahnfeld 11/2020
3
4/*************************************************************************
5 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_Math_RanluxppEngine
13#define ROOT_Math_RanluxppEngine
14
15#include "Math/TRandomEngine.h"
16
17#include <cstdint>
18#include <memory>
19
20namespace ROOT {
21namespace Math {
22
23template <int w, int p, int u = 0>
24class RanluxppEngineImpl;
25
26template <int p>
27class RanluxppEngine final : public TRandomEngine {
28
29private:
31 std::unique_ptr<ImplType> fImpl;
32
33public:
34 RanluxppEngine(uint64_t seed = 314159265);
35 virtual ~RanluxppEngine();
36
37 /// Generate a double-precision random number with 48 bits of randomness
38 double Rndm() override;
39 /// Generate a double-precision random number (non-virtual method)
40 double operator()();
41 /// Generate a random integer value with 48 bits
42 uint64_t IntRndm();
43
44 /// Initialize and seed the state of the generator
45 void SetSeed(uint64_t seed);
46 /// Skip `n` random numbers without generating them
47 void Skip(uint64_t n);
48
49 /// Get name of the generator
50 static const char *Name() { return "RANLUX++"; }
51};
52
55
56extern template class RanluxppEngine<24>;
57extern template class RanluxppEngine<2048>;
58
59
60template <int p>
62
63private:
65 std::unique_ptr<ImplType> fImpl;
66
67public:
68 RanluxppCompatEngineJames(uint64_t seed = 314159265);
70
71 /// Generate a floating point random number with 24 bits of randomness
72 double Rndm() override;
73 /// Generate a floating point random number (non-virtual method)
74 double operator()();
75 /// Generate a random integer value with 24 bits
76 uint64_t IntRndm();
77
78 /// Initialize and seed the state of the generator
79 void SetSeed(uint64_t seed);
80 /// Skip `n` random numbers without generating them
81 void Skip(uint64_t n);
82
83 /// Get name of the generator
84 static const char *Name() { return "RanluxppCompatJames"; }
85};
86
87/// Compatibility engine for original RANLUX implementation by James, luxury
88/// level 3 (p = 223). The sequence of numbers also matches `gsl_rng_ranlux`.
90/// Compatibility engine for original RANLUX implementation by James, luxury
91/// level 4 (p = 389). The sequence of numbers also matches `gsl_rng_ranlux389`.
93
94extern template class RanluxppCompatEngineJames<223>;
95extern template class RanluxppCompatEngineJames<389>;
96
97
98/// Compatibility engine for `gsl_rng_ranlxs*` from the GNU Scientific Library.
99template <int p>
101
102private:
104 std::unique_ptr<ImplType> fImpl;
105
106public:
107 RanluxppCompatEngineGslRanlxs(uint64_t seed = 1);
109
110 /// Generate a floating point random number with 24 bits of randomness
111 double Rndm() override;
112 /// Generate a floating point random number (non-virtual method)
113 double operator()();
114 /// Generate a random integer value with 24 bits
115 uint64_t IntRndm();
116
117 /// Initialize and seed the state of the generator
118 void SetSeed(uint64_t seed);
119 /// Skip `n` random numbers without generating them
120 void Skip(uint64_t n);
121
122 /// Get name of the generator
123 static const char *Name() { return "RanluxppCompatGslRanlxs"; }
124};
125
129
130extern template class RanluxppCompatEngineGslRanlxs<218>;
131extern template class RanluxppCompatEngineGslRanlxs<404>;
132extern template class RanluxppCompatEngineGslRanlxs<794>;
133
134
135/// Compatibility engine for `gsl_rng_ranlxd*` from the GNU Scientific Library.
136template <int p>
138
139private:
141 std::unique_ptr<ImplType> fImpl;
142
143public:
144 RanluxppCompatEngineGslRanlxd(uint64_t seed = 1);
146
147 /// Generate a floating point random number with 48 bits of randomness
148 double Rndm() override;
149 /// Generate a floating point random number (non-virtual method)
150 double operator()();
151 /// Generate a random integer value with 48 bits
152 uint64_t IntRndm();
153
154 /// Initialize and seed the state of the generator
155 void SetSeed(uint64_t seed);
156 /// Skip `n` random numbers without generating them
157 void Skip(uint64_t n);
158
159 /// Get name of the generator
160 static const char *Name() { return "RanluxppCompatGslRanlxd"; }
161};
162
165
166extern template class RanluxppCompatEngineGslRanlxd<404>;
167extern template class RanluxppCompatEngineGslRanlxd<794>;
168
169
170template <int w, int p>
172
173/// Compatibility engine for Lüscher's ranlxs implementation written in C.
174template <int p>
176
177private:
179 std::unique_ptr<ImplType> fImpl;
180
181public:
182 RanluxppCompatEngineLuescherRanlxs(uint64_t seed = 314159265);
184
185 /// Generate a floating point random number with 24 bits of randomness
186 double Rndm() override;
187 /// Generate a floating point random number (non-virtual method)
188 double operator()();
189 /// Generate a random integer value with 24 bits
190 uint64_t IntRndm();
191
192 /// Initialize and seed the state of the generator
193 void SetSeed(uint64_t seed);
194 /// Skip `n` random numbers without generating them
195 void Skip(uint64_t n);
196
197 /// Get name of the generator
198 static const char *Name() { return "RanluxppCompatLuescherRanlxs"; }
199};
200
204
205extern template class RanluxppCompatEngineLuescherRanlxs<218>;
206extern template class RanluxppCompatEngineLuescherRanlxs<404>;
207extern template class RanluxppCompatEngineLuescherRanlxs<794>;
208
209
210/// Compatibility engine for Lüscher's ranlxd implementation written in C.
211template <int p>
213
214private:
216 std::unique_ptr<ImplType> fImpl;
217
218public:
219 RanluxppCompatEngineLuescherRanlxd(uint64_t seed = 314159265);
221
222 /// Generate a floating point random number with 48 bits of randomness
223 double Rndm() override;
224 /// Generate a floating point random number (non-virtual method)
225 double operator()();
226 /// Generate a random integer value with 48 bits
227 uint64_t IntRndm();
228
229 /// Initialize and seed the state of the generator
230 void SetSeed(uint64_t seed);
231 /// Skip `n` random numbers without generating them
232 void Skip(uint64_t n);
233
234 /// Get name of the generator
235 static const char *Name() { return "RanluxppCompatLuescherRanlxd"; }
236};
239
240extern template class RanluxppCompatEngineLuescherRanlxd<404>;
241extern template class RanluxppCompatEngineLuescherRanlxd<794>;
242
243
244/// Compatibility engine for `std::ranlux24` from the C++ standard.
246
247private:
249 std::unique_ptr<ImplType> fImpl;
250
251public:
252 RanluxppCompatEngineStdRanlux24(uint64_t seed = 19780503);
254
255 /// Generate a floating point random number with 24 bits of randomness
256 double Rndm() override;
257 /// Generate a floating point random number (non-virtual method)
258 double operator()();
259 /// Generate a random integer value with 24 bits
260 uint64_t IntRndm();
261
262 /// Initialize and seed the state of the generator
263 void SetSeed(uint64_t seed);
264 /// Skip `n` random numbers without generating them
265 void Skip(uint64_t n);
266
267 /// Get name of the generator
268 static const char *Name() { return "RanluxppCompatStdRanlux24"; }
269};
270
271
272/// Compatibility engine for `std::ranlux48` from the C++ standard.
274
275private:
277 std::unique_ptr<ImplType> fImpl;
278
279public:
280 RanluxppCompatEngineStdRanlux48(uint64_t seed = 19780503);
282
283 /// Generate a floating point random number with 48 bits of randomness
284 double Rndm() override;
285 /// Generate a floating point random number (non-virtual method)
286 double operator()();
287 /// Generate a random integer value with 48 bits
288 uint64_t IntRndm();
289
290 /// Initialize and seed the state of the generator
291 void SetSeed(uint64_t seed);
292 /// Skip `n` random numbers without generating them
293 void Skip(uint64_t n);
294
295 /// Get name of the generator
296 static const char *Name() { return "RanluxppCompatStdRanlux48"; }
297};
298
299} // end namespace Math
300} // end namespace ROOT
301
302#endif /* ROOT_Math_RanluxppEngine */
TRObject operator()(const T1 &t1) const
Compatibility engine for gsl_rng_ranlxd* from the GNU Scientific Library.
static const char * Name()
Get name of the generator.
Compatibility engine for gsl_rng_ranlxs* from the GNU Scientific Library.
static const char * Name()
Get name of the generator.
std::unique_ptr< ImplType > fImpl
static const char * Name()
Get name of the generator.
Compatibility engine for Lüscher's ranlxd implementation written in C.
static const char * Name()
Get name of the generator.
Compatibility engine for Lüscher's ranlxs implementation written in C.
static const char * Name()
Get name of the generator.
Compatibility engine for std::ranlux24 from the C++ standard.
static const char * Name()
Get name of the generator.
Compatibility engine for std::ranlux48 from the C++ standard.
static const char * Name()
Get name of the generator.
Implementation of the RANLUX++ generator.
uint64_t IntRndm()
Generate a random integer value with 48 bits.
double Rndm() override
Generate a double-precision random number with 48 bits of randomness.
void Skip(uint64_t n)
Skip n random numbers without generating them.
void SetSeed(uint64_t seed)
Initialize and seed the state of the generator.
double operator()()
Generate a double-precision random number (non-virtual method)
RanluxppEngine(uint64_t seed=314159265)
static const char * Name()
Get name of the generator.
std::unique_ptr< ImplType > fImpl
const Int_t n
Definition: legend1.C:16
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...