Functions that use the Designated initializers syntax for reading inputs and assigning default values use the following rules for handling RNGs.
- The first time a function is called with no
gsl_rng as input, a new gsl_rng is produced. The call will effectively look like this static gsl_rng *internal_rng = gsl_rng_alloc(++apop_opts.rng_seed);
- Because
internal_rng is declared static, it will remember its state as you repeatedly call the function, so you will get appropriate random numbers.
apop_opts.rng_seed is incremented at each use, so you can write down the seed used for later reference.
- Because it increments, the next function to auto-allocate an RNG will produce different random numbers. That is, every function that uses this setup will have a different, independent RNG.
- If you would like a different outcome every time the program runs, set the seed to the time before running:
#include <time.h>
apop_opts.rng_seed = time(NULL);
Autogenerated by doxygen on 23 Nov 2009.