diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-01-06 16:35:31 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-01-06 16:35:31 (GMT) |
commit | 8aa349b15f65dd5106d182decd26c1027dcb7b7a (patch) | |
tree | 5e76db827968d52215e401a62857f94a8db96b02 /src/func.cc | |
parent | db971485846d54a043777b3db7ba43f31d486939 (diff) |
also use process ID to seed pseudo random number generator
Diffstat (limited to 'src/func.cc')
-rw-r--r-- | src/func.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/func.cc b/src/func.cc index 0f9329d..d32b382 100644 --- a/src/func.cc +++ b/src/func.cc @@ -37,10 +37,19 @@ #include <boost/random/mersenne_twister.hpp> #include <boost/random/uniform_real_distribution.hpp> +#ifdef __WIN32__ +#include <process.h> +int process_id = _getpid(); +#else +#include <sys/types.h> +#include <unistd.h> +int process_id = getpid(); +#endif + boost::random::mt19937 deterministic_rng; -// not technically non-deterministic, but boost::random::random_device has -// non-header library and/or version issues that would complicate the build -boost::random::mt19937 nondeterministic_rng( std::time(0) ); +// this is technically not non-deterministic, but boost::random::random_device +// has non-header library and/or version issues that would complicate the build +boost::random::mt19937 nondeterministic_rng( std::time(0) + process_id ); AbstractFunction::~AbstractFunction() { |