Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

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

      From cppreference.com
      <cpp‎ |numeric‎ |random‎ |philox engine
       
       
       
      Pseudo-random number generation
       
       
      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 typestd::philox4x32, the 10000th consecutive invocation of it produces the value1955073260.
      • If the default-constructed engine is of typestd::philox4x64, the 10000th consecutive invocation of it produces the value3409172418970261260.
      2) Constructs the engine with a seed valuevalue. The engine's initialstate is determined as follows:[1]
      • All elements of the sequenceX are set to zero.
      • The first element of the sequenceK is set to\(\scriptsize value \mod 2^w \)value mod 2w
        , the remaining elements are set to zero.
      • The value ofj is set ton-1.
      3) Constructs the engine with a seed sequenceseq. The engine's initialstate is determined as follows:[1]
      • All elements of the sequenceX are set to zero.
      • Given(w-1)/32+1 asp, the elements of the sequenceK are set by the following steps:
      1. Creates an invented array objecta of lengthn/2* p.
      2. Callsseq.generate(a+0, a+ n/2* p).
      3. For each integerk in[0n/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 ofj is set ton-1.
      This overload participates in overload resolution only ifSeedSeq meets the requirements ofSeedSequence.
      4) The copy constructor. Upon construction,*this== other istrue.


      1. 1.01.1The bufferY is intentionally not being set. Asj is being set ton-1, the next state transition always generates new random values and stores them inY.

      Contents

      [edit]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

      [edit]Complexity

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

      [edit]Exceptions

      3) IfSeedSeq is notstd::seed_seq, throws the exceptions thrown by theseq.generate call.

      [edit]See also

      sets the current state of the engine
      (public member function)[edit]
      sets the current counter of the engine
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/random/philox_engine/philox_engine&oldid=177251"

      [8]ページ先頭

      ©2009-2025 Movatter.jp