Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68754 - in trunk: boost/random libs/random/test
From: steven_at_[hidden]
Date: 2011-02-09 17:34:47


Author: steven_watanabe
Date: 2011-02-09 17:34:46 EST (Wed, 09 Feb 2011)
New Revision: 68754
URL: http://svn.boost.org/trac/boost/changeset/68754

Log:
Update lagged_fibonacci to match C++0x.
Added:
   trunk/libs/random/test/test_lagged_fibonacci.cpp (contents, props changed)
   trunk/libs/random/test/test_lagged_fibonacci607.cpp (contents, props changed)
Text files modified:
   trunk/boost/random/lagged_fibonacci.hpp | 859 ++++++++++++++++++---------------------
   trunk/libs/random/test/Jamfile.v2 | 6
   trunk/libs/random/test/validate.cpp | 55 +
   3 files changed, 440 insertions(+), 480 deletions(-)

Modified: trunk/boost/random/lagged_fibonacci.hpp
==============================================================================
--- trunk/boost/random/lagged_fibonacci.hpp (original)
+++ trunk/boost/random/lagged_fibonacci.hpp 2011-02-09 17:34:46 EST (Wed, 09 Feb 2011)
@@ -16,289 +16,232 @@
 #ifndef BOOST_RANDOM_LAGGED_FIBONACCI_HPP
 #define BOOST_RANDOM_LAGGED_FIBONACCI_HPP
 
-#include <boost/config/no_tr1/cmath.hpp>
-#include <iostream>
+#include <istream>
+#include <iosfwd>
 #include <algorithm> // std::max
 #include <iterator>
 #include <boost/config/no_tr1/cmath.hpp> // std::pow
 #include <boost/config.hpp>
 #include <boost/limits.hpp>
 #include <boost/cstdint.hpp>
-#include <boost/detail/workaround.hpp>
+#include <boost/integer/integer_mask.hpp>
 #include <boost/random/linear_congruential.hpp>
 #include <boost/random/uniform_01.hpp>
 #include <boost/random/detail/config.hpp>
 #include <boost/random/detail/seed.hpp>
-#include <boost/random/detail/pass_through_engine.hpp>
+#include <boost/random/detail/operators.hpp>
 
 namespace boost {
 namespace random {
 
-#if BOOST_WORKAROUND(_MSC_FULL_VER, BOOST_TESTED_AT(13102292)) && BOOST_MSVC > 1300
-# define BOOST_RANDOM_EXTRACT_LF
-#endif
-
-#if defined(__APPLE_CC__) && defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ <= 3)
-# define BOOST_RANDOM_EXTRACT_LF
-#endif
-
-# ifdef BOOST_RANDOM_EXTRACT_LF
-namespace detail
-{
- template<class IStream, class F, class RealType>
- IStream&
- extract_lagged_fibonacci_01(
- IStream& is
- , F const& f
- , unsigned int& i
- , RealType* x
- , RealType modulus)
- {
- is >> i >> std::ws;
- for(unsigned int i = 0; i < f.long_lag; ++i)
- {
- RealType value;
- is >> value >> std::ws;
- x[i] = value / modulus;
- }
- return is;
- }
-
- template<class IStream, class F, class UIntType>
- IStream&
- extract_lagged_fibonacci(
- IStream& is
- , F const& f
- , unsigned int& i
- , UIntType* x)
- {
- is >> i >> std::ws;
- for(unsigned int i = 0; i < f.long_lag; ++i)
- is >> x[i] >> std::ws;
- return is;
- }
-}
-# endif
-
 /**
  * Instantiations of class template \lagged_fibonacci model a
  * \pseudo_random_number_generator. It uses a lagged Fibonacci
  * algorithm with two lags @c p and @c q:
  * x(i) = x(i-p) + x(i-q) (mod 2<sup>w</sup>) with p > q.
  */
-template<class UIntType, int w, unsigned int p, unsigned int q,
- UIntType val = 0>
-class lagged_fibonacci
+template<class UIntType, int w, unsigned int p, unsigned int q>
+class lagged_fibonacci_engine
 {
 public:
- typedef UIntType result_type;
- BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
- BOOST_STATIC_CONSTANT(int, word_size = w);
- BOOST_STATIC_CONSTANT(unsigned int, long_lag = p);
- BOOST_STATIC_CONSTANT(unsigned int, short_lag = q);
-
- /**
- * Returns: the smallest value that the generator can produce
- */
- result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 0; }
- /**
- * Returns: the largest value that the generator can produce
- */
- result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return wordmask; }
-
- /**
- * Creates a new @c lagged_fibonacci generator and calls @c seed()
- */
- lagged_fibonacci() { init_wordmask(); seed(); }
- /**
- * Creates a new @c lagged_fibonacci generator and calls @c seed(value)
- */
- explicit lagged_fibonacci(uint32_t value) { init_wordmask(); seed(value); }
- /**
- * Creates a new @c lagged_fibonacci generator and calls @c seed(first, last)
- */
- template<class It> lagged_fibonacci(It& first, It last)
- { init_wordmask(); seed(first, last); }
- // compiler-generated copy ctor and assignment operator are fine
+ typedef UIntType result_type;
+ BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
+ BOOST_STATIC_CONSTANT(int, word_size = w);
+ BOOST_STATIC_CONSTANT(unsigned int, long_lag = p);
+ BOOST_STATIC_CONSTANT(unsigned int, short_lag = q);
+
+ /** Returns the smallest value that the generator can produce. */
+ static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }
+ /** Returns the largest value that the generator can produce. */
+ static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION ()
+ { return low_bits_mask_t<w>::sig_bits; }
+
+ /** Creates a new @c lagged_fibonacci_engine and calls @c seed(). */
+ lagged_fibonacci_engine() { seed(); }
+
+ /** Creates a new @c lagged_fibonacci_engine and calls @c seed(value). */
+ BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(lagged_fibonacci_engine,
+ uint32_t, value)
+ { seed(value); }
+
+ /** Creates a new @c lagged_fibonacci_engine and calls @c seed(seq). */
+ BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(lagged_fibonacci_engine,
+ SeedSeq, seq)
+ { seed(seq); }
+
+ /**
+ * Creates a new @c lagged_fibonacci_engine and calls @c seed(first, last).
+ */
+ template<class It> lagged_fibonacci_engine(It& first, It last)
+ { seed(first, last); }
+
+ // compiler-generated copy ctor and assignment operator are fine
+
+ /** Calls @c seed(331). */
+ void seed() { seed(331u); }
+
+ /**
+ * Sets the state of the generator to values produced by
+ * a \minstd_rand0 generator.
+ */
+ BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(lagged_fibonacci_engine,
+ uint32_t, value)
+ {
+ minstd_rand0 gen(value);
+ for(unsigned int j = 0; j < long_lag; ++j)
+ x[j] = gen() & low_bits_mask_t<w>::sig_bits;
+ i = long_lag;
+ }
 
-private:
- /// \cond hide_private_members
- void init_wordmask()
- {
- wordmask = 0;
- for(int j = 0; j < w; ++j)
- wordmask |= (1u << j);
- }
- /// \endcond
+ /**
+ * Sets the state of the generator using values produced by seq.
+ */
+ BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(lagged_fibonacci_engine, SeedSeq, seq)
+ {
+ boost::uint32_t temp[long_lag];
+ seq.generate(&temp[0], &temp[0] + long_lag);
+ boost::uint32_t* iter = temp;
+ seed(iter, iter + long_lag);
+ }
 
-public:
- /**
- * Sets the state of the generator to values produced by
- * a \minstd_rand generator.
- */
- void seed(uint32_t value = 331u)
- {
- minstd_rand0 gen(value);
- for(unsigned int j = 0; j < long_lag; ++j)
- x[j] = gen() & wordmask;
- i = long_lag;
- }
-
- /**
- * Sets the state of the generator to values from the iterator
- * range [first, last). If there are not enough elements in the
- * range [first, last) throws @c std::invalid_argument.
- */
- template<class It>
- void seed(It& first, It last)
- {
- // word size could be smaller than the seed values
- unsigned int j;
- for(j = 0; j < long_lag && first != last; ++j, ++first)
- x[j] = *first & wordmask;
- i = long_lag;
- if(first == last && j < long_lag)
- throw std::invalid_argument("lagged_fibonacci::seed");
- }
-
- /**
- * Returns: the next value of the generator
- */
- result_type operator()()
- {
- if(i >= long_lag)
- fill();
- return x[i++];
- }
-
- static bool validation(result_type x)
- {
- return x == val;
- }
-
-#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
+ /**
+ * Sets the state of the generator to values from the iterator
+ * range [first, last). If there are not enough elements in the
+ * range [first, last) throws @c std::invalid_argument.
+ */
+ template<class It>
+ void seed(It& first, It last)
+ {
+ // word size could be smaller than the seed values
+ unsigned int j;
+ for(j = 0; j < long_lag && first != last; ++j, ++first)
+ x[j] = *first & low_bits_mask_t<w>::sig_bits;
+ i = long_lag;
+ if(first == last && j < long_lag)
+ throw std::invalid_argument("lagged_fibonacci::seed");
+ }
 
-#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
- template<class CharT, class Traits>
- friend std::basic_ostream<CharT,Traits>&
- operator<<(std::basic_ostream<CharT,Traits>& os, const lagged_fibonacci& f)
- {
- os << f.i << " ";
- for(unsigned int i = 0; i < f.long_lag; ++i)
- os << f.x[i] << " ";
- return os;
- }
-
- template<class CharT, class Traits>
- friend std::basic_istream<CharT, Traits>&
- operator>>(std::basic_istream<CharT, Traits>& is, lagged_fibonacci& f)
- {
-# ifdef BOOST_RANDOM_EXTRACT_LF
- return detail::extract_lagged_fibonacci(is, f, f.i, f.x);
-# else
- is >> f.i >> std::ws;
- for(unsigned int i = 0; i < f.long_lag; ++i)
- is >> f.x[i] >> std::ws;
- return is;
-# endif
- }
-#endif
+ /** Returns the next value of the generator. */
+ result_type operator()()
+ {
+ if(i >= long_lag)
+ fill();
+ return x[i++];
+ }
+
+ /** Fills a range with random values */
+ template<class Iter>
+ void generate(Iter first, Iter last)
+ {
+ for(; first != last; ++first) {
+ *first = (*this)();
+ }
+ }
 
