* include/tr1/random (xor_combine<>::operator<<): Fix typo.
* include/tr1/random (bernoulli_distribution::min(),
bernoulli_distribution::max(), geometric_distribution<>::min(),
geometric_distribution<>::max()): Remove.
* include/tr1/random (geometric_distribution<>::operator()):
Simplify formula.
* include/tr1/random: Minor cosmetic changes.
* testsuite/tr1/5_numerical_facilities/random/discard_block/
operators/equal.cc: New.
* testsuite/tr1/5_numerical_facilities/random/discard_block/
operators/not_equal.cc: Likewise.
* testsuite/tr1/5_numerical_facilities/random/discard_block/
operators/serialize.cc: Likewise.
* testsuite/tr1/5_numerical_facilities/random/xor_combine/
operators/equal.cc: Likewise.
* testsuite/tr1/5_numerical_facilities/random/xor_combine/
operators/not_equal.cc: Likewise.
* testsuite/tr1/5_numerical_facilities/random/xor_combine/
operators/serialize.cc: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114777
138bc75d-0d04-0410-961f-
82ee72b054a4
+2006-06-19 Paolo Carlini <pcarlini@suse.de>
+
+ * include/tr1/random (xor_combine<>::operator<<): Fix typo.
+
+ * include/tr1/random (bernoulli_distribution::min(),
+ bernoulli_distribution::max(), geometric_distribution<>::min(),
+ geometric_distribution<>::max()): Remove.
+
+ * include/tr1/random (geometric_distribution<>::operator()):
+ Simplify formula.
+
+ * include/tr1/random: Minor cosmetic changes.
+
+ * testsuite/tr1/5_numerical_facilities/random/discard_block/
+ operators/equal.cc: New.
+ * testsuite/tr1/5_numerical_facilities/random/discard_block/
+ operators/not_equal.cc: Likewise.
+ * testsuite/tr1/5_numerical_facilities/random/discard_block/
+ operators/serialize.cc: Likewise.
+ * testsuite/tr1/5_numerical_facilities/random/xor_combine/
+ operators/equal.cc: Likewise.
+ * testsuite/tr1/5_numerical_facilities/random/xor_combine/
+ operators/not_equal.cc: Likewise.
+ * testsuite/tr1/5_numerical_facilities/random/xor_combine/
+ operators/serialize.cc: Likewise.
+
2006-06-17 Ami Tavory <atavory@gmail.com>
Paolo Carlini <pcarlini@suse.de>
/**
* Constructs a default %discard_block engine.
*
- * The underlying engine is default constrcuted as well.
+ * The underlying engine is default constructed as well.
*/
discard_block()
: _M_n(0) { }
* Copies an existing base class random number geenerator.
* @param rng An existing (base class) engine object.
*/
- explicit discard_block(const base_type& __rng)
- : _M_b(__rng) , _M_n(0) { }
+ explicit
+ discard_block(const base_type& __rng)
+ : _M_b(__rng), _M_n(0) { }
/**
* Seed constructs a %discard_block engine.
* Constructs the underlying generator engine seeded with @p __s.
* @param __s A seed value for the base class engine.
*/
- explicit discard_block(unsigned long __s)
+ explicit
+ discard_block(unsigned long __s)
: _M_b(__s), _M_n(0) { }
/**
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const xor_combine& __x)
- { return __os << __x.base1() << " " << __x.base1(); }
+ { return __os << __x.base1() << " " << __x.base2(); }
/**
* Extracts the current state of a %xor_combine random number
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const uniform_int& __x)
- { return __os << __x._M_min << " " << __x._M_max; }
+ { return __os << __x.min() << " " << __x.max(); }
/**
* Extracts a %unform_int random number distribution
{ return _M_p; }
/**
- * Gets the inclusive lower bound of the distribution range.
- */
- result_type
- min() const
- { return false; }
-
- /**
- * Gets the inclusive upper bound of the distribution range.
- */
- result_type
- max() const
- { return true; }
-
- /**
* Resets the distribution state.
*
* Does nothing for a bernoulli distribution.
p() const
{ return _M_p; }
- /**
- * Gets the inclusive lower bound of the distribution range.
- */
- result_type
- min() const;
-
- /**
- * Gets the inclusive upper bound of the distribution range.
- */
- result_type
- max() const;
-
void
reset() { }
template<class _UniformRandomNumberGenerator>
result_type
operator()(_UniformRandomNumberGenerator& __urng)
- {
- return result_type(std::floor(std::log(_RealType(1.0) - __urng())
- / _M_log_p)) + result_type(1);
- }
+ { return result_type(std::ceil(std::log(__urng()) / _M_log_p)); }
/**
* Inserts a %geometric_distribution random number distribution
friend std::basic_ostream<_CharT, _Traits>&
operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const uniform_real& __x)
- { return __os << __x._M_min << " " << __x._M_max; }
+ { return __os << __x.min() << " " << __x.max(); }
/**
* Extracts a %unform_real random number distribution
--- /dev/null
+// 2006-06-19 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 5.1.4.5 class template discard_block [tr.rand.eng.disc]
+// 5.1.1 Table 16
+
+#include <tr1/random>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std::tr1;
+
+ discard_block
+ <
+ subtract_with_carry<long, (1 << 24), 10, 24>,
+ 389, 24
+ > u, v;
+
+ VERIFY( u == v );
+
+ for (int i = 0; i < 100; ++i)
+ {
+ u();
+ v();
+ }
+ VERIFY( u == v );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2006-06-19 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 5.1.4.5 class template discard_block [tr.rand.eng.disc]
+// 5.1.1 Table 16
+
+#include <tr1/random>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std::tr1;
+
+ discard_block
+ <
+ subtract_with_carry<long, (1 << 24), 10, 24>,
+ 389, 24
+ > u(1);
+
+ discard_block
+ <
+ subtract_with_carry<long, (1 << 24), 10, 24>,
+ 389, 24
+ > v(2);
+
+ VERIFY( u != v );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2006-06-19 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 5.1.4.5 class template discard_block [tr.rand.eng.disc]
+// 5.1.1 Table 16
+
+#include <sstream>
+#include <tr1/random>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::tr1::discard_block;
+ using std::tr1::subtract_with_carry;
+
+ std::stringstream str;
+ discard_block
+ <
+ subtract_with_carry<long, (1 << 24), 10, 24>,
+ 389, 24
+ > u, v;
+
+ u(); // advance
+ str << u;
+
+ VERIFY( u != v );
+
+ str >> v;
+ VERIFY( u == v );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2006-06-19 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 5.1.4.6 class template xor_combine [tr.rand.eng.xor]
+// 5.1.1 Table 16
+
+#include <tr1/random>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std::tr1;
+
+ xor_combine
+ <
+ minstd_rand, 1,
+ mt19937, 2
+ > u, v;
+
+ VERIFY( u == v );
+
+ for (int i = 0; i < 100; ++i)
+ {
+ u();
+ v();
+ }
+ VERIFY( u == v );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2006-06-19 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 5.1.4.6 class template discard_block [tr.rand.eng.xor]
+// 5.1.1 Table 16
+
+#include <tr1/random>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ using namespace std::tr1;
+
+ xor_combine
+ <
+ minstd_rand, 1,
+ mt19937, 2
+ > u(1);
+
+ xor_combine
+ <
+ minstd_rand, 1,
+ mt19937, 2
+ > v(2);
+
+ VERIFY( u != v );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
--- /dev/null
+// 2006-06-19 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 5.1.4.6 class template xor_combine [tr.rand.eng.xor]
+// 5.1.1 Table 16
+
+#include <sstream>
+#include <tr1/random>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+ using std::tr1::xor_combine;
+ using std::tr1::minstd_rand;
+ using std::tr1::mt19937;
+
+ std::stringstream str;
+ xor_combine
+ <
+ minstd_rand, 1,
+ mt19937, 2
+ > u, v;
+
+ u(); // advance
+ str << u;
+
+ VERIFY( u != v );
+
+ str >> v;
+ VERIFY( u == v );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}