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_distribution.hpp>
29IMPKERNEL_BEGIN_NAMESPACE
46template<
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);
88template<
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);
112float get_random_float_uniform();
119float get_random_float_uniform(
float min,
float max);
126double get_random_double_uniform();
133double get_random_double_uniform(
double min,
double max);
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::random::uniform_real_distribution<float> rand(0.0, 1.0);
163#ifdef IMP_KERNEL_CUDA_LIB
166 ::boost::random::uniform_real_distribution<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::random::uniform_real_distribution<double> rand(0.0, 1.0);
196#ifdef IMP_KERNEL_CUDA_LIB
199 ::boost::random::uniform_real_distribution<double> rand(min, max);
206IMPKERNEL_END_NAMESPACE
A class for storing lists of IMP items.
A more IMP-like version of the std::vector.
double get_random_double_uniform()
Return a uniformly distributed double number in range [0..1).
float get_random_float_uniform()
Return a uniformly distributed float number in range [0..1).
void get_random_numbers_uniform(Vector< RealType > &v, unsigned int n)
Fill the float array with random uniformly distributed values.
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.
RandomNumberGenerator random_number_generator
A shared non-GPU random number generator.
Random number generators used by IMP.