void discard (unsigned long long z);
123
UIntType Mask = (1u<<w)-1, UMask= (Mask << r) & Mask, LMask = (~UMask) & Mask, Y = (x[i]&UMask)|(x[(i+1)%n]&LMask); // upper bits of x[i] and lower of x[i+1] x[i]=x[(i+m)%n]^(Y>>1)^((Y&1)*a); // mersenne twister linear transformation
1234567891011121314151617181920
// mersenne_twister_engine::discard #include <iostream> #include <chrono> #include <random> int main () { // obtain a seed from the system clock: unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); std::mt19937 generator (seed); // mt19937 is a standard mersenne_twister_engine std::cout << "Random value: " << generator() << std::endl; generator.discard(generator.state_size); // twist the entire state sequence std::cout << "Random value: " << generator() << std::endl; return 0; }
Random value: 2025681734 Random value: 649145785