14 #include <type_traits>
22 namespace distribution::gpu
26 template<
typename TFloat>
32 using type = std::uint32_t;
38 using type = std::uint64_t;
46 static_assert(std::is_integral_v<T>,
"Return type of UniformUint must be integral.");
51 template<
typename TEngine>
54 using BitsT =
typename TEngine::result_type;
56 constexpr
auto N =
sizeof(T) /
sizeof(BitsT);
57 for(
unsigned int a = 0; a < N; ++a)
60 ^= (
static_cast<T
>(engine())
61 << (
sizeof(BitsT) * std::numeric_limits<unsigned char>::digits * a));
71 static_assert(std::is_floating_point_v<T>,
"Return type of UniformReal must be floating point.");
78 template<
typename TEngine>
81 constexpr BitsT limit =
static_cast<BitsT
>(1) << std::numeric_limits<T>::digits;
83 auto const ret =
static_cast<T
>(b & (limit - 1)) / limit;
100 template<
typename Acc,
typename T>
103 static_assert(std::is_floating_point_v<T>,
"Return type of NormalReal must be floating point.");
106 T m_cache = std::numeric_limits<T>::quiet_NaN();
133 template<
typename TEngine>
136 constexpr
auto sigma = T{1};
137 constexpr
auto mu = T{0};
147 }
while(u1 <= std::numeric_limits<T>::epsilon());
153 m_cache = mag *
static_cast<T
>(
math::cos(*m_acc, twoPi * u2)) + mu;
155 return mag *
static_cast<T
>(
math::sin(*m_acc, twoPi * u2)) + mu;
158 T
const ret = m_cache;
159 m_cache = std::numeric_limits<T>::quiet_NaN();
165 namespace distribution::trait
171 template<
typename TAcc>
199 namespace engine::trait
205 template<
typename TAcc>
208 std::uint32_t
const& seed,
209 std::uint32_t
const& subsequence,
212 return {seed, subsequence,
offset};
ALPAKA_FN_HOST_ACC auto operator()(TEngine &engine) -> T
constexpr ALPAKA_FN_HOST_ACC NormalReal(NormalReal const &other)
constexpr ALPAKA_FN_HOST_ACC auto operator=(NormalReal const &other) -> NormalReal &
constexpr ALPAKA_FN_HOST_ACC NormalReal(Acc const &acc)
#define ALPAKA_FN_HOST_ACC
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto sqrt(T const &sqrt_ctx, TArg const &arg)
Computes the square root of arg.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto cos(T const &cos_ctx, TArg const &arg)
Computes the cosine (measured in radians).
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto isnan(T const &ctx, TArg const &arg)
Checks if given value is NaN.
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto sin(T const &sin_ctx, TArg const &arg)
Computes the sine (measured in radians).
ALPAKA_NO_HOST_ACC_WARNING ALPAKA_FN_HOST_ACC auto log(T const &log_ctx, TArg const &arg)
Computes the the natural (base e) logarithm of arg.
typename trait::AccType< T >::type Acc
The accelerator type trait alias template to remove the ::type.
Tag used in class inheritance hierarchies that describes that a specific interface (TInterface) is im...
static ALPAKA_FN_HOST_ACC auto createNormalReal(TAcc const &acc) -> gpu::NormalReal< TAcc, T >
The random number float normal distribution get trait.
static ALPAKA_FN_HOST_ACC auto createDefault(TAcc const &, std::uint32_t const &seed, std::uint32_t const &subsequence, std::uint32_t const &offset) -> Philox4x32x10
The random number default generator engine get trait.