次の方法で共有


linear_congruential_engine Class

Generates a random sequence by the linear congruential algorithm.

template<class UIntType,
    UIntType A, UIntType C, UIntType M>
    class linear_congruential_engine {
public:
    typedef UIntType result_type;
    static const UIntType multiplier = A;
    static const UIntType increment = C;
    static const UIntType modulus = M;
    static const UIntType default_seed = 1U;
    explicit linear_congruential_engine(result_type x0 = default_seed);
    explicit linear_congruential_engine(seed_seq& seq);
    void seed(result_type x0 = default_seed);
    void seed(seed_seq& seq);
    static const result_type min();
    static const result_type max();
    result_type operator()();
    void discard(unsigned long long count)();
private:
    result_type stored_value;
    };

Parameters

  • UIntType
    The unsigned integer result type.

  • A
    The A engine parameter.

  • C
    The C engine parameter.

  • M
    The M engine parameter.

Remarks

The template class describes a <random> that produces values of a user-specified unsigned integral type using the recurrence relationrecurrence relation x(i) = (A * x(i-1) + C) mod M. The engine's state is the last value returned, or the seed value if no call has been made to operator().

The template argument UIntType must be large enough to hold values up to M - 1. The values of the template arguments A and C must be less than M.

Requirements

Header: <random>

Namespace: std

See Also

Reference

<random>

linear_congruential_engine::discard

linear_congruential_engine::linear_congruential_engine

linear_congruential_engine::operator()

linear_congruential_engine::seed

Other Resources

<random> Members