random_matrix.cpp
来自「This collection of C++ templates wraps t」· C++ 代码 · 共 26 行
CPP
26 行
#include <boost/random.hpp>
namespace {
class Random {
public:
Random() : rng(), gen_uniform(rng), gen_normal(rng,norm) {}
double uniform() { return gen_uniform(); }
double normal() { return gen_normal(); }
void seed(boost::uint32_t s) {
rng.seed(s);
boost::uniform_01<boost::mt19937, double> tmp(rng);
gen_uniform = tmp;
}
private:
boost::mt19937 rng;
boost::uniform_01<boost::mt19937, double> gen_uniform;
boost::normal_distribution<> norm;
boost::variate_generator<boost::mt19937, boost::normal_distribution<> > gen_normal;
};
} // unnamed namespace
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?