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, T max);
40 ~RandNumGen() = default;
41 T
42 generate();
43 };
44
45 template <>
46 class RandNumGen<short>
47 {
48 public:
49 RandNumGen(short min, short max);
50 ~RandNumGen() = default;
51 short
52 generate();
53
54 private:
55 std::mt19937 d_gen;
56 std::uniform_int_distribution<short> d_dis;
57 };
58
59 template <>
60 class RandNumGen<unsigned short>
61 {
62 public:
63 RandNumGen(unsigned short min, unsigned short max);
64 ~RandNumGen() = default;
65 unsigned short
67
68 private:
69 std::mt19937 d_gen;
70 std::uniform_int_distribution<unsigned short> d_dis;
71 };
72
73 template <>
74 class RandNumGen<int>
75 {
76 public:
77 RandNumGen(int min, int max);
78 ~RandNumGen() = default;
79 int
80 generate();
81
82 private:
83 std::mt19937 d_gen;
84 std::uniform_int_distribution<int> d_dis;
85 };
86
87 template <>
88 class RandNumGen<unsigned int>
89 {
90 public:
91 RandNumGen(unsigned int min, unsigned int max);
92 ~RandNumGen() = default;
93 unsigned int
95
96 private:
97 std::mt19937 d_gen;
98 std::uniform_int_distribution<unsigned int> d_dis;
99 };
100
101 template <>
102 class RandNumGen<long>
103 {
104 public:
105 RandNumGen(long min, long max);
106 ~RandNumGen() = default;
107 long
108 generate();
109
110 private:
111 std::mt19937 d_gen;
112 std::uniform_int_distribution<long> d_dis;
113 };
114
115 template <>
116 class RandNumGen<unsigned long>
117 {
118 public:
119 RandNumGen(unsigned long min, unsigned long max);
120 ~RandNumGen() = default;
121 unsigned long
123
124 private:
125 std::mt19937 d_gen;
126 std::uniform_int_distribution<unsigned long> d_dis;
127 };
128
129 template <>
130 class RandNumGen<long long>
131 {
132 public:
133 RandNumGen(long long min, long long max);
134 ~RandNumGen() = default;
135 long long
137
138 private:
139 std::mt19937 d_gen;
140 std::uniform_int_distribution<long long> d_dis;
141 };
142
143 template <>
144 class RandNumGen<unsigned long long>
145 {
146 public:
147 RandNumGen(unsigned long long min, unsigned long long max);
148 ~RandNumGen() = default;
149 unsigned long long
151
152 private:
153 std::mt19937 d_gen;
154 std::uniform_int_distribution<unsigned long long> d_dis;
155 };
156
157 template <>
158 class RandNumGen<float>
159 {
160 public:
161 RandNumGen(float min, float max);
162 ~RandNumGen() = default;
163 float
164 generate();
165
166 private:
167 std::mt19937 d_gen;
168 std::uniform_real_distribution<float> d_dis;
169 };
170
171 template <>
172 class RandNumGen<double>
173 {
174 public:
175 RandNumGen(double min, double max);
176 ~RandNumGen() = default;
177 double
178 generate();
179
180 private:
181 std::mt19937 d_gen;
182 std::uniform_real_distribution<double> d_dis;
183 };
184
185 template <>
186 class RandNumGen<long double>
187 {
188 public:
189 RandNumGen(long double min, long double max);
190 ~RandNumGen() = default;
191 long double
193
194 private:
195 std::mt19937 d_gen;
196 std::uniform_real_distribution<long double> d_dis;
197 };
198
199 template <>
200 class RandNumGen<std::complex<float>>
201 {
202 public:
203 RandNumGen(std::complex<float> min, std::complex<float> max);
204 ~RandNumGen() = default;
205 std::complex<float>
206 generate();
207
208 private:
209 std::mt19937 d_gen;
210 std::uniform_real_distribution<float> d_dis;
211 };
212
213 template <>
214 class RandNumGen<std::complex<double>>
215 {
216 public:
217 RandNumGen(std::complex<double> min, std::complex<double> max);
218 ~RandNumGen() = default;
219 std::complex<double>
220 generate();
221
222 private:
223 std::mt19937 d_gen;
224 std::uniform_real_distribution<double> d_dis;
225 };
226
227 template <>
228 class RandNumGen<std::complex<long double>>
229 {
230 public:
231 RandNumGen(std::complex<long double> min, std::complex<long double> max);
232 ~RandNumGen() = default;
233 std::complex<long double>
235
236 private:
237 std::mt19937 d_gen;
238 std::uniform_real_distribution<long double> d_dis;
239 };
240 } // end of namespace utils
241} // end of namespace dftefe
242#include <utils/RandNumGen.t.cpp>
243#endif // dftefeRandNumGen_h
std::uniform_real_distribution< double > d_dis
Definition: RandNumGen.h:182
std::mt19937 d_gen
Definition: RandNumGen.h:181
std::mt19937 d_gen
Definition: RandNumGen.h:167
std::uniform_real_distribution< float > d_dis
Definition: RandNumGen.h:168
std::mt19937 d_gen
Definition: RandNumGen.h:83
std::uniform_int_distribution< int > d_dis
Definition: RandNumGen.h:84
std::mt19937 d_gen
Definition: RandNumGen.h:111
std::uniform_int_distribution< long > d_dis
Definition: RandNumGen.h:112
std::uniform_real_distribution< long double > d_dis
Definition: RandNumGen.h:196
std::mt19937 d_gen
Definition: RandNumGen.h:195
RandNumGen(long double min, long double max)
std::mt19937 d_gen
Definition: RandNumGen.h:139
std::uniform_int_distribution< long long > d_dis
Definition: RandNumGen.h:140
RandNumGen(long long min, long long max)
std::uniform_int_distribution< short > d_dis
Definition: RandNumGen.h:56
std::mt19937 d_gen
Definition: RandNumGen.h:55
std::mt19937 d_gen
Definition: RandNumGen.h:223
std::uniform_real_distribution< double > d_dis
Definition: RandNumGen.h:224
std::mt19937 d_gen
Definition: RandNumGen.h:209
std::uniform_real_distribution< float > d_dis
Definition: RandNumGen.h:210
std::mt19937 d_gen
Definition: RandNumGen.h:237
RandNumGen(std::complex< long double > min, std::complex< long double > max)
std::uniform_real_distribution< long double > d_dis
Definition: RandNumGen.h:238
std::uniform_int_distribution< unsigned int > d_dis
Definition: RandNumGen.h:98
RandNumGen(unsigned int min, unsigned int max)
std::mt19937 d_gen
Definition: RandNumGen.h:97
std::mt19937 d_gen
Definition: RandNumGen.h:125
std::uniform_int_distribution< unsigned long > d_dis
Definition: RandNumGen.h:126
RandNumGen(unsigned long min, unsigned long max)
std::mt19937 d_gen
Definition: RandNumGen.h:153
std::uniform_int_distribution< unsigned long long > d_dis
Definition: RandNumGen.h:154
RandNumGen(unsigned long long min, unsigned long long max)
std::uniform_int_distribution< unsigned short > d_dis
Definition: RandNumGen.h:70
RandNumGen(unsigned short min, unsigned short max)
std::mt19937 d_gen
Definition: RandNumGen.h:69
Definition: RandNumGen.h:37
T generate()
Definition: RandNumGen.cpp:67
dealii includes
Definition: AtomFieldDataSpherical.cpp:31