libscnumerics/src/random.cpp

24 lines
569 B
C++
Raw Normal View History

2021-10-06 10:55:22 +02:00
#include "random.hpp"
sc::random sc::random::singleton {};
bool sc::random::random_bool() {
std::uniform_int_distribution<int> dist {0, 1};
return dist(_reng) == 1;
}
int sc::random::random_int(int from, int to) {
std::uniform_int_distribution<int> dist {from, to};
return dist(_reng);
}
double sc::random::random_double() {
std::uniform_real_distribution<double> dist {};
return dist(_reng);
}
double sc::random::random_double(double from, double to) {
std::uniform_real_distribution<double> dist {from, to};
return dist(_reng);
}