1

I am currently filling a vector with random numbers using Eigen::VectorXd::Random(n).

Is it possible to seed Eigen's random number generator for deterministic results? Or alternatively, pass a random number generator to Eigen? I found no mention of either in the Eigen wiki, but it seems odd that such a feature would be missing.

Sean Bone
  • 3,368
  • 7
  • 31
  • 47

1 Answers1

3

It calls rand() from the standard library. You can set the seed by calling srand().

Matrix::Random uses the random number generator of the standard library, so you can initialize the random number sequence with srand(unsigned int seed), for instance:

srand((unsigned int) time(0));

Dean Van Greunen
  • 5,060
  • 2
  • 14
  • 28