DFT-EFE
 
Loading...
Searching...
No Matches
RandNumGen.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Bikash Kanungo
24 */
25
26#ifndef dftefeRandNumGen_h
27#define dftefeRandNumGen_h
28
29#include <random>
30#include <complex>
31namespace dftefe
32{
33 namespace utils
34 {
35 template <typename T>
37 {
38 public:
39 RandNumGen(T min,
40 T max,
41 bool isReproducible = true,
42 unsigned int seed = 0);
43 ~RandNumGen() = default;
44 T
45 generate();
46 };
47
48 template <>
49 class RandNumGen<short>
50 {
51 public:
52 RandNumGen(short min,
53 short max,
54 bool isReproducible = true,
55 unsigned int seed = 0);
56 ~RandNumGen() = default;
57 short
58 generate();
59
60 private:
61 std::mt19937 d_gen;
62 std::uniform_int_distribution<short> d_dis;
63 };
64
65 template <>
66 class RandNumGen<unsigned short>
67 {
68 public:
69 RandNumGen(unsigned short min,
70 unsigned short max,
71 bool isReproducible = true,
72 unsigned int seed = 0);
73 ~RandNumGen() = default;
74 unsigned short
76
77 private:
78 std::mt19937 d_gen;
79 std::uniform_int_distribution<unsigned short> d_dis;
80 };
81
82 template <>
83 class RandNumGen<int>
84 {
85 public:
86 RandNumGen(int min,
87 int max,
88 bool isReproducible = true,
89 unsigned int seed = 0);
90 ~RandNumGen() = default;
91 int
92 generate();
93
94 private:
95 std::mt19937 d_gen;
96 std::uniform_int_distribution<int> d_dis;
97 };
98
99 template <>
100 class RandNumGen<unsigned int>
101 {
102 public:
103 RandNumGen(unsigned int min,
104 unsigned int max,
105 bool isReproducible = true,
106 unsigned int seed = 0);
107 ~RandNumGen() = default;
108 unsigned int
110
111 private:
112 std::mt19937 d_gen;
113 std::uniform_int_distribution<unsigned int> d_dis;
114 };
115
116 template <>
117 class RandNumGen<long>
118 {
119 public:
120 RandNumGen(long min,
121 long max,
122 bool isReproducible = true,
123 unsigned int seed = 0);
124 ~RandNumGen() = default;
125 long
126 generate();
127
128 private:
129 std::mt19937 d_gen;
130 std::uniform_int_distribution<long> d_dis;
131 };
132
133 template <>
134 class RandNumGen<unsigned long>
135 {
136 public:
137 RandNumGen(unsigned long min,
138 unsigned long max,
139 bool isReproducible = true,
140 unsigned int seed = 0);
141 ~RandNumGen() = default;
142 unsigned long
144
145 private:
146 std::mt19937 d_gen;
147 std::uniform_int_distribution<unsigned long> d_dis;
148 };
149
150 template <>
151 class RandNumGen<long long>
152 {
153 public:
154 RandNumGen(long long min,
155 long long max,
156 bool isReproducible = true,
157 unsigned int seed = 0);
158 ~RandNumGen() = default;
159 long long
161
162 private:
163 std::mt19937 d_gen;
164 std::uniform_int_distribution<long long> d_dis;
165 };
166
167 template <>
168 class RandNumGen<unsigned long long>
169 {
170 public:
171 RandNumGen(unsigned long long min,
172 unsigned long long max,
173 bool isReproducible = true,
174 unsigned int seed = 0);
175 ~RandNumGen() = default;
176 unsigned long long
178
179 private:
180 std::mt19937 d_gen;
181 std::uniform_int_distribution<unsigned long long> d_dis;
182 };
183
184 template <>
185 class RandNumGen<float>
186 {
187 public:
188 RandNumGen(float min,
189 float max,
190 bool isReproducible = true,
191 unsigned int seed = 0);
192 ~RandNumGen() = default;
193 float
194 generate();
195
196 private:
197 std::mt19937 d_gen;
198 std::uniform_real_distribution<float> d_dis;
199 };
200
201 template <>
202 class RandNumGen<double>
203 {
204 public:
205 RandNumGen(double min,
206 double max,
207 bool isReproducible = true,
208 unsigned int seed = 0);
209 ~RandNumGen() = default;
210 double
211 generate();
212
213 private:
214 std::mt19937 d_gen;
215 std::uniform_real_distribution<double> d_dis;
216 };
217
218 template <>
219 class RandNumGen<long double>
220 {
221 public:
222 RandNumGen(long double min,
223 long double max,
224 bool isReproducible = true,
225 unsigned int seed = 0);
226 ~RandNumGen() = default;
227 long double
229
230 private:
231 std::mt19937 d_gen;
232 std::uniform_real_distribution<long double> d_dis;
233 };
234
235 template <>
236 class RandNumGen<std::complex<float>>
237 {
238 public:
239 RandNumGen(std::complex<float> min,
240 std::complex<float> max,
241 bool isReproducible = true,
242 unsigned int seed = 0);
243 ~RandNumGen() = default;
244 std::complex<float>
245 generate();
246
247 private:
248 std::mt19937 d_gen;
249 std::uniform_real_distribution<float> d_dis;
250 };
251
252 template <>
253 class RandNumGen<std::complex<double>>
254 {
255 public:
256 RandNumGen(std::complex<double> min,
257 std::complex<double> max,
258 bool isReproducible = true,
259 unsigned int seed = 0);
260 ~RandNumGen() = default;
261 std::complex<double>
262 generate();
263
264 private:
265 std::mt19937 d_gen;
266 std::uniform_real_distribution<double> d_dis;
267 };
268
269 template <>
270 class RandNumGen<std::complex<long double>>
271 {
272 public:
273 RandNumGen(std::complex<long double> min,
274 std::complex<long double> max,
275 bool isReproducible = true,
276 unsigned int seed = 0);
277 ~RandNumGen() = default;
278 std::complex<long double>
280
281 private:
282 std::mt19937 d_gen;
283 std::uniform_real_distribution<long double> d_dis;
284 };
285 } // end of namespace utils
286} // end of namespace dftefe
287#include <utils/RandNumGen.t.cpp>
288#endif // dftefeRandNumGen_h
std::uniform_real_distribution< double > d_dis
Definition: RandNumGen.h:215
std::mt19937 d_gen
Definition: RandNumGen.h:214
std::mt19937 d_gen
Definition: RandNumGen.h:197
std::uniform_real_distribution< float > d_dis
Definition: RandNumGen.h:198
std::mt19937 d_gen
Definition: RandNumGen.h:95
std::uniform_int_distribution< int > d_dis
Definition: RandNumGen.h:96
std::mt19937 d_gen
Definition: RandNumGen.h:129
std::uniform_int_distribution< long > d_dis
Definition: RandNumGen.h:130
std::uniform_real_distribution< long double > d_dis
Definition: RandNumGen.h:232
RandNumGen(long double min, long double max, bool isReproducible=true, unsigned int seed=0)
std::mt19937 d_gen
Definition: RandNumGen.h:231
std::mt19937 d_gen
Definition: RandNumGen.h:163
RandNumGen(long long min, long long max, bool isReproducible=true, unsigned int seed=0)
std::uniform_int_distribution< long long > d_dis
Definition: RandNumGen.h:164
std::uniform_int_distribution< short > d_dis
Definition: RandNumGen.h:62
std::mt19937 d_gen
Definition: RandNumGen.h:61
std::mt19937 d_gen
Definition: RandNumGen.h:265
std::uniform_real_distribution< double > d_dis
Definition: RandNumGen.h:266
std::mt19937 d_gen
Definition: RandNumGen.h:248
std::uniform_real_distribution< float > d_dis
Definition: RandNumGen.h:249
std::mt19937 d_gen
Definition: RandNumGen.h:282
RandNumGen(std::complex< long double > min, std::complex< long double > max, bool isReproducible=true, unsigned int seed=0)
std::uniform_real_distribution< long double > d_dis
Definition: RandNumGen.h:283
std::uniform_int_distribution< unsigned int > d_dis
Definition: RandNumGen.h:113
RandNumGen(unsigned int min, unsigned int max, bool isReproducible=true, unsigned int seed=0)
std::mt19937 d_gen
Definition: RandNumGen.h:112
std::mt19937 d_gen
Definition: RandNumGen.h:146
std::uniform_int_distribution< unsigned long > d_dis
Definition: RandNumGen.h:147
RandNumGen(unsigned long min, unsigned long max, bool isReproducible=true, unsigned int seed=0)
RandNumGen(unsigned long long min, unsigned long long max, bool isReproducible=true, unsigned int seed=0)
std::mt19937 d_gen
Definition: RandNumGen.h:180
std::uniform_int_distribution< unsigned long long > d_dis
Definition: RandNumGen.h:181
RandNumGen(unsigned short min, unsigned short max, bool isReproducible=true, unsigned int seed=0)
std::uniform_int_distribution< unsigned short > d_dis
Definition: RandNumGen.h:79
std::mt19937 d_gen
Definition: RandNumGen.h:78
Definition: RandNumGen.h:37
T generate()
Definition: RandNumGen.cpp:78
dealii includes
Definition: AtomFieldDataSpherical.cpp:31