I have an application which requires me to call an external C++ function 
involving some random number generation. This function gets called 
thousands of times during the running of my julia code and I would like to 
know how to properly seed or track the state of the random number generator 
in the C++ function. The naive implementation would have the same seed 
every time the C++ function is called and for my monte carlo purposes this 
is not good. I need to get new pseudo random numbers every time the 
function is called.

Some intial thoughts are

A) I could generate a random integer within julia, and supply this as an 
argument when calling my C++ function, and using this to seed the RNG in 
the C++ function
B) using std::random_device to seed the C++ RNG when the C++ function is 
called. However I'm not sure how safe/portable this code would be if such 
hardware device is not available. This falls back to a pseudo random number 
generator if such a device is not available.
C) Generate the random numbers within julia, and pass a pointer to this 
array as an arguement to the C++ function.

Desired) Is it possible to use the same julia RNG within C++ so that the 
same state is advanced within my C++ code as within my julia code?

Reply via email to