From e192376912cefa1c207e633388b0be1e6d95d2df Mon Sep 17 00:00:00 2001 From: Edward Smith-Rowland <3dw4rd@verizon.net> Date: Fri, 14 Aug 2009 23:33:27 +0000 Subject: [PATCH] re PR libstdc++/41061 (Compile of program using std random fails.) 2009-08-14 Edward Smith-Rowland <3dw4rd@verizon.net> Paolo Carlini PR libstdc++/41061 * include/bits/random.h (operator<<(std::basic_ostream<>&, const std::lognormal_distribution<>&), operator>>(std::basic_istream<>&, std::lognormal_distribution<>&), operator<<(std::basic_ostream<>&, const std::gamma_distribution<>&), operator>>(std::basic_istream<>&, std::gamma_distribution<>&), operator<<(std::basic_ostream<>&, const std::chi_squared_distribution<>&), operator>>(std::basic_istream<>&, std::chi_squared_distribution<>&), operator<<(std::basic_ostream<>&, const std::fisher_f_distribution<>&), operator>>(std::basic_istream<>&, std::fisher_f_distribution<>&), operator<<(std::basic_ostream<>&, const std::student_t_distribution<>&), operator>>(std::basic_istream<>&, std::student_t_distribution<>&), operator<<(std::basic_ostream<>&, const std::negative_binomial_distribution<>&)): Declare friend. * testsuite/26_numerics/random/uniform_real_distribution/operators/ serialize.cc: New. * testsuite/26_numerics/random/piecewise_constant_distribution/ operators/serialize.cc: Likewise. * testsuite/26_numerics/random/chi_squared_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/normal_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/uniform_int_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/poisson_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/bernoulli_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/discrete_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/weibull_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/negative_binomial_distribution/ operators/serialize.cc: Likewise. * testsuite/26_numerics/random/cauchy_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/gamma_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/fisher_f_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/exponential_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/lognormal_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/binomial_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/extreme_value_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/piecewise_linear_distribution/ operators/serialize.cc * testsuite/26_numerics/random/student_t_distribution/operators/ serialize.cc: Likewise. * testsuite/26_numerics/random/geometric_distribution/operators/ serialize.cc: Likewise. Co-Authored-By: Paolo Carlini From-SVN: r150783 --- libstdc++-v3/ChangeLog | 64 +++- libstdc++-v3/include/bits/random.h | 360 +++++++++--------- .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 47 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 47 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 46 +++ .../gamma_distribution/operators/serialize.cc | 46 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 47 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 50 +++ .../operators/serialize.cc | 50 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 46 +++ .../operators/serialize.cc | 46 +++ 22 files changed, 1174 insertions(+), 181 deletions(-) create mode 100644 libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/serialize.cc create mode 100644 libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/serialize.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a48eb055c7a7..cde0934b3bf0 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,6 +1,68 @@ +2009-08-14 Edward Smith-Rowland <3dw4rd@verizon.net> + Paolo Carlini + + PR libstdc++/41061 + * include/bits/random.h (operator<<(std::basic_ostream<>&, + const std::lognormal_distribution<>&), + operator>>(std::basic_istream<>&, std::lognormal_distribution<>&), + operator<<(std::basic_ostream<>&, const std::gamma_distribution<>&), + operator>>(std::basic_istream<>&, std::gamma_distribution<>&), + operator<<(std::basic_ostream<>&, + const std::chi_squared_distribution<>&), + operator>>(std::basic_istream<>&, std::chi_squared_distribution<>&), + operator<<(std::basic_ostream<>&, + const std::fisher_f_distribution<>&), + operator>>(std::basic_istream<>&, std::fisher_f_distribution<>&), + operator<<(std::basic_ostream<>&, + const std::student_t_distribution<>&), + operator>>(std::basic_istream<>&, std::student_t_distribution<>&), + operator<<(std::basic_ostream<>&, + const std::negative_binomial_distribution<>&)): Declare friend. + * testsuite/26_numerics/random/uniform_real_distribution/operators/ + serialize.cc: New. + * testsuite/26_numerics/random/piecewise_constant_distribution/ + operators/serialize.cc: Likewise. + * testsuite/26_numerics/random/chi_squared_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/normal_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/uniform_int_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/poisson_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/bernoulli_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/discrete_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/weibull_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/negative_binomial_distribution/ + operators/serialize.cc: Likewise. + * testsuite/26_numerics/random/cauchy_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/gamma_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/fisher_f_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/exponential_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/lognormal_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/binomial_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/extreme_value_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/piecewise_linear_distribution/ + operators/serialize.cc + * testsuite/26_numerics/random/student_t_distribution/operators/ + serialize.cc: Likewise. + * testsuite/26_numerics/random/geometric_distribution/operators/ + serialize.cc: Likewise. + 2009-08-14 Edward Smith-Rowland <3dw4rd@verizon.net> - * include/bits/stl_tree.h: Make erase return iterator as per DR 130. + * include/bits/stl_tree.h: In C++0x mode make erase return + an iterator as per DR 130. * include/bits/stl_set.h: Same. * include/bits/stl_multiset.h: Same. * include/bits/stl_map.h: Same. diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index aa34fccf2482..06aa6f87b916 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -2039,42 +2039,42 @@ namespace std const param_type& __p) { return std::exp(__p.s() * _M_nd(__urng) + __p.m()); } + /** + * @brief Inserts a %lognormal_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %lognormal_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::lognormal_distribution<_RealType1>&); + + /** + * @brief Extracts a %lognormal_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %lognormal_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::lognormal_distribution<_RealType1>&); + private: param_type _M_param; std::normal_distribution _M_nd; }; - /** - * @brief Inserts a %lognormal_distribution random number distribution - * @p __x into the output stream @p __os. - * - * @param __os An output stream. - * @param __x A %lognormal_distribution random number distribution. - * - * @returns The output stream with the state of @p __x inserted or in - * an error state. - */ - template - std::basic_ostream<_CharT, _Traits>& - operator<<(std::basic_ostream<_CharT, _Traits>&, - const std::lognormal_distribution<_RealType>&); - - /** - * @brief Extracts a %lognormal_distribution random number distribution - * @p __x from the input stream @p __is. - * - * @param __is An input stream. - * @param __x A %lognormal_distribution random number - * generator engine. - * - * @returns The input stream with @p __x extracted or in an error state. - */ - template - std::basic_istream<_CharT, _Traits>& - operator>>(std::basic_istream<_CharT, _Traits>&, - std::lognormal_distribution<_RealType>&); - /** * @brief A gamma continuous distribution for random numbers. @@ -2198,41 +2198,41 @@ namespace std operator()(_UniformRandomNumberGenerator& __urng, const param_type& __p); + /** + * @brief Inserts a %gamma_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %gamma_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::gamma_distribution<_RealType1>&); + + /** + * @brief Extracts a %gamma_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %gamma_distribution random number generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::gamma_distribution<_RealType1>&); + private: param_type _M_param; std::normal_distribution _M_nd; }; - /** - * @brief Inserts a %gamma_distribution random number distribution - * @p __x into the output stream @p __os. - * - * @param __os An output stream. - * @param __x A %gamma_distribution random number distribution. - * - * @returns The output stream with the state of @p __x inserted or in - * an error state. - */ - template - std::basic_ostream<_CharT, _Traits>& - operator<<(std::basic_ostream<_CharT, _Traits>&, - const std::gamma_distribution<_RealType>&); - - /** - * @brief Extracts a %gamma_distribution random number distribution - * @p __x from the input stream @p __is. - * - * @param __is An input stream. - * @param __x A %gamma_distribution random number generator engine. - * - * @returns The input stream with @p __x extracted or in an error state. - */ - template - std::basic_istream<_CharT, _Traits>& - operator>>(std::basic_istream<_CharT, _Traits>&, - std::gamma_distribution<_RealType>&); - /** * @brief A chi_squared_distribution random number distribution. @@ -2332,42 +2332,42 @@ namespace std return 2 * _M_gd(__urng, param_type(__p.n() / 2)); } + /** + * @brief Inserts a %chi_squared_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %chi_squared_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::chi_squared_distribution<_RealType1>&); + + /** + * @brief Extracts a %chi_squared_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %chi_squared_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::chi_squared_distribution<_RealType1>&); + private: param_type _M_param; std::gamma_distribution _M_gd; }; - /** - * @brief Inserts a %chi_squared_distribution random number distribution - * @p __x into the output stream @p __os. - * - * @param __os An output stream. - * @param __x A %chi_squared_distribution random number distribution. - * - * @returns The output stream with the state of @p __x inserted or in - * an error state. - */ - template - std::basic_ostream<_CharT, _Traits>& - operator<<(std::basic_ostream<_CharT, _Traits>&, - const std::chi_squared_distribution<_RealType>&); - - /** - * @brief Extracts a %chi_squared_distribution random number distribution - * @p __x from the input stream @p __is. - * - * @param __is An input stream. - * @param __x A %chi_squared_distribution random number - * generator engine. - * - * @returns The input stream with @p __x extracted or in an error state. - */ - template - std::basic_istream<_CharT, _Traits>& - operator>>(std::basic_istream<_CharT, _Traits>&, - std::chi_squared_distribution<_RealType>&); - /** * @brief A cauchy_distribution random number distribution. @@ -2623,42 +2623,42 @@ namespace std / (_M_gd_y(__urng, param_type(__p.n() / 2)) * m())); } + /** + * @brief Inserts a %fisher_f_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %fisher_f_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::fisher_f_distribution<_RealType1>&); + + /** + * @brief Extracts a %fisher_f_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %fisher_f_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::fisher_f_distribution<_RealType1>&); + private: param_type _M_param; std::gamma_distribution _M_gd_x, _M_gd_y; }; - /** - * @brief Inserts a %fisher_f_distribution random number distribution - * @p __x into the output stream @p __os. - * - * @param __os An output stream. - * @param __x A %fisher_f_distribution random number distribution. - * - * @returns The output stream with the state of @p __x inserted or in - * an error state. - */ - template - std::basic_ostream<_CharT, _Traits>& - operator<<(std::basic_ostream<_CharT, _Traits>&, - const std::fisher_f_distribution<_RealType>&); - - /** - * @brief Extracts a %fisher_f_distribution random number distribution - * @p __x from the input stream @p __is. - * - * @param __is An input stream. - * @param __x A %fisher_f_distribution random number - * generator engine. - * - * @returns The input stream with @p __x extracted or in an error state. - */ - template - std::basic_istream<_CharT, _Traits>& - operator>>(std::basic_istream<_CharT, _Traits>&, - std::fisher_f_distribution<_RealType>&); - /** * @brief A student_t_distribution random number distribution. @@ -2764,6 +2764,36 @@ namespace std return _M_nd(__urng) * std::sqrt(__p.n() / __g); } + /** + * @brief Inserts a %student_t_distribution random number distribution + * @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %student_t_distribution random number distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::student_t_distribution<_RealType1>&); + + /** + * @brief Extracts a %student_t_distribution random number distribution + * @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %student_t_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::student_t_distribution<_RealType1>&); + private: param_type _M_param; @@ -2771,36 +2801,6 @@ namespace std std::gamma_distribution _M_gd; }; - /** - * @brief Inserts a %student_t_distribution random number distribution - * @p __x into the output stream @p __os. - * - * @param __os An output stream. - * @param __x A %student_t_distribution random number distribution. - * - * @returns The output stream with the state of @p __x inserted or in - * an error state. - */ - template - std::basic_ostream<_CharT, _Traits>& - operator<<(std::basic_ostream<_CharT, _Traits>&, - const std::student_t_distribution<_RealType>&); - - /** - * @brief Extracts a %student_t_distribution random number distribution - * @p __x from the input stream @p __is. - * - * @param __is An input stream. - * @param __x A %student_t_distribution random number - * generator engine. - * - * @returns The input stream with @p __x extracted or in an error state. - */ - template - std::basic_istream<_CharT, _Traits>& - operator>>(std::basic_istream<_CharT, _Traits>&, - std::student_t_distribution<_RealType>&); - /* @} */ // group std_random_distributions_normal /** @@ -3384,43 +3384,43 @@ namespace std operator()(_UniformRandomNumberGenerator& __urng, const param_type& __p); + /** + * @brief Inserts a %negative_binomial_distribution random + * number distribution @p __x into the output stream @p __os. + * + * @param __os An output stream. + * @param __x A %negative_binomial_distribution random number + * distribution. + * + * @returns The output stream with the state of @p __x inserted or in + * an error state. + */ + template + friend std::basic_ostream<_CharT, _Traits>& + operator<<(std::basic_ostream<_CharT, _Traits>&, + const std::negative_binomial_distribution<_IntType1>&); + + /** + * @brief Extracts a %negative_binomial_distribution random number + * distribution @p __x from the input stream @p __is. + * + * @param __is An input stream. + * @param __x A %negative_binomial_distribution random number + * generator engine. + * + * @returns The input stream with @p __x extracted or in an error state. + */ + template + friend std::basic_istream<_CharT, _Traits>& + operator>>(std::basic_istream<_CharT, _Traits>&, + std::negative_binomial_distribution<_IntType1>&); + private: param_type _M_param; std::gamma_distribution _M_gd; }; - /** - * @brief Inserts a %negative_binomial_distribution random - * number distribution @p __x into the output stream @p __os. - * - * @param __os An output stream. - * @param __x A %negative_binomial_distribution random number - * distribution. - * - * @returns The output stream with the state of @p __x inserted or in - * an error state. - */ - template - std::basic_ostream<_CharT, _Traits>& - operator<<(std::basic_ostream<_CharT, _Traits>&, - const std::negative_binomial_distribution<_IntType>&); - - /** - * @brief Extracts a %negative_binomial_distribution random number - * distribution @p __x from the input stream @p __is. - * - * @param __is An input stream. - * @param __x A %negative_binomial_distribution random number - * generator engine. - * - * @returns The input stream with @p __x extracted or in an error state. - */ - template - std::basic_istream<_CharT, _Traits>& - operator>>(std::basic_istream<_CharT, _Traits>&, - std::negative_binomial_distribution<_IntType>&); - /* @} */ // group std_random_distributions_bernoulli /** diff --git a/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/serialize.cc new file mode 100644 index 000000000000..3677ba7dd615 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/bernoulli_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.2.1 Class template bernoulli_distribution [rand.dist.bern.bernoulli] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::bernoulli_distribution u(0.75), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/serialize.cc new file mode 100644 index 000000000000..fb65018b93f8 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/binomial_distribution/operators/serialize.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.2.2 Class template binomial_distribution [rand.dist.bern.bin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include +#include + +void +test01() +{ + std::stringstream str; + std::binomial_distribution u(3, 0.75), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/serialize.cc new file mode 100644 index 000000000000..fd0d5f9db568 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/cauchy_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.4.1 class template discard_block_engine [rand.adapt.disc] +// 26.4.2.3 concept RandomNumberEngineAdaptor [rand.concept.adapt] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::cauchy_distribution u(5.0, 2.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/serialize.cc new file mode 100644 index 000000000000..146eeae51576 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/chi_squared_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.4.3 Class template chi_squared_distribution [rand.dist.norm.chisq] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::chi_squared_distribution u(1.5), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/serialize.cc new file mode 100644 index 000000000000..c2ba51a1282e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/operators/serialize.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.5.1 Class template discrete_distribution [rand.dist.samp.discrete] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::vector wt = {0.5, 1.0, 2.5, 1.5, 0.5}; + std::discrete_distribution u(wt.begin(), wt.end()), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/serialize.cc new file mode 100644 index 000000000000..d1dca74c6244 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/exponential_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.3.2 Class template exponential_distribution [rand.dist.pois.exp] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::exponential_distribution u(0.5), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/serialize.cc new file mode 100644 index 000000000000..2f68409b995b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/extreme_value_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.3.5 Class template extreme_value_distribution [rand.dist.pois.extreme] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::extreme_value_distribution u, v(5.0, 2.0); + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/serialize.cc new file mode 100644 index 000000000000..52640f3fc3a3 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/fisher_f_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.4.5 Class template fisher_f_distribution [rand.dist.norm.f] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::fisher_f_distribution u(2.0, 3.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/serialize.cc new file mode 100644 index 000000000000..0c24b7a5b008 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/gamma_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.3.3 Class template gamma_distribution [rand.dist.pois.gamma] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::gamma_distribution u(1.5, 3.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/serialize.cc new file mode 100644 index 000000000000..75de1b88caed --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/geometric_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.2.3 Class template geometric_distribution [rand.dist.bern.geom] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::geometric_distribution u(0.75), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/serialize.cc new file mode 100644 index 000000000000..877b6aab5483 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/lognormal_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.4.2 Class template lognormal_distribution [rand.dist.norm.lognormal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::lognormal_distribution u(5.0, 2.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/serialize.cc new file mode 100644 index 000000000000..7320f52240e7 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/negative_binomial_distribution/operators/serialize.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.2.4 Class template negative_binomial_distribution +// [rand.dist.bern.negbin] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::negative_binomial_distribution u(3, 0.75), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/serialize.cc new file mode 100644 index 000000000000..c88e0a19b308 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/normal_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.4.1 Class template normal_distribution [rand.dist.norm.normal] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::normal_distribution u(5.0, 2.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/serialize.cc new file mode 100644 index 000000000000..e1136796d6e6 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/serialize.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.5.2 Class template piecewise_constant_distribution +// [rand.dist.samp.pconst] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::vector x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + std::vector wt = {0.5, 1.0, 2.5, 1.5, 0.5}; + std::piecewise_constant_distribution + u(x.begin(), x.end(), wt.begin()), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize.cc new file mode 100644 index 000000000000..75ea5a7005f1 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.5.3 Class template piecewise_linear_distribution +// [rand.dist.samp.plinear] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::vector x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + std::vector wt = {0.0, 1.0, 2.5, 1.5, 0.5, 0.0}; + std::piecewise_linear_distribution + u(x.begin(), x.end(), wt.begin()), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/serialize.cc new file mode 100644 index 000000000000..315e309dbe72 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/poisson_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.3.1 Class template poisson_distribution [rand.dist.pois.poisson] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::poisson_distribution u(5.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/serialize.cc new file mode 100644 index 000000000000..d4144702a025 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/student_t_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.4.6 Class template student_t_distribution [rand.dist.norm.t] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::student_t_distribution u(1.5), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/serialize.cc new file mode 100644 index 000000000000..6ae080957f39 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_int_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.1.1 Class template uniform_int_distribution [rand.dist_uni] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::uniform_int_distribution u(1, 20), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/serialize.cc new file mode 100644 index 000000000000..a6ef0f490408 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/uniform_real_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.1.2 Class template uniform_real_distribution [rand.dist.uni.real] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::uniform_real_distribution u(-5.0, 5.0), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/serialize.cc b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/serialize.cc new file mode 100644 index 000000000000..7867023641da --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/random/weibull_distribution/operators/serialize.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=c++0x" } +// { dg-require-cstdint "" } +// +// 2009-08-14 Edward M. Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 2009 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 3, 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 COPYING3. If not see +// . + +// 26.4.8.3.4 Class template weibull_distribution [rand.dist.pois.weibull] +// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist] + +#include +#include + +void +test01() +{ + std::stringstream str; + std::weibull_distribution u(2.0, 3.5), v; + std::minstd_rand0 rng; + + u(rng); // advance + str << u; + + str >> v; +} + +int main() +{ + test01(); + return 0; +}