gslRandomNumberGenerator.h 531 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef GSLRANDOMNUMBERGENERATOR
  2. #define GSLRANDOMNUMBERGENERATOR
  3. #ifdef NICE_USELIB_GSL
  4. #include <gsl/gsl_randist.h>
  5. #include <gsl/gsl_rng.h>
  6. static gsl_rng *randomGSL = NULL;
  7. static void initGSLRandom ()
  8. {
  9. if ( randomGSL == NULL )
  10. {
  11. gsl_rng_env_setup();
  12. const gsl_rng_type * T = gsl_rng_default;
  13. gsl_rng_default_seed = time(NULL);
  14. randomGSL = gsl_rng_alloc (T);
  15. }
  16. }
  17. static void resetGSLRandom ()
  18. {
  19. if ( randomGSL != NULL )
  20. {
  21. gsl_rng_free ( randomGSL );
  22. randomGSL = NULL;
  23. }
  24. }
  25. #endif
  26. #endif