alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::rand::distribution::UniformReal< T_Result, T_Interval > Struct Template Reference

Select a floating-point value from a uniform interval. More...

#include <UniformReal.hpp>

Inheritance diagram for alpaka::rand::distribution::UniformReal< T_Result, T_Interval >:

Public Types

using Base = internal::UniformRealBase<T_Result, T_Interval>

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.

Static Public Member Functions

template<std::integral T_Value>
static consteval void checkValueConformity ()

Detailed Description

template<std::floating_point T_Result, concepts::Interval T_Interval = interval::CO>
struct alpaka::rand::distribution::UniformReal< T_Result, T_Interval >

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.

Note
This distribution is subject to a small non-uniform bias; see UniformReal::operator() for details.

Definition at line 258 of file UniformReal.hpp.

Member Typedef Documentation

◆ Base

template<std::floating_point T_Result, concepts::Interval T_Interval = interval::CO>
using alpaka::rand::distribution::UniformReal< T_Result, T_Interval >::Base = internal::UniformRealBase<T_Result, T_Interval>

Definition at line 269 of file UniformReal.hpp.

Constructor & Destructor Documentation

◆ UniformReal() [1/2]

template<std::floating_point T_Result, concepts::Interval T_Interval = interval::CO>
alpaka::rand::distribution::UniformReal< T_Result, T_Interval >::UniformReal ( T_Interval interval = T_Interval{})
inlineexplicitconstexpr

Definition at line 271 of file UniformReal.hpp.

◆ UniformReal() [2/2]

template<std::floating_point T_Result, concepts::Interval T_Interval = interval::CO>
alpaka::rand::distribution::UniformReal< T_Result, T_Interval >::UniformReal ( T_Result min,
T_Result max,
T_Interval interval = T_Interval{} )
inlineconstexpr

Definition at line 275 of file UniformReal.hpp.

Member Function Documentation

◆ checkValueConformity()

template<std::floating_point T_Result, concepts::Interval T_Interval = interval::CO>
template<std::integral T_Value>
consteval void alpaka::rand::distribution::UniformReal< T_Result, T_Interval >::checkValueConformity ( )
inlinestaticconsteval

Definition at line 263 of file UniformReal.hpp.

◆ operator()()

template<std::floating_point T_Result, concepts::Interval T_Interval = interval::CO>
template<concepts::UniformRandomEngine T_Engine>
auto alpaka::rand::distribution::UniformReal< T_Result, T_Interval >::operator() ( T_Engine & engine) const -> T_Result
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.

Note
: This distribution introduces a slight numerical bias due to floating-point rounding effects and the use of a 1 / MAX integer-to-floating-point conversion methods
See also
Goualard, F. (2020). Generating Random Floating-Point Numbers by Dividing Integers: A Case Study. https://doi.org/10.1007/978-3-030-50417-5_2 or Allen B. Downey Generating Pseudo-random Floating-Point Values https://allendowney.com/research/rand/. Additionally, using an interval with an open bound (OC,CO,OO) may introduce yet another small non-uniform bias –
scaleInterval().

Definition at line 296 of file UniformReal.hpp.


The documentation for this struct was generated from the following file: