#include #include using namespace std; #include using namespace boost::random; int main(int argc, char * argv[]) { typedef mt11213b Engine; // an MT engine with the default seed Engine boost_mt; stringstream boost_ss; boost_ss << boost_mt; typedef Engine::result_type UIntType; static const size_t n = Engine::state_size; UIntType x[n], * y = x; for (size_t i = 0; i < n; ++i) boost_ss >> x[i] >> ws; Engine boost_mtOther; // alter the high w - r bits of y[0] (for mt11213b, w = 32 and r = 19) y[0] |= 0x00030000; boost_mtOther.seed(y, y + n); // operator== returns false cout << "boost_mt == boost_mtOther: " << (boost_mt == boost_mtOther) << endl; const size_t boost_testSize = 1000000; // however the two engines are equivalent: for (size_t i = 0; i < boost_testSize; ++i) { UIntType result = boost_mt(); UIntType resultOther = boost_mtOther(); if (result != resultOther) cout << "critical check boost_mt() == boost_mtOther() [" << result << " != " << resultOther << "] failed at iteration " << i << endl; } }