- friend bool operator==(const lagged_fibonacci& x, const lagged_fibonacci& y)
- { return x.i == y.i && std::equal(x.x, x.x+long_lag, y.x); }
- friend bool operator!=(const lagged_fibonacci& x,
- const lagged_fibonacci& y)
- { return !(x == y); }
-#else
- // Use a member function; Streamable concept not supported.
- bool operator==(const lagged_fibonacci& rhs) const
- { return i == rhs.i && std::equal(x, x+long_lag, rhs.x); }
- bool operator!=(const lagged_fibonacci& rhs) const
- { return !(*this == rhs); }
+#ifndef BOOST_NO_LONG_LONG
+ /** Advances the state of the generator by @c z. */
+ void discard(boost::ulong_long_type z)
+ {
+ for(boost::ulong_long_type j = 0; j < z; ++j) {
+ (*this)();
+ }
+ }
 #endif
+
+ /**
+ * Writes the textual representation of the generator to a @c std::ostream.
+ */
+ BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, lagged_fibonacci_engine, f)
+ {
+ os << f.i << " ";
+ for(unsigned int i = 0; i < f.long_lag; ++i)
+ os << f.x[i] << " ";
+ return os;
+ }
+
+ /**
+ * Reads the textual representation of the generator from a @c std::istream.
+ */
+ BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, lagged_fibonacci_engine, f)
+ {
+ is >> f.i >> std::ws;
+ for(unsigned int i = 0; i < f.long_lag; ++i)
+ is >> f.x[i] >> std::ws;
+ return is;
+ }
+
+ /**
+ * Returns true if the two generators will produce identical
+ * sequences of outputs.
+ */
+ BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(lagged_fibonacci_engine, x, y)
+ { return x.i == y.i && std::equal(x.x, x.x+long_lag, y.x); }
+
+ /**
+ * Returns true if the two generators will produce different
+ * sequences of outputs.
+ */
+ BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(lagged_fibonacci_engine)
 
 private:
- /// \cond hide_private_members
- void fill();
- /// \endcond
-
- UIntType wordmask;
- unsigned int i;
- UIntType x[long_lag];
+ /// \cond hide_private_members
+ void fill();
+ /// \endcond
+
+ unsigned int i;
+ UIntType x[long_lag];
 };
 
 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
 // A definition is required even for integral static constants
-template<class UIntType, int w, unsigned int p, unsigned int q, UIntType val>
-const bool lagged_fibonacci<UIntType, w, p, q, val>::has_fixed_range;
-template<class UIntType, int w, unsigned int p, unsigned int q, UIntType val>
-const unsigned int lagged_fibonacci<UIntType, w, p, q, val>::long_lag;
-template<class UIntType, int w, unsigned int p, unsigned int q, UIntType val>
-const unsigned int lagged_fibonacci<UIntType, w, p, q, val>::short_lag;
+template<class UIntType, int w, unsigned int p, unsigned int q>
+const bool lagged_fibonacci_engine<UIntType, w, p, q>::has_fixed_range;
+template<class UIntType, int w, unsigned int p, unsigned int q>
+const unsigned int lagged_fibonacci_engine<UIntType, w, p, q>::long_lag;
+template<class UIntType, int w, unsigned int p, unsigned int q>
+const unsigned int lagged_fibonacci_engine<UIntType, w, p, q>::short_lag;
 #endif
 
-/// \cond hide_private_members
+/// \cond
 
-template<class UIntType, int w, unsigned int p, unsigned int q, UIntType val>
-void lagged_fibonacci<UIntType, w, p, q, val>::fill()
+template<class UIntType, int w, unsigned int p, unsigned int q>
+void lagged_fibonacci_engine<UIntType, w, p, q>::fill()
 {
- // two loops to avoid costly modulo operations
- { // extra scope for MSVC brokenness w.r.t. for scope
- for(unsigned int j = 0; j < short_lag; ++j)
- x[j] = (x[j] + x[j+(long_lag-short_lag)]) & wordmask;
- }
- for(unsigned int j = short_lag; j < long_lag; ++j)
- x[j] = (x[j] + x[j-short_lag]) & wordmask;
- i = 0;
+ // two loops to avoid costly modulo operations
+ { // extra scope for MSVC brokenness w.r.t. for scope
+ for(unsigned int j = 0; j < short_lag; ++j)
+ x[j] = (x[j] + x[j+(long_lag-short_lag)]) & low_bits_mask_t<w>::sig_bits;
+ }
+ for(unsigned int j = short_lag; j < long_lag; ++j)
+ x[j] = (x[j] + x[j-short_lag]) & low_bits_mask_t<w>::sig_bits;
+ i = 0;
 }
 
+/// \endcond
 
+/// \cond
 
-// lagged Fibonacci generator for the range [0..1)
-// contributed by Matthias Troyer
-// for p=55, q=24 originally by G. J. Mitchell and D. P. Moore 1958
-
-template<class T, unsigned int p, unsigned int q>
-struct fibonacci_validation
+// provided for backwards compatibility
+template<class UIntType, int w, unsigned int p, unsigned int q, UIntType v = 0>
+class lagged_fibonacci : public lagged_fibonacci_engine<UIntType, w, p, q>
 {
- BOOST_STATIC_CONSTANT(bool, is_specialized = false);
- static T value() { return 0; }
- static T tolerance() { return 0; }
-};
-
-#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
-// A definition is required even for integral static constants
-template<class T, unsigned int p, unsigned int q>
-const bool fibonacci_validation<T, p, q>::is_specialized;
-#endif
-
-#define BOOST_RANDOM_FIBONACCI_VAL(T,P,Q,V,E) \
-template<> \
-struct fibonacci_validation<T, P, Q> \
-{ \
- BOOST_STATIC_CONSTANT(bool, is_specialized = true); \
- static T value() { return V; } \
- static T tolerance() \
-{ return (std::max)(E, static_cast<T>(5*std::numeric_limits<T>::epsilon())); } \
+ typedef lagged_fibonacci_engine<UIntType, w, p, q> base_type;
+public:
+ lagged_fibonacci() {}
+ BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(lagged_fibonacci, uint32_t, val)
+ { this->seed(val); }
+ BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(lagged_fibonacci, SeedSeq, seq)
+ { this->seed(seq); }
+ template<class It>
+ lagged_fibonacci(It& first, It last) : base_type(first, last) {}
 };
