-public:
- /** Calls seed(331u). */
- void seed() { seed(331u); }
- /**
- * Constructs a \minstd_rand0 generator with the constructor parameter
- * value and calls seed with it. Distinct seeds in the range
- * [1, 2147483647) will produce generators with different states. Other
- * seeds will be equivalent to some seed within this range. See
- * \linear_congruential for details.
- */
- BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(lagged_fibonacci_01, uint32_t, value)
- {
- minstd_rand0 intgen(value);
- seed(intgen);
- }
-
- /**
- * Sets the state of this @c lagged_fibonacci_01 to the values returned
- * by p invocations of \uniform_01<code>\<RealType\>()(gen)</code>.
- *
- * Complexity: Exactly p invocations of gen.
- */
- BOOST_RANDOM_DETAIL_GENERATOR_SEED(lagged_fibonacci, Generator, gen)
- {
- // use pass-by-reference, but wrap argument in pass_through_engine
- typedef detail::pass_through_engine<Generator&> ref_gen;
- uniform_01<ref_gen, RealType> gen01 =
- uniform_01<ref_gen, RealType>(ref_gen(gen));
- // I could have used std::generate_n, but it takes "gen" by value
- for(unsigned int j = 0; j < long_lag; ++j)
- x[j] = gen01();
- i = long_lag;
- }
-
- template<class It>
- void seed(It& first, It last)
- {
-#ifndef BOOST_NO_STDC_NAMESPACE
- // allow for Koenig lookup
- using std::fmod;
- using std::pow;
-#endif
- unsigned long mask = ~((~0u) << (w%32)); // now lowest w bits set
- RealType two32 = pow(RealType(2), 32);
- unsigned int j;
- for(j = 0; j < long_lag && first != last; ++j) {
- x[j] = RealType(0);
- for(int k = 0; k < w/32 && first != last; ++k, ++first)
- x[j] += *first / pow(two32,k+1);
- if(first != last && mask != 0) {
- x[j] += fmod((*first & mask) / _modulus, RealType(1));
- ++first;
- }
+ /**
+ * Seeds this @c lagged_fibonacci_01_engine using values produced by
+ * @c seq.generate.
+ */
+ BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(lagged_fibonacci_01_engine, SeedSeq, seq)
+ {
+ detail::seed_array_real<w>(seq, x);
+ i = long_lag;
+ }
+
+ /**
+ * Seeds this @c lagged_fibonacci_01_engine using values from the
+ * iterator range [first, last). If there are not enough elements
+ * in the range, throws @c std::invalid_argument.
+ */
+ template<class It>
+ void seed(It& first, It last)
+ {
+ detail::fill_array_real<w>(first, last, x);
+ i = long_lag;
+ }
+
+ /** Returns the smallest value that the generator can produce. */
+ static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return result_type(0); }
+ /** Returns the upper bound of the generators outputs. */
+ static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () { return result_type(1); }
+
+ /** Returns the next value of the generator. */
+ result_type operator()()
+ {
+ if(i >= long_lag)
+ fill();
+ return x[i++];