libscnumerics/src/random.cpp
2021-10-06 11:28:24 +02:00

24 lines
606 B
C++

#include "random.hpp"
sc::random sc::random::singleton {};
bool sc::random::boolean() {
std::uniform_int_distribution<int> dist {0, 1};
return dist(instance()._reng) == 1;
}
int sc::random::int_between(int from, int to) {
std::uniform_int_distribution<int> dist {from, to};
return dist(instance()._reng);
}
double sc::random::double01() {
std::uniform_real_distribution<double> dist {};
return dist(instance()._reng);
}
double sc::random::double_between(double from, double to) {
std::uniform_real_distribution<double> dist {from, to};
return dist(instance()._reng);
}