-// (The extra static_cast<T> in the std::max call above is actually
-// unnecessary except for HP aCC 1.30, which claims that
-// numeric_limits<double>::epsilon() doesn't actually return a double.)
-
-BOOST_RANDOM_FIBONACCI_VAL(double, 607, 273, 0.4293817707235914, 1e-14)
-BOOST_RANDOM_FIBONACCI_VAL(double, 1279, 418, 0.9421630240437659, 1e-14)
-BOOST_RANDOM_FIBONACCI_VAL(double, 2281, 1252, 0.1768114046909004, 1e-14)
-BOOST_RANDOM_FIBONACCI_VAL(double, 3217, 576, 0.1956232694868209, 1e-14)
-BOOST_RANDOM_FIBONACCI_VAL(double, 4423, 2098, 0.9499762202147172, 1e-14)
-BOOST_RANDOM_FIBONACCI_VAL(double, 9689, 5502, 0.05737836943695162, 1e-14)
-BOOST_RANDOM_FIBONACCI_VAL(double, 19937, 9842, 0.5076528587449834, 1e-14)
-BOOST_RANDOM_FIBONACCI_VAL(double, 23209, 13470, 0.5414473810619185, 1e-14)
-BOOST_RANDOM_FIBONACCI_VAL(double, 44497,21034, 0.254135073399297, 1e-14)
-
-#undef BOOST_RANDOM_FIBONACCI_VAL
 
 /// \endcond
 
+// lagged Fibonacci generator for the range [0..1)
+// contributed by Matthias Troyer
+// for p=55, q=24 originally by G. J. Mitchell and D. P. Moore 1958
+
 /**
  * Instantiations of class template @c lagged_fibonacci_01 model a
  * \pseudo_random_number_generator. It uses a lagged Fibonacci
@@ -322,216 +265,229 @@
  * 4856 bytes and \lagged_fibonacci44497 requires about 350 KBytes.
  */
 template<class RealType, int w, unsigned int p, unsigned int q>
