![]() |
alpaka
Abstraction Library for Parallel Kernel Acceleration
|
Select a floating-point value from a uniform interval. More...
#include <UniformReal.hpp>
Public Types | |
| using | Base = internal::UniformRealBase<T_Result, T_Interval> |
| Public Types inherited from alpaka::rand::distribution::internal::UniformRealBase< T_Result, interval::CO > | |
| using | Interval_type |
| using | result_type |
Public Member Functions | |
| constexpr | UniformReal (T_Interval interval=T_Interval{}) |
| constexpr | UniformReal (T_Result min, T_Result max, T_Interval interval=T_Interval{}) |
| template<concepts::UniformRandomEngine T_Engine> | |
| constexpr auto | operator() (T_Engine &engine) const -> T_Result |
| Selects a value from a uniform distribution over the configured (min, max) interval, respecting the specified interval bounds. | |
| Public Member Functions inherited from alpaka::rand::distribution::internal::UniformRealBase< T_Result, interval::CO > | |
| constexpr | UniformRealBase (T_Floating min, T_Floating max, T_Interval) |
Static Public Member Functions | |
| template<std::integral T_Value> | |
| static consteval void | checkValueConformity () |
Private Member Functions | |
| template<concepts::UniformVectorEngine T_Engine> | |
| constexpr auto | engineDispatch (T_Engine &engine) const -> T_Result |
| Dispatch for vector engines (uniform bit generators that return a vector (e.g Philox4x32x10Vector) to enable efficient double precision uniform_real generation (reducing the number of invocations). | |
| template<concepts::UniformStdEngine T_Engine> | |
| constexpr auto | engineDispatch (T_Engine &engine) const -> T_Result |
| Dispatch for std engines and alpaka abbreviations conforming to the std::uniform_random_bit_generator concept (e.g. | |
| constexpr auto | scaleInterval (T_Result const &normalizedVal) const -> T_Result |
| For open bounds, the normalized value in (0, 1) may (still) hit the lower or upper bound due to floating-point rounding (after scaling is applied). | |
Additional Inherited Members | |
| Protected Attributes inherited from alpaka::rand::distribution::internal::UniformRealBase< T_Result, interval::CO > | |
| T_Floating const | m_max |
| T_Floating const | m_min |
| T_Floating const | m_range |
Select a floating-point value from a uniform interval.
This generator produces floating-point values of type T_Result drawn from a uniform interval [a, b) or (a, b], depending on the interval type specified via Interval_v: default case is CO ->[a,b). The interface mirrors std::uniform_real_distribution, and can be invoked with any engine adhering to the 'UniformRandomEngine' concept, which includes std uniform engines.
Supported result types: float, double Supported engine result widths: 32-bit and 64-bit unsigned integers.
Definition at line 258 of file UniformReal.hpp.
| using alpaka::rand::distribution::UniformReal< T_Result, T_Interval >::Base = internal::UniformRealBase<T_Result, T_Interval> |
Definition at line 269 of file UniformReal.hpp.
|
inlineexplicitconstexpr |
Definition at line 271 of file UniformReal.hpp.
|
inlineconstexpr |
Definition at line 275 of file UniformReal.hpp.
|
inlinestaticconsteval |
Definition at line 263 of file UniformReal.hpp.
|
inlineconstexprprivate |
Dispatch for vector engines (uniform bit generators that return a vector (e.g Philox4x32x10Vector) to enable efficient double precision uniform_real generation (reducing the number of invocations).
Definition at line 319 of file UniformReal.hpp.
|
inlineconstexprprivate |
Dispatch for std engines and alpaka abbreviations conforming to the std::uniform_random_bit_generator concept (e.g.
Philox4x32x10)
Definition at line 306 of file UniformReal.hpp.
|
inlineconstexpr |
Selects a value from a uniform distribution over the configured (min, max) interval, respecting the specified interval bounds.
**
Input: a random engine conforming to the UniformRandomEngine concept (currently accepts stdlib uniform engines and alpaka engines included in the alpaka::rand::engine namespace) Output: a floating-point value sampled from the configured distribution.
Definition at line 296 of file UniformReal.hpp.
|
inlineconstexprprivate |
For open bounds, the normalized value in (0, 1) may (still) hit the lower or upper bound due to floating-point rounding (after scaling is applied).
To enforce adherence to the requested interval, the result is shifted to the next representable value using std::nextafter. WARNING: std::nextafter is not constexpr in cpp20 -> this might cause problems on some devices (regarding missing device annotations) and requires often unnecessary runtime evaluation – future maintainers should consider creating a constexpr adaptation of std::nextafter
Definition at line 350 of file UniformReal.hpp.