OpenMPCD
StandardNormal.hpp
Go to the documentation of this file.
1 /**
2  * @file
3  * Defines the `OpenMPCD::CUDA::Random::Distributions::StandardNormal` class.
4  */
5 
6 #ifndef OPENMPCD_CUDA_RANDOM_DISTRIBUTIONS_STANDARDNORMAL_HPP
7 #define OPENMPCD_CUDA_RANDOM_DISTRIBUTIONS_STANDARDNORMAL_HPP
8 
10 
11 
12 namespace OpenMPCD
13 {
14 namespace CUDA
15 {
16 namespace Random
17 {
18 namespace Distributions
19 {
20 
21 /**
22  * The standard normal distribution.
23  *
24  * This is the normal distribution with mean \f$ 0 \f$ and variance \f$ 1 \f$.
25  *
26  * @tparam T The underlying data type, which must be `float` or `double`.
27  */
28 template<typename T>
30 {
31 public:
32  /**
33  * Generates a random value sampled from the distribution.
34  *
35  * @tparam RNG The random number generator type.
36  *
37  * @param[in] rng The random number generator instance.
38  */
39  template<typename RNG>
41  T operator()(RNG& rng) const;
42 }; //class StandardNormal
43 
44 ///@cond
45 template<> template<typename RNG>
47 float StandardNormal<float>::operator()(RNG& rng) const
48 {
49  return curand_normal(rng.getState());
50 }
51 
52 template<> template<typename RNG>
54 double StandardNormal<double>::operator()(RNG& rng) const
55 {
56  return curand_normal_double(rng.getState());
57 }
58 ///@endcond
59 
60 } //namespace Distributions
61 } //namespace Random
62 } //namespace CUDA
63 } //namespace OpenMPCD
64 
65 
66 #endif //OPENMPCD_CUDA_RANDOM_DISTRIBUTIONS_STANDARDNORMAL_HPP
OpenMPCD::CUDA::Random::Distributions::StandardNormal
The standard normal distribution.
Definition: StandardNormal.hpp:29
OPENMPCD_CUDA_DEVICE
#define OPENMPCD_CUDA_DEVICE
Denotes a function to be callable from a CUDA Device.
Definition: Macros.hpp:25
OpenMPCD::CUDA::Random::Distributions::StandardNormal::operator()
OPENMPCD_CUDA_DEVICE T operator()(RNG &rng) const
Generates a random value sampled from the distribution.
OpenMPCD::RNG
boost::mt11213b RNG
The random number generator type.
Definition: Types.hpp:18
Macros.hpp