-class lagged_fibonacci_01
+class lagged_fibonacci_01_engine
 {
 public:
- typedef RealType result_type;
- BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
- BOOST_STATIC_CONSTANT(int, word_size = w);
- BOOST_STATIC_CONSTANT(unsigned int, long_lag = p);
- BOOST_STATIC_CONSTANT(unsigned int, short_lag = q);
-
- /** Constructs a @c lagged_fibonacci_01 generator and calls @c seed(). */
- lagged_fibonacci_01() { init_modulus(); seed(); }
- /** Constructs a @c lagged_fibonacci_01 generator and calls @c seed(value). */
- BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(lagged_fibonacci_01, uint32_t, value)
- { init_modulus(); seed(value); }
- /** Constructs a @c lagged_fibonacci_01 generator and calls @c seed(gen). */
- BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(lagged_fibonacci_01, Generator, gen)
- { init_modulus(); seed(gen); }
- template<class It> lagged_fibonacci_01(It& first, It last)
- { init_modulus(); seed(first, last); }
- // compiler-generated copy ctor and assignment operator are fine
+ typedef RealType result_type;
+ BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
+ BOOST_STATIC_CONSTANT(int, word_size = w);
+ BOOST_STATIC_CONSTANT(unsigned int, long_lag = p);
+ BOOST_STATIC_CONSTANT(unsigned int, short_lag = q);
+
+ /** Constructs a @c lagged_fibonacci_01 generator and calls @c seed(). */
+ lagged_fibonacci_01_engine() { seed(); }
+ /** Constructs a @c lagged_fibonacci_01 generator and calls @c seed(value). */
+ BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(lagged_fibonacci_01_engine, uint32_t, value)
+ { seed(value); }
+ /** Constructs a @c lagged_fibonacci_01 generator and calls @c seed(gen). */
+ BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(lagged_fibonacci_01_engine, SeedSeq, seq)
+ { seed(seq); }
+ template<class It> lagged_fibonacci_01_engine(It& first, It last)
+ { seed(first, last); }
+
+ // compiler-generated copy ctor and assignment operator are fine
+
+ /** 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_engine for details.
+ */
+ BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(lagged_fibonacci_01_engine, uint32_t, value)
+ {
+ minstd_rand0 intgen(value);
+ uniform_01<RealType> dist;
+ for(unsigned j = 0; j < long_lag; ++j)
+ x[j] = dist(intgen);
+ i = long_lag;
+ }
 
-private:
- /// \cond hide_private_members
- void init_modulus()
- {
-#ifndef BOOST_NO_STDC_NAMESPACE
- // allow for Koenig lookup
- using std::pow;
-#endif
- _modulus = pow(RealType(2), word_size);
- }
- /// \endcond
+ /**
+ * 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)
+ {
+ static const int words = (w+31)/32 * long_lag;
+ boost::uint32_t buffer[words];
+ seq.generate(&buffer[0], &buffer[0] + words);
+ boost::uint32_t* iter = buffer;
+ seed(iter, iter + words);
+ 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)
+ {
+ using std::fmod;
+ using std::pow;
+ 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;
+ }
+ }
+ i = long_lag;
+ if(first == last && j < long_lag)
+ throw std::invalid_argument("lagged_fibonacci_01::seed");
+ }
+
+ /** 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); }
 
-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_engine 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;
- }
- }
- i = long_lag;
- if(first == last && j < long_lag)
- throw std::invalid_argument("lagged_fibonacci_01::seed");
- }
-
- result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(0); }
- result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return result_type(1); }
-
- result_type operator()()
- {
- if(i >= long_lag)
- fill();
- return x[i++];
- }
-
- static bool validation(result_type x)
- {
- result_type v = fibonacci_validation<result_type, p, q>::value();
- result_type epsilon = fibonacci_validation<result_type, p, q>::tolerance();
- // std::abs is a source of trouble: sometimes, it's not overloaded
- // for double, plus the usual namespace std noncompliance -> avoid it
- // using std::abs;
- // return abs(x - v) < 5 * epsilon
- return x > v - epsilon && x < v + epsilon;
- }
+ /** Returns the next value of the generator. */
+ result_type operator()()
+ {
+ if(i >= long_lag)
+ fill();
+ return x[i++];
+ }
   
-#ifndef BOOST_NO_OPERATORS_IN_NAMESPACE
+ /** Fills a range with random values */
+ template<class Iter>
+ void generate(Iter first, Iter last)
+ {
+ for(; first != last; ++first) {
+ *first = static_cast<boost::uint32_t>((*this)() * modulus());
+ }
+ }
 
-#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
- template<class CharT, class Traits>
- friend std::basic_ostream<CharT,Traits>&
- operator<<(std::basic_ostream<CharT,Traits>& os, const lagged_fibonacci_01&f)
- {
-#ifndef BOOST_NO_STDC_NAMESPACE
- // allow for Koenig lookup
- using std::pow;
+#ifndef BOOST_NO_LONG_LONG
+ /** Advances the state of the generator by @c z. */
+ void discard(boost::ulong_long_type z)
+ {
+ for(boost::ulong_long_type j = 0; j < z; ++j) {
+ (*this)();
+ }
+ }
 #endif
- os << f.i << " ";
- std::ios_base::fmtflags oldflags = os.flags(os.dec | os.fixed | os.left);
- for(unsigned int i = 0; i < f.long_lag; ++i)
- os << f.x[i] * f._modulus << " ";
- os.flags(oldflags);
- return os;
- }
-
- template<class CharT, class Traits>
- friend std::basic_istream<CharT, Traits>&
- operator>>(std::basic_istream<CharT, Traits>& is, lagged_fibonacci_01& f)
- {
-# ifdef BOOST_RANDOM_EXTRACT_LF
- return detail::extract_lagged_fibonacci_01(is, f, f.i, f.x, f._modulus);
-# else
- is >> f.i >> std::ws;
+
+ /**
+ * Writes the textual representation of the generator to a @c std::ostream.
+ */
+ BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, lagged_fibonacci_01_engine, f)
+ {
+ // allow for Koenig lookup
+ using std::pow;
+ os << f.i << " ";
+ std::ios_base::fmtflags oldflags = os.flags(os.dec | os.fixed | os.left);
+ for(unsigned int i = 0; i < f.long_lag; ++i)
+ os << f.x[i] * f.modulus() << " ";
+ os.flags(oldflags);
+ return os;
+ }
+
+ /**
+ * Reads the textual representation of the generator from a @c std::istream.
+ */
+ BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, lagged_fibonacci_01_engine, f)
+ {
+ is >> f.i;
         for(unsigned int i = 0; i < f.long_lag; ++i) {
- typename lagged_fibonacci_01::result_type value;
- is >> value >> std::ws;
- f.x[i] = value / f._modulus;
+ typename lagged_fibonacci_01_engine::result_type value;
+ is >> std::ws >> value;
+ f.x[i] = value / f.modulus();
         }
         return is;
-# endif
     }
-#endif
-
- friend bool operator==(const lagged_fibonacci_01& x,
- const lagged_fibonacci_01& y)
- { return x.i == y.i && std::equal(x.x, x.x+long_lag, y.x); }
- friend bool operator!=(const lagged_fibonacci_01& x,
- const lagged_fibonacci_01& y)
- { return !(x == y); }
-#else
- // Use a member function; Streamable concept not supported.
- bool operator==(const lagged_fibonacci_01& rhs) const
- { return i == rhs.i && std::equal(x, x+long_lag, rhs.x); }
- bool operator!=(const lagged_fibonacci_01& rhs) const
- { return !(*this == rhs); }
-#endif
+
+ /**
+ * Returns true if the two generators will produce identical
+ * sequences of outputs.
+ */
+ BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(lagged_fibonacci_01_engine, x, y)
+ { return x.i == y.i && std::equal(x.x, x.x+long_lag, y.x); }
+
+ /**
+ * Returns true if the two generators will produce different
+ * sequences of outputs.
+ */
+ BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(lagged_fibonacci_01_engine)
 
 private:
