I have this program where I use the mersenne twister generator like so:
#include <iostream>
#include <random>
using namespace std;
unsigned seed = 131353;
mt19937 generator(seed);
normal_distribution<real> distribution(0.0, 1.0);
int main() {
cout << distribution(generator);
}
for me it's convenient to declare this generator outside of main so that it is a global variable, so that I don't have to keep passing it as an argument in the functions I have;
but I want to read the seed from a file, which as far as I am aware can only be done inside the main() function.
Is it possible to declare the generator as a global variable and set the seed inside main()?
Thanks in advance
I tried reading the seed from a file outside main function, without success so far
Aucun commentaire:
Enregistrer un commentaire