# std::philox_engine<UIntType,w,n,r,consts>::philox_engine

From cppreference.com
< cpp‎ | numeric‎ | random‎ | philox engine

philox_engine() : philox_engine(default_seed) {} | (1) | (since C++26)
explicit philox_engine( result_type value ); | (2) | (since C++26)
template< class SeedSeq > explicit philox_engine( SeedSeq& seq ); | (3) | (since C++26)
philox_engine( const philox_engine& other ); | (4) | (since C++26) (implicitly declared)

Constructs the pseudo-random number engine.

1) The default constructor.

- If the default-constructed engine is of type `std::philox4x32`, the 10000th consecutive invocation of it produces the value 1955073260.
- If the default-constructed engine is of type `std::philox4x64`, the 10000th consecutive invocation of it produces the value 3409172418970261260.

2) Constructs the engine with a seed value value. The engine's initial state is determined as follows:[1]

- All elements of the sequence X are set to zero.
- The first element of the sequence K is set to \(\scriptsize value \mod 2^w \)value mod 2w
  , the remaining elements are set to zero.
- The value of j is set to n - 1.

3) Constructs the engine with a seed sequence seq. The engine's initial state is determined as follows:[1]

- All elements of the sequence X are set to zero.
- Given (w - 1) / 32 + 1 as p, the elements of the sequence K are set by the following steps:

1. Creates an invented array object a of length n / 2 * p.
2. Calls seq.generate(a + 0, a + n / 2 * p).
3. For each integer k in `[`​0​`,` n / 2`)`, sets \(\scriptsize K_k \)Kk to \(\scriptsize (\sum^{p-1}_{i=0} a_{k \cdot p+i} \cdot 2^{32i}) \mod 2^w \)(∑p-1
   i=0 ak·p+i·232i
   ) mod 2w
   .

- The value of j is set to n - 1.

This overload participates in overload resolution only if `SeedSeq` meets the requirements of SeedSequence.
4) The copy constructor. Upon construction, *this == other is true.

1. ↑ 1.0 1.1 The buffer Y is intentionally not being set. As j is being set to n - 1, the next state transition always generates new random values and stores them in Y.

### Parameters

value | - | seed value to use in the initialization of the internal state
seq | - | seed sequence to use in the initialization of the internal state

### Complexity

1,2) Constant.
3) Same as the complexity of the `seq.generate` call.
4) Constant.

### Exceptions

3) If `SeedSeq` is not std::seed_seq, throws the exceptions thrown by the `seq.generate` call.

### See also

seed | sets the current state of the engine (public member function)
set_counter | sets the current counter of the engine (public member function)

Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/random/philox_engine/philox_engine&oldid=177251"