diff --git a/include/random b/include/random index 948bb9aa9..4045574b7 100644 --- a/include/random +++ b/include/random @@ -672,7 +672,60 @@ template class negative_binomial_distribution; template - class poisson_distribution; +class poisson_distribution +{ +public: + // types + typedef IntType result_type; + + class param_type + { + public: + typedef poisson_distribution distribution_type; + + explicit param_type(double mean = 1.0); + + double mean() const; + + friend bool operator==(const param_type& x, const param_type& y); + friend bool operator!=(const param_type& x, const param_type& y); + }; + + // constructors and reset functions + explicit poisson_distribution(double mean = 1.0); + explicit poisson_distribution(const param_type& parm); + void reset(); + + // generating functions + template result_type operator()(URNG& g); + template result_type operator()(URNG& g, const param_type& parm); + + // property functions + double mean() const; + + param_type param() const; + void param(const param_type& parm); + + result_type min() const; + result_type max() const; + + friend bool operator==(const poisson_distribution& x, + const poisson_distribution& y); + friend bool operator!=(const poisson_distribution& x, + const poisson_distribution& y); + + template + friend + basic_ostream& + operator<<(basic_ostream& os, + const poisson_distribution& x); + + template + friend + basic_istream& + operator>>(basic_istream& is, + poisson_distribution& x); +}; template class exponential_distribution @@ -3181,6 +3234,149 @@ operator>>(basic_istream<_CharT, _Traits>& __is, return __is; } +// poisson_distribution + +template +class poisson_distribution +{ +public: + // types + typedef _IntType result_type; + + class param_type + { + double __mean_; + double __sq_; + double __alxm_; + double __g_; + public: + typedef poisson_distribution distribution_type; + + explicit param_type(double __mean = 1.0); + + double mean() const {return __mean_;} + + friend bool operator==(const param_type& __x, const param_type& __y) + {return __x.__mean_ == __y.__mean_;} + friend bool operator!=(const param_type& __x, const param_type& __y) + {return !(__x == __y);} + + friend class poisson_distribution; + }; + +private: + param_type __p_; + +public: + // constructors and reset functions + explicit poisson_distribution(double __mean = 1.0) : __p_(__mean) {} + explicit poisson_distribution(const param_type& __p) : __p_(__p) {} + void reset() {} + + // generating functions + template result_type operator()(_URNG& __g) + {return (*this)(__g, __p_);} + template result_type operator()(_URNG& __g, const param_type& __p); + + // property functions + double mean() const {return __p_.mean();} + + param_type param() const {return __p_;} + void param(const param_type& __p) {__p_ = __p;} + + result_type min() const {return 0;} + result_type max() const {return numeric_limits::max();} + + friend bool operator==(const poisson_distribution& __x, + const poisson_distribution& __y) + {return __x.__p_ == __y.__p_;} + friend bool operator!=(const poisson_distribution& __x, + const poisson_distribution& __y) + {return !(__x == __y);} +}; + +template +poisson_distribution<_IntType>::param_type::param_type(double __mean) + : __mean_(__mean) +{ + if (__mean_ < 12.0) + { + __g_ = _STD::exp(-__mean_); + __alxm_ = 0; + __sq_ = 0; + } + else + { + __sq_ = _STD::sqrt(2.0 * __mean_); + __alxm_ = _STD::log(__mean_); + __g_ = __mean_ * __alxm_ - _STD::lgamma(__mean_ + 1); + } +} + +template +template +_IntType +poisson_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p) +{ + result_type __x; + uniform_real_distribution __gen; + if (__p.__mean_ < 12.0) + { + __x = result_type(~0); + double __t = 1; + do + { + ++__x; + __t *= __gen(__g); + } while (__t > __p.__g_); + } + else + { + double __t; + const double __pi = 3.14159265358979323846264338328; + do + { + double _X; + double __y; + do + { + __y = _STD::tan(__pi * __gen(__g)); + _X = __p.__sq_ * __y + __p.__mean_; + } while (_X < 0); + __x = static_cast(_X); + __t = 0.9 * (1 + __y * __y) * _STD::exp(__x * __p.__alxm_ - + _STD::lgamma(__x + 1.0) - __p.__g_); + } while (__gen(__g) > __t); + } + return __x; +} + +template +basic_ostream<_CharT, _Traits>& +operator<<(basic_ostream<_CharT, _Traits>& __os, + const poisson_distribution<_IntType>& __x) +{ + __save_flags<_CharT, _Traits> _(__os); + __os.flags(ios_base::dec | ios_base::left); + return __os << __x.mean(); +} + +template +basic_istream<_CharT, _Traits>& +operator>>(basic_istream<_CharT, _Traits>& __is, + poisson_distribution<_IntType>& __x) +{ + typedef poisson_distribution<_IntType> _Eng; + typedef typename _Eng::param_type param_type; + __save_flags<_CharT, _Traits> _(__is); + __is.flags(ios_base::dec | ios_base::skipws); + double __mean; + __is >> __mean; + if (!__is.fail()) + __x.param(param_type(__mean)); + return __is; +} + // exponential_distribution template diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp new file mode 100644 index 000000000..51bb064a8 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// poisson_distribution& operator=(const poisson_distribution&); + +#include +#include + +void +test1() +{ + typedef std::poisson_distribution<> D; + D d1(0.75); + D d2; + assert(d1 != d2); + d2 = d1; + assert(d1 == d2); +} + +int main() +{ + test1(); +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp new file mode 100644 index 000000000..1b12f89df --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// poisson_distribution(const poisson_distribution&); + +#include +#include + +void +test1() +{ + typedef std::poisson_distribution<> D; + D d1(1.75); + D d2 = d1; + assert(d1 == d2); +} + +int main() +{ + test1(); +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp new file mode 100644 index 000000000..2a77e4e65 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// explicit poisson_distribution(RealType lambda = 1.0); + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + D d; + assert(d.mean() == 1); + } + { + typedef std::poisson_distribution<> D; + D d(3.5); + assert(d.mean() == 3.5); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp new file mode 100644 index 000000000..3494d84cd --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// explicit poisson_distribution(const param_type& parm); + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::param_type P; + P p(0.25); + D d(p); + assert(d.mean() == 0.25); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp new file mode 100644 index 000000000..7bd27f42e --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// bool operator=(const poisson_distribution& x, +// const poisson_distribution& y); +// bool operator!(const poisson_distribution& x, +// const poisson_distribution& y); + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + D d1(.25); + D d2(.25); + assert(d1 == d2); + } + { + typedef std::poisson_distribution<> D; + D d1(.28); + D d2(.25); + assert(d1 != d2); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp new file mode 100644 index 000000000..f03f8871d --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp @@ -0,0 +1,89 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +inline +T +sqr(T x) +{ + return x * x; +} + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef std::minstd_rand G; + G g; + D d(2); + const int N = 100000; + std::vector u; + for (int i = 0; i < N; ++i) + u.push_back(d(g)); + double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size(); + double var = 0; + for (int i = 0; i < u.size(); ++i) + var += sqr(u[i] - mean); + var /= u.size(); + double x_mean = d.mean(); + double x_var = d.mean(); + assert(std::abs(mean - x_mean) / x_mean < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + } + { + typedef std::poisson_distribution<> D; + typedef std::minstd_rand G; + G g; + D d(0.75); + const int N = 100000; + std::vector u; + for (int i = 0; i < N; ++i) + u.push_back(d(g)); + double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size(); + double var = 0; + for (int i = 0; i < u.size(); ++i) + var += sqr(u[i] - mean); + var /= u.size(); + double x_mean = d.mean(); + double x_var = d.mean(); + assert(std::abs(mean - x_mean) / x_mean < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + } + { + typedef std::poisson_distribution<> D; + typedef std::minstd_rand G; + G g; + D d(20); + const int N = 10000; + std::vector u; + for (int i = 0; i < N; ++i) + u.push_back(d(g)); + double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size(); + double var = 0; + for (int i = 0; i < u.size(); ++i) + var += sqr(u[i] - mean); + var /= u.size(); + double x_mean = d.mean(); + double x_var = d.mean(); + assert(std::abs(mean - x_mean) / x_mean < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp new file mode 100644 index 000000000..b7226a3fc --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include +#include +#include +#include + +template +inline +T +sqr(T x) +{ + return x * x; +} + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d(.75); + P p(2); + const int N = 100000; + std::vector u; + for (int i = 0; i < N; ++i) + u.push_back(d(g, p)); + double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size(); + double var = 0; + for (int i = 0; i < u.size(); ++i) + var += sqr(u[i] - mean); + var /= u.size(); + double x_mean = p.mean(); + double x_var = p.mean(); + assert(std::abs(mean - x_mean) / x_mean < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + } + { + typedef std::poisson_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d(2); + P p(.75); + const int N = 100000; + std::vector u; + for (int i = 0; i < N; ++i) + u.push_back(d(g, p)); + double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size(); + double var = 0; + for (int i = 0; i < u.size(); ++i) + var += sqr(u[i] - mean); + var /= u.size(); + double x_mean = p.mean(); + double x_var = p.mean(); + assert(std::abs(mean - x_mean) / x_mean < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + } + { + typedef std::poisson_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d(2); + P p(20); + const int N = 10000; + std::vector u; + for (int i = 0; i < N; ++i) + u.push_back(d(g, p)); + double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size(); + double var = 0; + for (int i = 0; i < u.size(); ++i) + var += sqr(u[i] - mean); + var /= u.size(); + double x_mean = p.mean(); + double x_var = p.mean(); + assert(std::abs(mean - x_mean) / x_mean < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp new file mode 100644 index 000000000..16e955bed --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// param_type param() const; + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::param_type P; + P p(.125); + D d(p); + assert(d.param() == p); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp new file mode 100644 index 000000000..845cb4df4 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const poisson_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// poisson_distribution& x); + +#include +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + D d1(7); + std::ostringstream os; + os << d1; + std::istringstream is(os.str()); + D d2; + is >> d2; + assert(d1 == d2); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp new file mode 100644 index 000000000..f1709777d --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// result_type max() const; + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + D d(.25); + D::result_type m = d.max(); + assert(m == std::numeric_limits::max()); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp new file mode 100644 index 000000000..852ddc2a4 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution + +// result_type min() const; + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + D d(.5); + assert(d.min() == 0); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp new file mode 100644 index 000000000..b6ba102a3 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::param_type param_type; + param_type p0(.7); + param_type p; + p = p0; + assert(p.mean() == .7); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp new file mode 100644 index 000000000..a47da699e --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::param_type param_type; + param_type p0(.125); + param_type p = p0; + assert(p.mean() == .125); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp new file mode 100644 index 000000000..68422c33d --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::param_type param_type; + param_type p; + assert(p.mean() == 1); + } + { + typedef std::poisson_distribution<> D; + typedef D::param_type param_type; + param_type p(10); + assert(p.mean() == 10); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp new file mode 100644 index 000000000..726eacf33 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::param_type param_type; + param_type p1(0.75); + param_type p2(0.75); + assert(p1 == p2); + } + { + typedef std::poisson_distribution<> D; + typedef D::param_type param_type; + param_type p1(0.75); + param_type p2(0.5); + assert(p1 != p2); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp new file mode 100644 index 000000000..2ef9c5bf1 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// class param_type; + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::param_type param_type; + typedef param_type::distribution_type distribution_type; + static_assert((std::is_same::value), ""); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp new file mode 100644 index 000000000..22b22c8c0 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution; + +// void param(const param_type& parm); + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::param_type P; + P p(0.25); + D d(0.75); + d.param(p); + assert(d.param() == p); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp new file mode 100644 index 000000000..639bb5673 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class poisson_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::poisson_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::poisson_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } +}