diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-01-07 20:23:35 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-01-07 20:23:35 +0100 |
commit | 92190a1cafc3a8613e1200cd4ed81dbc509a93bd (patch) | |
tree | 43084ae6898fa9bd36e5d71363cc8dcdf8ca0a6c /doc/special_examples/random_cpp11.cpp | |
parent | ac409f51f185a4654f9a5c38ab5d1652824836f6 (diff) |
Add an example showing how to use C++11 random distributions
Diffstat (limited to 'doc/special_examples/random_cpp11.cpp')
-rw-r--r-- | doc/special_examples/random_cpp11.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/special_examples/random_cpp11.cpp b/doc/special_examples/random_cpp11.cpp new file mode 100644 index 000000000..ccd7c77d0 --- /dev/null +++ b/doc/special_examples/random_cpp11.cpp @@ -0,0 +1,14 @@ +#include <Eigen/Core> +#include <iostream> +#include <random> + +using namespace Eigen; + +int main() { + std::default_random_engine generator; + std::poisson_distribution<int> distribution(4.1); + auto poisson = [&] (int) {return distribution(generator);}; + + RowVectorXi v = RowVectorXi::NullaryExpr(10, poisson ); + std::cout << v << "\n"; +} |