- /// \cond hide_private_members
- void fill();
- /// \endcond
- unsigned int i;
- RealType x[long_lag];
- RealType _modulus;
+ /// \cond
+ void fill();
+ static RealType modulus()
+ {
+ using std::pow;
+ return pow(RealType(2), word_size);
+ }
+ /// \endcond
+ unsigned int i;
+ RealType x[long_lag];
 };
 
 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
 // A definition is required even for integral static constants
 template<class RealType, int w, unsigned int p, unsigned int q>
-const bool lagged_fibonacci_01<RealType, w, p, q>::has_fixed_range;
+const bool lagged_fibonacci_01_engine<RealType, w, p, q>::has_fixed_range;
 template<class RealType, int w, unsigned int p, unsigned int q>
-const unsigned int lagged_fibonacci_01<RealType, w, p, q>::long_lag;
+const unsigned int lagged_fibonacci_01_engine<RealType, w, p, q>::long_lag;
 template<class RealType, int w, unsigned int p, unsigned int q>
-const unsigned int lagged_fibonacci_01<RealType, w, p, q>::short_lag;
+const unsigned int lagged_fibonacci_01_engine<RealType, w, p, q>::short_lag;
 template<class RealType, int w, unsigned int p, unsigned int q>
-const int lagged_fibonacci_01<RealType,w,p,q>::word_size;
+const int lagged_fibonacci_01_engine<RealType,w,p,q>::word_size;
 
 #endif
 
-/// \cond hide_private_members
+/// \cond
 template<class RealType, int w, unsigned int p, unsigned int q>
-void lagged_fibonacci_01<RealType, w, p, q>::fill()
+void lagged_fibonacci_01_engine<RealType, w, p, q>::fill()
 {
- // two loops to avoid costly modulo operations
- { // extra scope for MSVC brokenness w.r.t. for scope
- for(unsigned int j = 0; j < short_lag; ++j) {
- RealType t = x[j] + x[j+(long_lag-short_lag)];
- if(t >= RealType(1))
- t -= RealType(1);
- x[j] = t;
- }
- }
- for(unsigned int j = short_lag; j < long_lag; ++j) {
- RealType t = x[j] + x[j-short_lag];
- if(t >= RealType(1))
- t -= RealType(1);
- x[j] = t;
- }
- i = 0;
+ // two loops to avoid costly modulo operations
+ { // extra scope for MSVC brokenness w.r.t. for scope
+ for(unsigned int j = 0; j < short_lag; ++j) {
+ RealType t = x[j] + x[j+(long_lag-short_lag)];
+ if(t >= RealType(1))
+ t -= RealType(1);
+ x[j] = t;
+ }
+ }
+ for(unsigned int j = short_lag; j < long_lag; ++j) {
+ RealType t = x[j] + x[j-short_lag];
+ if(t >= RealType(1))
+ t -= RealType(1);
+ x[j] = t;
+ }
+ i = 0;
 }
 /// \endcond
 
-} // namespace random
+/// \cond
+
+// provided for backwards compatibility
+template<class RealType, int w, unsigned int p, unsigned int q>
+class lagged_fibonacci_01 : public lagged_fibonacci_01_engine<RealType, w, p, q>
+{
+ typedef lagged_fibonacci_01_engine<RealType, w, p, q> base_type;
+public:
+ lagged_fibonacci_01() {}
+ BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(lagged_fibonacci_01, uint32_t, val)
+ { this->seed(val); }
+ BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(lagged_fibonacci_01, SeedSeq, seq)
+ { this->seed(seq); }
+ template<class It>
+ lagged_fibonacci_01(It& first, It last) : base_type(first, last) {}
+};
+
+/// \endcond
 
 #ifdef BOOST_RANDOM_DOXYGEN
 namespace detail {
@@ -558,47 +514,36 @@
 }
 #endif
 
