-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrandom.cpp
More file actions
29 lines (23 loc) · 710 Bytes
/
random.cpp
File metadata and controls
29 lines (23 loc) · 710 Bytes
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
#include <random>
#include <vector>
#include <algorithm>
#include "random.hpp"
Random::Random (){
// The random device for the random numbers
std::random_device device;
// Random-number engine used (Mersenne-Twister in this case)
std::mt19937 rng(device());
mt19937_eng = rng;
}
template <>
int Random::DrawNumber(int min, int max) {
// The uniform int distribution is created
std::uniform_int_distribution<int> distribution(min,max);
return distribution(mt19937_eng);
}
template <>
double Random::DrawNumber(double min, double max) {
// The uniform int distribution is created
std::uniform_real_distribution<double> distribution(min,max);
return distribution(mt19937_eng);
}