Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在使用随机数填充一个向量Eigen::VectorXd::Random(n)。
Eigen::VectorXd::Random(n)
是否可以播种 Eigen 的随机数生成器以获得确定性结果?或者,将随机数生成器传递给 Eigen?我在 Eigen wiki 中没有发现任何提及,但缺少这样的功能似乎很奇怪。
它从标准库调用 rand()。您可以通过调用 srand() 来设置种子。
Matrix::Random 使用标准库的随机数生成器,因此可以使用 srand(unsigned int seed) 初始化随机数序列,例如:
srand((unsigned int) time(0));