std::subtra...carry_engine(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

std::subtract_with_carry_engine::subtract_with_carry_engine β€” bestie, this is the constructor page, and you're reading it in the C++ Standard Libary manual under the name std::subtra...carry_engine(3). iconic. πŸ’…


πŸ“œ Synopsis πŸ“œ

subtract_with_carry_engine() : subtract_with_carry_engine(0u) {}  (1) (since C++11)
explicit subtract_with_carry_engine( result_type value );         (2) (since C++11)
template< class SeedSeq >
explicit subtract_with_carry_engine( SeedSeq& seq );              (3) (since C++11)
subtract_with_carry_engine( const subtract_with_carry_engine& other ); (4) (since C++11)
(implicitly declared)

Constructs the pseudo-random number engine. 🫢

  1. The default constructor.
  2. Seed value constructor. Constructs the engine with a seed value value. The sequence X of the engine's initial state is determined as follows:
    1. Constructs a std::linear_congruential_engine<std::uint_least32_t, 40014u, 0u, 2147483563u> object e with argument value == 0u ? default_seed : value.
    2. Let n be std::size_t(w / 32) + 1.
    3. Sets the values of X_{-r}, ..., X_{-1}, in that order. Each value X_i is set as specified below:
      1. Successively calls e for n times, the return values are denoted as z_0 ... z_{n-1}.
      2. Sets X_i to \((\sum^{n-1}_{j=0} z_j \cdot 2^{32j}) \mod m\). If X_{-1} is 0, sets the carry value c of the engine's initial state to 1. Otherwise, sets c to 0.
  3. Seed sequence constructor. Constructs the engine with a seed sequence seq. Given std::size_t(w / 32) + 1 as k, the sequence X of the engine's initial state is determined as follows:
    1. Creates an invented array object a of length r * k.
    2. Calls seq.generate(a + 0, a + r * k).
    3. For each integer i in [-r, -1], sets X_{i} to \((\sum^{k-1}_{j=0} a_{k(i+r)+j} \cdot 2^{32j}) \mod m\). If X_{-1} is 0, sets the carry value c of the engine's initial state to 1. Otherwise, sets c to 0. This overload participates in overload resolution only if SeedSeq meets the requirements of SeedSequence.
  4. The copy constructor. Upon construction, *this == other is true.

🌸 Parameters 🌸

  • value β€” seed value to use in the initialization of the internal state.
  • seq β€” seed sequence to use in the initialization of the internal state.

πŸ”₯ Complexity πŸ”₯

  • 1,2) β€” (std::size_t(w / 32) + 1) * r invocations of e.
  • 3) β€” Same as the complexity of the seq.generate call.
  • 4) β€” O(r).

πŸ’€ Defect reports πŸ’€

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • LWG 3809 β€” applied to: C++11; behavior as published: "e could not be constructed if result_type is std::uint16_t"; correct behavior: "e can be constructed in this case".
  • P0935R0 β€” applied to: C++11; behavior as published: "the default constructor was explicit"; correct behavior: "made implicit".

πŸ¦‹ See also πŸ¦‹

  • seed β€” sets the current state of the engine β€” (C++11) (public member function).

okay that's the whole page, bestie 🫢 β€” source/version: http://cppreference.com; date: 2024.06.10; footer manual name: std::subtra...carry_engine(3). slay and goodbye πŸ’‹

πŸ“¦ where this page comes from