aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/tr1/random
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2006-10-02 00:12:50 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2006-10-02 00:12:50 +0000
commit276116fdcca02afc42d1da59056497f075b742f2 (patch)
treec70f68e068607d9065c930cb53c10a09a1fe71dd /libstdc++-v3/include/tr1/random
parenta40776a29588b73758d83ced0bf31488023de9ad (diff)
downloadgcc-276116fdcca02afc42d1da59056497f075b742f2.zip
gcc-276116fdcca02afc42d1da59056497f075b742f2.tar.gz
gcc-276116fdcca02afc42d1da59056497f075b742f2.tar.bz2
random (xor_combine<>::_M_initialize_max_aux): New.
2006-10-01 Paolo Carlini <pcarlini@suse.de> * include/tr1/random (xor_combine<>::_M_initialize_max_aux): New. (xor_combine<>::operator()()): Tweak per N2079. * include/tr1/random.tcc (xor_combine<>::_M_initialize_max_aux): Define. (xor_combine<>::_M_initialize_max): Use it. * testsuite/tr1/5_numerical_facilities/random/xor_combine/ cons/default.cc: Adjust. * docs/html/ext/tr1.html: Adjust. From-SVN: r117353
Diffstat (limited to 'libstdc++-v3/include/tr1/random')
-rw-r--r--libstdc++-v3/include/tr1/random13
1 files changed, 10 insertions, 3 deletions
diff --git a/libstdc++-v3/include/tr1/random b/libstdc++-v3/include/tr1/random
index 05286ee..543378e 100644
--- a/libstdc++-v3/include/tr1/random
+++ b/libstdc++-v3/include/tr1/random
@@ -1262,7 +1262,8 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
public:
/** The type of the generated random value. */
- typedef typename __gnu_cxx::__conditional_type<(sizeof(_Result_type1) > sizeof(_Result_type2)),
+ typedef typename __gnu_cxx::__conditional_type<(sizeof(_Result_type1)
+ > sizeof(_Result_type2)),
_Result_type1, _Result_type2>::__type result_type;
// parameter values
@@ -1310,7 +1311,6 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
base2() const
{ return _M_b2; }
- // XXX Per N2032, but aren't always right...
result_type
min() const
{ return 0; }
@@ -1322,9 +1322,13 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
/**
* Gets the next random number in the sequence.
*/
+ // NB: Not exactly the TR1 formula, per N2079 instead.
result_type
operator()()
- { return ((_M_b1() << shift1) ^ (_M_b2() << shift2)); }
+ {
+ return ((result_type(_M_b1() - _M_b1.min()) << shift1)
+ ^ (result_type(_M_b2() - _M_b2.min()) << shift2));
+ }
/**
* Compares two %xor_combine random number generator objects of
@@ -1397,6 +1401,9 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
void
_M_initialize_max();
+ result_type
+ _M_initialize_max_aux(result_type, result_type, int);
+
base1_type _M_b1;
base2_type _M_b2;
result_type _M_max;