9 #ifndef IMPKERNEL_RANDOM_UTILS_H
10 #define IMPKERNEL_RANDOM_UTILS_H
12 #include <IMP/kernel_config.h>
15 #ifdef IMP_KERNEL_CUDA_LIB
17 #include "IMP/internal/random_number_generation_cuda.h"
20 #include "IMP/internal/random_number_generation_boost.h"
23 #include <boost/random/mersenne_twister.hpp>
24 #include <boost/random/uniform_real.hpp>
29 IMPKERNEL_BEGIN_NAMESPACE
46 template<
typename RealType>
49 RealType mean=0.0, RealType stddev=1.0)
57 #ifdef IMP_KERNEL_CUDA_LIB
58 static unsigned last_seeded = 0;
59 IMPcuda::kernel::internal::init_gpu_rng_once(
63 IMPcuda::kernel::internal::get_random_numbers_normal_cuda
64 (&v[0], n, mean, stddev);
66 internal::get_random_numbers_normal_boost(&v[0], n, mean, stddev);
88 template<
typename RealType>
95 #ifdef IMP_KERNEL_CUDA_LIB
96 static unsigned last_seeded = 0;
97 IMPcuda::kernel::internal::init_gpu_rng_once(
101 IMPcuda::kernel::internal::get_random_numbers_uniform_cuda (&v[0], n);
103 internal::get_random_numbers_uniform_boost(&v[0], n);
141 #ifdef IMP_KERNEL_CUDA_LIB
142 const static unsigned int cache_n=20000000;
144 static unsigned int i=0;
145 static unsigned last_seeded = 0;
146 if (i >= cache.size()
154 static boost::uniform_real<float> rand(0.0, 1.0);
163 #ifdef IMP_KERNEL_CUDA_LIB
166 ::boost::uniform_real<float> rand(min, max);
175 #ifdef IMP_KERNEL_CUDA_LIB
176 const static unsigned int cache_n=2000000;
178 static unsigned int i=0;
179 static unsigned last_seeded = 0;
180 if (i >= cache.size()
188 static boost::uniform_real<double> rand(0.0, 1.0);
196 #ifdef IMP_KERNEL_CUDA_LIB
199 ::boost::uniform_real<double> rand(min, max);
206 IMPKERNEL_END_NAMESPACE
void get_random_numbers_uniform(Vector< RealType > &v, unsigned int n)
Fill the float array with random uniformly distributed values.
A more IMP-like version of the std::vector.
double get_random_double_uniform(double min, double max)
Return a uniformly distributed double number in range [min..max)
float get_random_float_uniform(float min, float max)
Return a uniformly distributed float number in range [min..max)
A class for storing lists of IMP items.
void get_random_numbers_normal(Vector< RealType > &v, unsigned int n, RealType mean=0.0, RealType stddev=1.0)
Fill the double array with random normally distributed values.
Random number generators used by IMP.
RandomNumberGenerator random_number_generator
A shared non-GPU random number generator.