mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Add an example showing how to use C++11 random distributions
This commit is contained in:
14
doc/special_examples/random_cpp11.cpp
Normal file
14
doc/special_examples/random_cpp11.cpp
Normal file
@@ -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";
|
||||
}
|
||||
Reference in New Issue
Block a user