re PR libstdc++/41061 (Compile of program using std random fails.)

2009-08-14  Edward Smith-Rowland  <3dw4rd@verizon.net>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	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 <paolo.carlini@oracle.com>

From-SVN: r150783
This commit is contained in:
Edward Smith-Rowland 2009-08-14 23:33:27 +00:00 committed by Paolo Carlini
parent a2a0778d2d
commit e192376912
22 changed files with 1174 additions and 181 deletions

View File

@ -1,6 +1,68 @@
2009-08-14 Edward Smith-Rowland <3dw4rd@verizon.net>
Paolo Carlini <paolo.carlini@oracle.com>
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.

View File

@ -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<typename _RealType1, typename _CharT, typename _Traits>
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<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
std::lognormal_distribution<_RealType1>&);
private:
param_type _M_param;
std::normal_distribution<result_type> _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<typename _RealType, typename _CharT, typename _Traits>
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<typename _RealType, typename _CharT, typename _Traits>
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<typename _RealType1, typename _CharT, typename _Traits>
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<typename _RealType1, typename _CharT, typename _Traits>
friend std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
std::gamma_distribution<_RealType1>&);
private:
param_type _M_param;
std::normal_distribution<result_type> _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<typename _RealType, typename _CharT, typename _Traits>
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<typename _RealType, typename _CharT, typename _Traits>
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<typename _RealType1, typename _CharT, typename _Traits>
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<typename _RealType1, typename _CharT, typename _Traits>
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<result_type> _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<typename _RealType, typename _CharT, typename _Traits>
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<typename _RealType, typename _CharT, typename _Traits>
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<typename _RealType1, typename _CharT, typename _Traits>
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<typename _RealType1, typename _CharT, typename _Traits>
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<result_type> _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<typename _RealType, typename _CharT, typename _Traits>
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<typename _RealType, typename _CharT, typename _Traits>
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<typename _RealType1, typename _CharT, typename _Traits>
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<typename _RealType1, typename _CharT, typename _Traits>
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<result_type> _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<typename _RealType, typename _CharT, typename _Traits>
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<typename _RealType, typename _CharT, typename _Traits>
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<typename _IntType1, typename _CharT, typename _Traits>
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<typename _IntType1, typename _CharT, typename _Traits>
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<double> _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<typename _IntType, typename _CharT, typename _Traits>
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<typename _IntType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>&,
std::negative_binomial_distribution<_IntType>&);
/* @} */ // group std_random_distributions_bernoulli
/**

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.2.1 Class template bernoulli_distribution [rand.dist.bern.bernoulli]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
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;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.2.2 Class template binomial_distribution [rand.dist.bern.bin]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
#include <testsuite_hooks.h>
void
test01()
{
std::stringstream str;
std::binomial_distribution<int> u(3, 0.75), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.4.1 class template discard_block_engine [rand.adapt.disc]
// 26.4.2.3 concept RandomNumberEngineAdaptor [rand.concept.adapt]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::cauchy_distribution<double> u(5.0, 2.0), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.4.3 Class template chi_squared_distribution [rand.dist.norm.chisq]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::chi_squared_distribution<double> u(1.5), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.5.1 Class template discrete_distribution [rand.dist.samp.discrete]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::vector<double> wt = {0.5, 1.0, 2.5, 1.5, 0.5};
std::discrete_distribution<int> u(wt.begin(), wt.end()), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.3.2 Class template exponential_distribution [rand.dist.pois.exp]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::exponential_distribution<double> u(0.5), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.3.5 Class template extreme_value_distribution [rand.dist.pois.extreme]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::extreme_value_distribution<double> u, v(5.0, 2.0);
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.4.5 Class template fisher_f_distribution [rand.dist.norm.f]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::fisher_f_distribution<double> u(2.0, 3.0), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.3.3 Class template gamma_distribution [rand.dist.pois.gamma]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::gamma_distribution<double> u(1.5, 3.0), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.2.3 Class template geometric_distribution [rand.dist.bern.geom]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::geometric_distribution<int> u(0.75), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.4.2 Class template lognormal_distribution [rand.dist.norm.lognormal]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::lognormal_distribution<double> u(5.0, 2.0), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.2.4 Class template negative_binomial_distribution
// [rand.dist.bern.negbin]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::negative_binomial_distribution<int> u(3, 0.75), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.4.1 Class template normal_distribution [rand.dist.norm.normal]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::normal_distribution<double> u(5.0, 2.0), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.5.2 Class template piecewise_constant_distribution
// [rand.dist.samp.pconst]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::vector<double> x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
std::vector<double> wt = {0.5, 1.0, 2.5, 1.5, 0.5};
std::piecewise_constant_distribution<double>
u(x.begin(), x.end(), wt.begin()), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.5.3 Class template piecewise_linear_distribution
// [rand.dist.samp.plinear]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::vector<double> x = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
std::vector<double> wt = {0.0, 1.0, 2.5, 1.5, 0.5, 0.0};
std::piecewise_linear_distribution<double>
u(x.begin(), x.end(), wt.begin()), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.3.1 Class template poisson_distribution [rand.dist.pois.poisson]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::poisson_distribution<int> u(5.0), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.4.6 Class template student_t_distribution [rand.dist.norm.t]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::student_t_distribution<double> u(1.5), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.1.1 Class template uniform_int_distribution [rand.dist_uni]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::uniform_int_distribution<int> u(1, 20), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.1.2 Class template uniform_real_distribution [rand.dist.uni.real]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::uniform_real_distribution<double> u(-5.0, 5.0), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
// 26.4.8.3.4 Class template weibull_distribution [rand.dist.pois.weibull]
// 26.4.2.4 Concept RandomNumberDistribution [rand.concept.dist]
#include <random>
#include <sstream>
void
test01()
{
std::stringstream str;
std::weibull_distribution<double> u(2.0, 3.5), v;
std::minstd_rand0 rng;
u(rng); // advance
str << u;
str >> v;
}
int main()
{
test01();
return 0;
}