3

i want to use the Eigen3 library with the random number generator Mersenne Twister, is there a simple way to extend eigen (simple) ?

I cannot find in the documentation of eigen what random number generator they are using and if its thread safe?

Roby
  • 2,011
  • 4
  • 28
  • 55
  • Can you be more specific? What are you trying to achieve? – Borgleader Jan 05 '15 at 20:38
  • @Borgleader a good and elegant way to initialise a eigen3 matrix. – Roby Jan 05 '15 at 20:41
  • Why would you care about the RNG in Eigen? C++ comes standard with the Mersenne Twister RNG(in ``). Since that's OO, it's not naturally threadsafe but each thread can have its own RNG. – MSalters Jan 06 '15 at 08:17

1 Answers1

3

See this page for an example showing how to use C++11 random generators within Eigen. You can easily adapt it to use the std::mersenne_twister_engine engine.

ggael
  • 28,425
  • 2
  • 65
  • 71
  • 1
    For future reference: The method one has to use is `NullaryExpr`. There the documentation linked above does indeed include an example for exactly this use case. It just took me a while to find it. – PeterE Dec 05 '16 at 13:10
  • Indeed, for some reason the link within the page does not work from outside. – ggael Dec 05 '16 at 15:21