Created
July 19, 2014 09:48
-
-
Save orian/b67bf23c41df287844cd to your computer and use it in GitHub Desktop.
Example boost random generating function.
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 <boost/random.hpp> | |
#include <boost/random/normal_distribution.hpp> | |
#include <boost/random/random_device.hpp> | |
#include <boost/random/uniform_real.hpp> | |
double BoostRandom(double dummy) { | |
static boost::random_device rd; | |
static boost::mt19937 rng(rd()); | |
// static boost::normal_distribution<> nd(0.0, 1.0); | |
// return nd(rng); | |
static boost::uniform_real<> unif(-1.0, 1.0); | |
return unif(rng); | |
} | |
// For Eigen3 we initialize Matrix by: | |
MatrixXd::Zero(100, 100).unaryExpr(std::ptr_fun(BoostRandom)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment