Algos directory is setup.
This commit is contained in:
parent
0064664556
commit
b91e9ffaf6
38 changed files with 46 additions and 47 deletions
31
src/algos/rand.hpp
Normal file
31
src/algos/rand.hpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
#include <random>
|
||||
#include <chrono>
|
||||
|
||||
|
||||
namespace Random {
|
||||
extern std::mt19937 GENERATOR;
|
||||
|
||||
template<typename T>
|
||||
T uniform(T from, T to) {
|
||||
std::uniform_int_distribution<T> rand(from, to);
|
||||
|
||||
return rand(GENERATOR);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T uniform_real(T from, T to) {
|
||||
std::uniform_real_distribution<T> rand(from, to);
|
||||
|
||||
return rand(GENERATOR);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T normal(T mean, T stddev) {
|
||||
std::normal_distribution<T> rand(mean, stddev);
|
||||
|
||||
return rand(GENERATOR);
|
||||
}
|
||||
|
||||
std::chrono::milliseconds milliseconds(int from, int to);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue