4#include <Kokkos_Random.hpp>
5#include <common/common.hpp>
6#include <common/traits.hpp>
18 Kokkos::Random_XorShift1024_Pool<Kokkos::DefaultExecutionSpace>;
19 explicit KPRNG(
size_t _seed = 0);
21 [[deprecated]] [[nodiscard]] KOKKOS_INLINE_FUNCTION
double
25 double x = generator.drand(0., 1.);
30 template <FloatingPo
intType T> KOKKOS_INLINE_FUNCTION T
uniform()
const
34 if constexpr (std::is_same_v<T, float>)
36 x = generator.frand();
38 else if constexpr (std::is_same_v<T, double>)
40 x = generator.drand();
46 template <FloatingPo
intType T>
47 KOKKOS_INLINE_FUNCTION T
uniform(T a, T b)
const
51 if constexpr (std::is_same_v<T, float>)
53 x = generator.frand(a, b);
55 else if constexpr (std::is_same_v<T, double>)
57 x = generator.drand(a, b);
63 [[deprecated]] [[nodiscard]] Kokkos::View<double*, ComputeSpace>
64 double_uniform(
size_t n_sample,
double a = 0.,
double b = 1.)
const;
69 Kokkos::View<double[n_r], ComputeSpace> A(
"random");
75 [[deprecated]] KOKKOS_INLINE_FUNCTION std::array<double, n_r>
82 [[nodiscard]] KOKKOS_INLINE_FUNCTION uint64_t
uniform_u(uint64_t a,
87 uint64_t x = generator.urand64(a, b);
101 template <
typename random_pool_t,
size_t n_r,
size_t... I>
102 KOKKOS_INLINE_FUNCTION std::array<double, n_r>
104 std::index_sequence<I...> )
const
107 auto generator = pool.get_state();
108 std::array<double, n_r> res = {
109 {(
static_cast<void>(I), generator.drand(0., 1.))...}};
110 pool.free_state(generator);
KOKKOS_INLINE_FUNCTION uint64_t uniform_u(uint64_t a, uint64_t b) const
Definition prng.hpp:82
Kokkos::View< double[n_r], ComputeSpace > double_uniform_view() const
Definition prng.hpp:67
KOKKOS_INLINE_FUNCTION T uniform() const
Definition prng.hpp:30
Kokkos::Random_XorShift1024_Pool< Kokkos::DefaultExecutionSpace > pool_type
Definition prng.hpp:17
KOKKOS_INLINE_FUNCTION T uniform(T a, T b) const
Definition prng.hpp:47
KOKKOS_INLINE_FUNCTION std::array< double, n_r > generate_uniform_impl(random_pool_t pool, std::index_sequence< I... >) const
Definition prng.hpp:103
auto get_seed() const
Definition prng.hpp:94
KPRNG(size_t _seed=0)
Definition prng.cpp:9
KOKKOS_INLINE_FUNCTION std::array< double, n_r > double_uniform() const
Definition prng.hpp:76
KOKKOS_INLINE_FUNCTION double double_uniform() const
Definition prng.hpp:22
pool_type random_pool
Definition prng.hpp:92
std::size_t seed
Definition prng.hpp:100
Namespace that contains classes and structures related to Monte Carlo (MC) simulations.
Definition alias.hpp:11