Philox4xW-10, the counter-based std::uniform_random_bit_generator of words of \( W \) bits (32 or 64) of Salmon, Moraes, Dror and Shaw, with the sequence of std::philox4x32 and std::philox4x64 of C++26.
More...
#include <ADS/numeric/RandomGenerators.h>
|
| using | result_type = W |
| using | Block = std::array< W , 4 > |
| | < the type of the numbers
|
| using | Key = std::array< W , 2 > |
| | < a counter, or its 4 outputs
|
|
| constexpr | PhiloxT (W seed=default_seed) |
| | the key \( ( \mathit{seed} , 0 ) \) and the counter 0
|
| constexpr W | operator() (void) |
| | the next number, the next word of the buffer of two blocks, which is filled again when it is empty
|
| constexpr void | discard (unsigned long long z) |
| | advances by \( z \) outputs, in \( O( 1 ) \) blocks
|
| constexpr void | setCounter (const Block &c) |
| | the counter of the next output, which will be the first word of its block
|
| bool | operator== (const PhiloxT &) const =default |
| | true if the two states are equal
|
|
| static constexpr Block | block (Block c, Key k) |
| | the block of the counter \( c \) under the key \( k \): 10 rounds of the products of \( 2 W \) bits by the multipliers, with the key bumped by the Weyl constants between the rounds
|
| static constexpr W | min (void) |
| | the least number, 0
|
| static constexpr W | max (void) |
| | the largest number, \( 2^W - 1 \)
|
template<class W>
class ADS::PhiloxT< W >
Philox4xW-10, the counter-based std::uniform_random_bit_generator of words of \( W \) bits (32 or 64) of Salmon, Moraes, Dror and Shaw, with the sequence of std::philox4x32 and std::philox4x64 of C++26.
◆ Block
< the type of the numbers
◆ Key
< a counter, or its 4 outputs
◆ result_type
◆ PhiloxT()
the key \( ( \mathit{seed} , 0 ) \) and the counter 0
◆ block()
the block of the counter \( c \) under the key \( k \): 10 rounds of the products of \( 2 W \) bits by the multipliers, with the key bumped by the Weyl constants between the rounds
In pseudocode (Salmon and others, beyond the book), \( M_0 , M_1 \) the multipliers and \( w_0 , w_1 \) the Weyl constants:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{block}( c , k ) \cr
2 & \quad \textbf{for}\ r \gets 0\ \textbf{to}\ 9\ \textbf{do} \cr
3 & \qquad \textbf{if}\ r > 0\ \textbf{then}\ k_0 \gets k_0 + w_0;\ k_1
\gets k_1 + w_1 \cr
4 & \qquad ( h_0 , l_0 ) \gets M_0 c_0;\ ( h_1 , l_1 ) \gets M_1 c_2 \cr
5 & \qquad c \gets ( h_1 \oplus c_1 \oplus k_0 , l_1 , h_0 \oplus c_3
\oplus k_1 , l_0 ) \cr
6 & \quad \textbf{return}\ c
\end{array}}
\]
◆ discard()
advances by \( z \) outputs, in \( O( 1 ) \) blocks
In pseudocode (beyond the book), the counter moved instead of the blocks computed:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{discard}( z ) \cr
2 & \quad \textbf{if}\ z \le \text{the outputs left in the buffer}
\ \textbf{then}\ \text{skip them};\ \textbf{return} \cr
3 & \quad z \gets z - \text{those left};\ \mathit{ctr} \gets
\mathit{ctr} + \lfloor z / 4 \rfloor\quad \triangleright\ \text{on }
4 W \text{ bits} \cr
4 & \quad \text{empty the buffer, and draw } z \bmod 4 \text{ outputs}
\end{array}}
\]
◆ max()
the largest number, \( 2^W - 1 \)
◆ min()
◆ operator()()
the next number, the next word of the buffer of two blocks, which is filled again when it is empty
◆ operator==()
true if the two states are equal
◆ setCounter()
the counter of the next output, which will be the first word of its block
◆ default_seed
< a key
the seed of the default constructor, as in C++26
The documentation for this class was generated from the following file: