gslsingleton.cpp 618 B

1234567891011121314151617181920212223242526272829303132
  1. #include "sys.hpp" // for libcwd
  2. #include "debug.hpp" // for libcwd
  3. #include "gslsingleton.h"
  4. #include <time.h>
  5. GslSingleton::GslSingleton()
  6. {
  7. // initialize global random generator
  8. const gsl_rng_type * T;
  9. gsl_rng_env_setup();
  10. T = gsl_rng_default;
  11. gslr = gsl_rng_alloc (T);
  12. #ifdef SEED_RNG_WITH_42
  13. unsigned long int seed = (long)(42);
  14. #else
  15. unsigned long int seed = (long)(time( NULL ));
  16. #endif
  17. gsl_rng_set(gslr, seed);
  18. }
  19. GslSingleton& GslSingleton::GetGslSingleton()
  20. {
  21. static GslSingleton instanz;
  22. return instanz;
  23. }
  24. gsl_rng* GslSingleton::GetGslRng()
  25. {
  26. return gslr;
  27. }