-
-
Save menyf/3afb3be1a168282ee069f6263a37b128 to your computer and use it in GitHub Desktop.
random_double
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <random> | |
class Random { | |
public: | |
Random(double low, double high) { | |
rd = new std::random_device; | |
gen = new std::mt19937((*rd)()); | |
dis = new std::uniform_real_distribution<double>(low, high); | |
} | |
~Random() { | |
delete dis; | |
delete gen; | |
delete rd; | |
} | |
double next() const { return (*dis)(*gen); } | |
private: | |
std::random_device *rd; | |
std::mt19937 *gen; | |
std::uniform_real_distribution<double> *dis; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment