Currently, I have a main application in Fortran that need a seed to generate pseudo-random numbers.
I would like to run many (many) times this application with completely uncorrelated seeds (and furthermore completely independent pseudo-random numbers chains).
My question is : how to generate the seeds with C++ 2011 ?
In your main thread, extract a single seed (or seed sequence) from a good random source (e.g. from
/dev/urandomon Linux). Use that data to seed a single root PRNG. Then use that PRNG to generate seed values for your thread-local PRNGs.The random number engine interface in
<random>lets you seed both from a single integer and from a sequence of integers. If you want additional randomness, you can seed themt19937from a sequence of several hundred integers.