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.ibits below:

[rand.adapt.ibits]

29 Numerics library [numerics] 29.6 Random number generation [rand] 29.6.4 Random number engine adaptor class templates [rand.adapt] 29.6.4.3 Class template independent_­bits_­engine [rand.adapt.ibits]

An independent_­bits_­engine random number engine adaptor combines random numbers that are produced by some base engine e, so as to produce random numbers with a specified number of bits w. The state xi of an independent_­bits_­engine engine adaptor object x consists of the state ei of its base engine e; the size of the state is the size of e's state.

The transition and generation algorithms are described in terms of the following integral constants:

  1. a)Let R=e.max() - e.min() + 1 and m=log2R.

  2. b)With n as determined below, let w0=w/n, n0=nwmodn, y0=2w0R/2w0, and y1=2w0+1R/2w0+1.

  3. c)Let n=w/m if and only if the relation Ry0y0/n holds as a result. Otherwise let n=1+w/m.

[Note: The relation w=n0w0+(nn0)(w0+1) always holds. end note]

The transition algorithm is carried out by invoking e() as often as needed to obtain n0 values less than y0+e.min() and nn0 values less than y1+e.min().

The generation algorithm uses the values produced while advancing the state as described above to yield a quantity S obtained as if by the following algorithm:

S = 0;
for (k = 0; kn0; k += 1)  {
 do u = e() - e.min(); while (uy0);
 S = 2w0S+umod2w0;
}
for (k = n0; kn; k += 1)  {
 do u = e() - e.min(); while (uy1);
 S = 2w0+1S+umod2w0+1;
}
template<class Engine, size_t w, class UIntType>
  class independent_bits_engine {
  public:
        using result_type = UIntType;

        static constexpr result_type min() { return 0; }
    static constexpr result_type max() { return 2w1; }

        independent_bits_engine();
    explicit independent_bits_engine(const Engine& e);
    explicit independent_bits_engine(Engine&& e);
    explicit independent_bits_engine(result_type s);
    template<class Sseq> explicit independent_bits_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;     };

The following relations shall hold: 0 < w and w <= numeric_­limits<result_­type>​::​digits.

The textual representation consists of the textual representation of e.


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