다음을 통해 공유


mersenne_twister_engine::seed

Seeds the engine.

void seed(result_type x0 = default_seed);
void seed(seed_seq& seq);

Parameters

  • x0
    The seed value.

  • seq
    The object of type seed_seq that supplies the randomized seed.

Remarks

Precondition: 0 < x0

The first seed function sets the oldest historical value h[0] to x0 mod 2W, then iteratively sets each successive historical value h[i] to (i + F * (h[i - 1] >> (W - 2))) mod 2W, for i ranging from 1 to N - 1.

The second seed function sets the N historical values beginning with h[0] as follows:

  • k is the number of unsigned long integers needed to supply all the bits in a UIntType integer (at least 1).

  • a is an array of N * k elements of type UIntType.

  • a is initialized by calling seq.generate(&a[0], &a[N * k]).

  • Each h[i] is composed by packing the k elements beginning at a[i * k], which supplies the lowest-order bits.

Requirements

Header: <random>

Namespace: std

See Also

Reference

<random>

mersenne_twister_engine Class

Other Resources

<random> Members