Functions  
template<typename Ftype , typename Itype >  
static Ftype  r123::u01 (Itype in) 
Return a uniform real value in (0, 1]. More...  
template<typename Ftype , typename Itype >  
static Ftype  r123::uneg11 (Itype in) 
Return a signed value in [1,1]. More...  
template<typename Ftype , typename Itype >  
static Ftype  r123::u01fixedpt (Itype in) 
Return a value in (0,1) chosen from a set of equally spaced fixedpoint values. More...  
template<typename Ftype , typename CollType >  
static std::array< Ftype, CollType::static_size >  r123::u01all (CollType in) 
Apply u01 to every item in an r123array, returning a std::array. More...  
template<typename Ftype , typename CollType >  
static std::array< Ftype, CollType::static_size >  r123::uneg11all (CollType in) 
Apply uneg11 to every item in an r123array, returning a std::array. More...  
template<typename Ftype , typename CollType >  
static std::array< Ftype, CollType::static_size >  r123::u01fixedptall (CollType in) 
Apply u01fixedpt to every item in an r123array, returning a std::array. More...  
This file provides some simple functions that can be used to convert integers of various widths to floats and doubles with various characteristics. It can be used to generate realvalued, uniformly distributed random variables from the random integers produced by the Random123 CBRNGs.
There are three templated functions:
The behavior of u01 and uneg11 depend on the preprocessor symbol: R123_UNIFORM_FLOAT_STORE. When #defined to a nonzero value, u01 and uneg11 declare a volatile intermediate result, with the intention of forcing architectures that have "extra bits" in their floating point registers to more closely conform to IEEE arithmetic. When compiled this way, u01 and uneg11 will be significantly slower, as they will incur a memory write and read on every call. Without it, they may fail the "known answer test" implemented in ut_uniform_IEEEkat.cpp even though they perform perfectly reasonable int to float conversions. We have used this option to get 32bit x86 to produce the same results as 64bit x8664 code, but we do not recommend it for normal use.
Three additional functions are defined when C++11 or newer is in use:
These functions apply the corresponding conversion to every element of their argument, which must be a staticly sized array, e.g., an r123array or a std::array of an integer type.
This file may not be as portable, and has not been tested as rigorously as other files in the library, e.g., the generators. Nevertheless, we hope it is useful and we encourage developers to copy it and modify it for their own use. We invite comments and improvements.

inlinestatic 
Return a uniform real value in (0, 1].
Input is a Wbit integer (signed or unsigned). It is cast to a Wbit unsigned integer, multiplied by Ftype(2^W) and added to Ftype(2^(W1)). A good compiler should optimize it down to an inttofloat conversion followed by a multiply and an add, which might be fused, depending on the architecture. If the input is a uniformly distributed integer, and if Ftype arithmetic follows IEEE754 roundtonearest rules, then the result is a uniformly distributed floating point number in (0, 1].

inlinestatic 
Apply u01 to every item in an r123array, returning a std::array.
Only in C++11 and newer. The argument type may be any integer collection with a constexpr static_size member, e.g., an r123array or a std::array of an integer type.

inlinestatic 
Return a value in (0,1) chosen from a set of equally spaced fixedpoint values.
Let:
Then the 2^(B1) possible output values are: 2^B*{1, 3, 5, ..., 2^B  1}
The smallest output is: 2^B
The largest output is: 1  2^B
The output is never exactly 0.0, nor 0.5, nor 1.0.
The 2^(B1) possible outputs:

inlinestatic 
Apply u01fixedpt to every item in an r123array, returning a std::array.
Only in C++11 and newer. The argument type may be any integer collection with a constexpr static_size member, e.g., an r123array or a std::array of an integer type.

inlinestatic 
Return a signed value in [1,1].
The argument is converted to a Wbit signed integer, multiplied by Ftype(2^(W1)) and then added to Ftype(2^W). A good compiler should optimize it down to an inttofloat conversion followed by a multiply and an add, which might be fused, depending on the architecture.
If the input is a uniformly distributed integer, and if Ftype arithmetic follows IEEE754 roundtonearest rules, then the output is a uniformly distributed floating point number in [1, 1].

inlinestatic 
Apply uneg11 to every item in an r123array, returning a std::array.
Only in C++11 and newer. The argument type may be any integer collection with a constexpr static_size member, e.g., an r123array or a std::array of an integer type.