A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/rand.adapt.disc below:

[rand.adapt.disc]

29 Numerics library [numerics] 29.6 Random number generation [rand] 29.6.4 Random number engine adaptor class templates [rand.adapt] 29.6.4.2 Class template discard_­block_­engine [rand.adapt.disc]

A discard_­block_­engine random number engine adaptor produces random numbers selected from those produced by some base engine e. The state xi of a discard_­block_­engine engine adaptor object x consists of the state ei of its base engine e and an additional integer n. The size of the state is the size of e's state plus 1.

The transition algorithm discards all but r>0 values from each block of pr values delivered by e. The state transition is performed as follows: If nr, advance the state of e from ei to ei+pr and set n to 0. In any case, then increment n and advance e's then-current state ej to ej+1.

The generation algorithm yields the value returned by the last invocation of e() while advancing e's state as described above.

template<class Engine, size_t p, size_t r>
  class discard_block_engine {
  public:
        using result_type = typename Engine::result_type;

        static constexpr size_t block_size = p;
    static constexpr size_t used_block = r;
    static constexpr result_type min() { return Engine::min(); }
    static constexpr result_type max() { return Engine::max(); }

        discard_block_engine();
    explicit discard_block_engine(const Engine& e);
    explicit discard_block_engine(Engine&& e);
    explicit discard_block_engine(result_type s);
    template<class Sseq> explicit discard_block_engine(Sseq& q);
    void seed();
    void seed(result_type s);
    template<class Sseq> void seed(Sseq& q);

        result_type operator()();
    void discard(unsigned long long z);

        const Engine& base() const noexcept { return e; };

  private:
    Engine e;       int n;        };

The following relations shall hold: 0 < r and r <= p.

The textual representation consists of the textual representation of e followed by the value of n.

In addition to its behavior pursuant to section [rand.req.adapt], each constructor that is not a copy constructor sets n to 0.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4