Skip to content

Instantly share code, notes, and snippets.

@orian
Created July 19, 2014 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orian/b67bf23c41df287844cd to your computer and use it in GitHub Desktop.
Save orian/b67bf23c41df287844cd to your computer and use it in GitHub Desktop.
Example boost random generating function.
#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