-/**
- * @copydoc boost::detail::lagged_fibonacci_doc
- */
-typedef random::lagged_fibonacci_01<double, 48, 607, 273> lagged_fibonacci607;
-/**
- * @copydoc boost::detail::lagged_fibonacci_doc
- */
-typedef random::lagged_fibonacci_01<double, 48, 1279, 418> lagged_fibonacci1279;
-/**
- * @copydoc boost::detail::lagged_fibonacci_doc
- */
-typedef random::lagged_fibonacci_01<double, 48, 2281, 1252> lagged_fibonacci2281;
-/**
- * @copydoc boost::detail::lagged_fibonacci_doc
- */
-typedef random::lagged_fibonacci_01<double, 48, 3217, 576> lagged_fibonacci3217;
-/**
- * @copydoc boost::detail::lagged_fibonacci_doc
- */
-typedef random::lagged_fibonacci_01<double, 48, 4423, 2098> lagged_fibonacci4423;
-/**
- * @copydoc boost::detail::lagged_fibonacci_doc
- */
-typedef random::lagged_fibonacci_01<double, 48, 9689, 5502> lagged_fibonacci9689;
-/**
- * @copydoc boost::detail::lagged_fibonacci_doc
- */
-typedef random::lagged_fibonacci_01<double, 48, 19937, 9842> lagged_fibonacci19937;
-/**
- * @copydoc boost::detail::lagged_fibonacci_doc
- */
-typedef random::lagged_fibonacci_01<double, 48, 23209, 13470> lagged_fibonacci23209;
-/**
- * @copydoc boost::detail::lagged_fibonacci_doc
- */
-typedef random::lagged_fibonacci_01<double, 48, 44497, 21034> lagged_fibonacci44497;
+/** @copydoc boost::random::detail::lagged_fibonacci_doc */
+typedef lagged_fibonacci_01_engine<double, 48, 607, 273> lagged_fibonacci607;
+/** @copydoc boost::random::detail::lagged_fibonacci_doc */
+typedef lagged_fibonacci_01_engine<double, 48, 1279, 418> lagged_fibonacci1279;
+/** @copydoc boost::random::detail::lagged_fibonacci_doc */
+typedef lagged_fibonacci_01_engine<double, 48, 2281, 1252> lagged_fibonacci2281;
+/** @copydoc boost::random::detail::lagged_fibonacci_doc */
+typedef lagged_fibonacci_01_engine<double, 48, 3217, 576> lagged_fibonacci3217;
+/** @copydoc boost::random::detail::lagged_fibonacci_doc */
+typedef lagged_fibonacci_01_engine<double, 48, 4423, 2098> lagged_fibonacci4423;
+/** @copydoc boost::random::detail::lagged_fibonacci_doc */
+typedef lagged_fibonacci_01_engine<double, 48, 9689, 5502> lagged_fibonacci9689;
+/** @copydoc boost::random::detail::lagged_fibonacci_doc */
+typedef lagged_fibonacci_01_engine<double, 48, 19937, 9842> lagged_fibonacci19937;
+/** @copydoc boost::random::detail::lagged_fibonacci_doc */
+typedef lagged_fibonacci_01_engine<double, 48, 23209, 13470> lagged_fibonacci23209;
+/** @copydoc boost::random::detail::lagged_fibonacci_doc */
+typedef lagged_fibonacci_01_engine<double, 48, 44497, 21034> lagged_fibonacci44497;
 
+} // namespace random
 
-// It is possible to partially specialize uniform_01<> on lagged_fibonacci_01<>
-// to help the compiler generate efficient code. For GCC, this seems useless,
-// because GCC optimizes (x-0)/(1-0) to (x-0). This is good enough for now.
+using random::lagged_fibonacci607;
+using random::lagged_fibonacci1279;
+using random::lagged_fibonacci2281;
+using random::lagged_fibonacci3217;
+using random::lagged_fibonacci4423;
+using random::lagged_fibonacci9689;
+using random::lagged_fibonacci19937;
+using random::lagged_fibonacci23209;
+using random::lagged_fibonacci44497;
 
 } // namespace boost
 

Modified: trunk/libs/random/test/Jamfile.v2
==============================================================================
--- trunk/libs/random/test/Jamfile.v2 (original)
+++ trunk/libs/random/test/Jamfile.v2 2011-02-09 17:34:46 EST (Wed, 09 Feb 2011)
@@ -1,5 +1,5 @@
 # Copyright 2003 Jens Maurer
-# Copyright 2009-2010 Steven Watanabe
+# Copyright 2009-2011 Steven Watanabe
 # Distributed under the Boost Software License, Version 1.0. (See accompany-
 # ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 
@@ -24,8 +24,6 @@
     kreutzer1986
     mt11213b
     mt19937_64
- lagged_fibonacci
- lagged_fibonacci607
     ranlux3
     ranlux4
     ranlux3_01
@@ -45,6 +43,8 @@
 run test_mt19937.cpp /boost//unit_test_framework ;
 run test_ecuyer1988.cpp /boost//unit_test_framework ;
 run test_hellekalek1995.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci607.cpp /boost//unit_test_framework ;
 
 run test_seed_seq.cpp /boost//unit_test_framework ;
 

Added: trunk/libs/random/test/test_lagged_fibonacci.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci.cpp 2011-02-09 17:34:46 EST (Wed, 09 Feb 2011)
@@ -0,0 +1,17 @@
+/* test_lagged_fibonacci.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+typedef boost::random::lagged_fibonacci_engine<boost::uint32_t, 24, 607, 273> lagged_fibonacci;
+#define BOOST_RANDOM_URNG lagged_fibonacci
+
+#include "test_generator.ipp"

Added: trunk/libs/random/test/test_lagged_fibonacci607.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/random/test/test_lagged_fibonacci607.cpp 2011-02-09 17:34:46 EST (Wed, 09 Feb 2011)
@@ -0,0 +1,16 @@
+/* test_lagged_fibonacci607.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci607
+
+#include "test_generator.ipp"

Modified: trunk/libs/random/test/validate.cpp
==============================================================================
--- trunk/libs/random/test/validate.cpp (original)
+++ trunk/libs/random/test/validate.cpp 2011-02-09 17:34:46 EST (Wed, 09 Feb 2011)
@@ -21,8 +21,9 @@
  */
 
 template<class PRNG>
