9#include "Random/Utility.h"
25 template <
typename T,
unsigned Dim>
29 using GeneratorPool =
typename Kokkos::Random_XorShift64_Pool<>;
35 GeneratorPool rand_pool;
47 KOKKOS_INLINE_FUNCTION
randn(view_type v_, GeneratorPool rand_pool_, T* mu_p, T* sd_p)
49 , rand_pool(rand_pool_) {
50 for (
unsigned int i = 0; i < Dim; i++) {
56 KOKKOS_INLINE_FUNCTION
randn(view_type v_, GeneratorPool rand_pool_)
58 , rand_pool(rand_pool_) {
59 for (
unsigned int i = 0; i < Dim; i++) {
70 KOKKOS_INLINE_FUNCTION
const T&
getMu(
unsigned int idx)
const {
return mu[idx]; }
77 KOKKOS_INLINE_FUNCTION
const T&
getSd(
unsigned int idx)
const {
return sd[idx]; }
84 KOKKOS_INLINE_FUNCTION
void operator()(
const size_t i)
const {
86 typename GeneratorPool::generator_type rand_gen = rand_pool.get_state();
88 for (
unsigned d = 0; d < Dim; ++d) {
89 v(i)[d] = mu[d] + sd[d] * rand_gen.normal(0.0, 1.0);
93 rand_pool.free_state(rand_gen);
Definition ViewTypes.h:44
Functor to generate random numbers from a normal distribution.
Definition Randn.h:26
KOKKOS_INLINE_FUNCTION randn(view_type v_, GeneratorPool rand_pool_, T *mu_p, T *sd_p)
Constructor for the randn functor.
Definition Randn.h:47
KOKKOS_INLINE_FUNCTION const T & getSd(unsigned int idx) const
Getter function for the standard deviation in idx dimension.
Definition Randn.h:77
KOKKOS_INLINE_FUNCTION const T & getMu(unsigned int idx) const
Getter function for mean in idx dimension.
Definition Randn.h:70
KOKKOS_INLINE_FUNCTION void operator()(const size_t i) const
Operator to generate random numbers.
Definition Randn.h:84