-typename PRNG::result_type validation_value(PRNG rng)
+typename PRNG::result_type validation_value()
 {
+ PRNG rng;
     for(int i = 0; i < 9999; i++)
         rng();
     return rng();
@@ -31,56 +32,70 @@
 int test_main(int, char*[])
 {
     // own run
- BOOST_CHECK_EQUAL(validation_value(boost::mt11213b()), 3809585648U);
+ BOOST_CHECK_EQUAL(validation_value<boost::mt11213b>(), 3809585648U);
 
     // validation by experiment from mt19937.c
- BOOST_CHECK_EQUAL(validation_value(boost::mt19937()), 4123659995U);
+ BOOST_CHECK_EQUAL(validation_value<boost::mt19937>(), 4123659995U);
 
 #if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
     // validation from the C++0x draft (n3090)
- BOOST_CHECK_EQUAL(validation_value(boost::mt19937_64()), UINT64_C(9981545732273789042));
+ BOOST_CHECK_EQUAL(validation_value<boost::mt19937_64>(), UINT64_C(9981545732273789042));
 #endif
 
     // validation values from the publications
- BOOST_CHECK_EQUAL(validation_value(boost::minstd_rand0()), 1043618065);
+ BOOST_CHECK_EQUAL(validation_value<boost::minstd_rand0>(), 1043618065);
 
     // validation values from the publications
- BOOST_CHECK_EQUAL(validation_value(boost::minstd_rand()), 399268537);
+ BOOST_CHECK_EQUAL(validation_value<boost::minstd_rand>(), 399268537);
 
 #if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
     // by experiment from lrand48()
- BOOST_CHECK_EQUAL(validation_value(boost::rand48()), 1993516219);
+ BOOST_CHECK_EQUAL(validation_value<boost::rand48>(), 1993516219);
 #endif
 
     // ????
- BOOST_CHECK_EQUAL(validation_value(boost::taus88()), 3535848941U);
+ BOOST_CHECK_EQUAL(validation_value<boost::taus88>(), 3535848941U);
 
     // ????
- BOOST_CHECK_EQUAL(validation_value(boost::ecuyer1988()), 2060321752);
+ BOOST_CHECK_EQUAL(validation_value<boost::ecuyer1988>(), 2060321752);
 
     // validation by experiment from Harry Erwin's generator.h (private e-mail)
- BOOST_CHECK_EQUAL(validation_value(boost::kreutzer1986()), 139726);
+ BOOST_CHECK_EQUAL(validation_value<boost::kreutzer1986>(), 139726);
 
     // validation from the C++0x draft (n3090)
- BOOST_CHECK_EQUAL(validation_value(boost::random::knuth_b()), 1112339016);
+ BOOST_CHECK_EQUAL(validation_value<boost::random::knuth_b>(), 1112339016);
 
- BOOST_CHECK_CLOSE_FRACTION(validation_value(boost::lagged_fibonacci607()), 0.401269, 1e-5);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci607>(), 0.401269, 1e-5);
 
     // principal operation validated with CLHEP, values by experiment
- BOOST_CHECK_EQUAL(validation_value(boost::ranlux3()), 5957620);
- BOOST_CHECK_EQUAL(validation_value(boost::ranlux4()), 8587295);
+ BOOST_CHECK_EQUAL(validation_value<boost::ranlux3>(), 5957620);
+ BOOST_CHECK_EQUAL(validation_value<boost::ranlux4>(), 8587295);
 
- BOOST_CHECK_CLOSE_FRACTION(validation_value(boost::ranlux3_01()), 5957620/std::pow(2.0f,24), 1e-6);
- BOOST_CHECK_CLOSE_FRACTION(validation_value(boost::ranlux4_01()), 8587295/std::pow(2.0f,24), 1e-6);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::ranlux3_01>(), 5957620/std::pow(2.0f,24), 1e-6);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::ranlux4_01>(), 8587295/std::pow(2.0f,24), 1e-6);
 
- BOOST_CHECK_CLOSE_FRACTION(validation_value(boost::ranlux64_3_01()), 0.838413, 1e-6);
- BOOST_CHECK_CLOSE_FRACTION(validation_value(boost::ranlux64_4_01()), 0.59839, 1e-6);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::ranlux64_3_01>(), 0.838413, 1e-6);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::ranlux64_4_01>(), 0.59839, 1e-6);
 
- BOOST_CHECK_EQUAL(validation_value(boost::random::ranlux24()), 9901578);
+ BOOST_CHECK_EQUAL(validation_value<boost::random::ranlux24>(), 9901578);
 
 #if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
- BOOST_CHECK_EQUAL(validation_value(boost::random::ranlux48()), UINT64_C(249142670248501));
+ BOOST_CHECK_EQUAL(validation_value<boost::random::ranlux48>(), UINT64_C(249142670248501));
 #endif
 
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci607>(), 0.40126853196520074, 1e-14);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci1279>(), 0.56576990947654049, 1e-14);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci2281>(), 0.85870032418398168, 1e-14);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci3217>(), 0.29923216793615537, 1e-14);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci4423>(), 0.39798595467394815, 1e-14);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci9689>(), 0.22728966337376244, 1e-14);
+
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci19937>(), 0.21779661133680173, 1e-14);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci23209>(), 0.98718042717052668, 1e-14);
+ BOOST_CHECK_CLOSE_FRACTION(validation_value<boost::lagged_fibonacci44497>(), 0.86191789886161496, 1e-14);
+
+ typedef boost::random::lagged_fibonacci_engine<boost::uint32_t, 24, 607, 273> lagged_fibonacci;
+ BOOST_CHECK_EQUAL(validation_value<lagged_fibonacci>(), 3543833);
+
     return 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk