From 321b4bb7ae50ef318c51ec58db550d7846c3edae Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Tue, 18 May 2010 20:08:04 +0000 Subject: [PATCH] [rand.dist.norm.t] git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@104052 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/random | 151 +++++++++++++++++- .../rand.dist.norm.t/assign.pass.cpp | 34 ++++ .../rand.dist.norm.t/copy.pass.cpp | 32 ++++ .../rand.dist.norm.t/ctor_double.pass.cpp | 32 ++++ .../rand.dist.norm.t/ctor_param.pass.cpp | 29 ++++ .../rand.dist.norm.t/eq.pass.cpp | 37 +++++ .../rand.dist.norm.t/eval.pass.cpp | 140 ++++++++++++++++ .../rand.dist.norm.t/eval_param.pass.cpp | 143 +++++++++++++++++ .../rand.dist.norm.t/get_param.pass.cpp | 29 ++++ .../rand.dist.norm.t/io.pass.cpp | 41 +++++ .../rand.dist.norm.t/max.pass.cpp | 28 ++++ .../rand.dist.norm.t/min.pass.cpp | 27 ++++ .../rand.dist.norm.t/param_assign.pass.cpp | 31 ++++ .../rand.dist.norm.t/param_copy.pass.cpp | 30 ++++ .../rand.dist.norm.t/param_ctor.pass.cpp | 35 ++++ .../rand.dist.norm.t/param_eq.pass.cpp | 37 +++++ .../rand.dist.norm.t/param_types.pass.cpp | 28 ++++ .../rand.dist.norm.t/set_param.pass.cpp | 30 ++++ .../rand.dist.norm.t/types.pass.cpp | 34 ++++ 19 files changed, 946 insertions(+), 2 deletions(-) create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp diff --git a/include/random b/include/random index f1ae33b3..6a3dcce7 100644 --- a/include/random +++ b/include/random @@ -1305,7 +1305,7 @@ public: class param_type { public: - typedef result_type distribution_type; + typedef fisher_f_distribution distribution_type; explicit param_type(result_type m = 1, result_type n = 1); @@ -1354,7 +1354,60 @@ public: }; template - class student_t_distribution; +class student_t_distribution +{ +public: + // types + typedef RealType result_type; + + class param_type + { + public: + typedef student_t_distribution distribution_type; + + explicit param_type(result_type n = 1); + + result_type n() const; + + friend bool operator==(const param_type& x, const param_type& y); + friend bool operator!=(const param_type& x, const param_type& y); + }; + + // constructor and reset functions + explicit student_t_distribution(result_type n = 1); + explicit student_t_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 + result_type n() const; + + param_type param() const; + void param(const param_type& parm); + + result_type min() const; + result_type max() const; + + friend bool operator==(const student_t_distribution& x, + const student_t_distribution& y); + friend bool operator!=(const student_t_distribution& x, + const student_t_distribution& y); + + template + friend + basic_ostream& + operator<<(basic_ostream& os, + const student_t_distribution& x); + + template + friend + basic_istream& + operator>>(basic_istream& is, + student_t_distribution& x); +}; template class discrete_distribution; @@ -5123,6 +5176,100 @@ operator>>(basic_istream<_CharT, _Traits>& __is, return __is; } +template +class student_t_distribution +{ +public: + // types + typedef _RealType result_type; + + class param_type + { + result_type __n_; + public: + typedef student_t_distribution distribution_type; + + explicit param_type(result_type __n = 1) : __n_(__n) {} + + result_type n() const {return __n_;} + + friend bool operator==(const param_type& __x, const param_type& __y) + {return __x.__n_ == __y.__n_;} + friend bool operator!=(const param_type& __x, const param_type& __y) + {return !(__x == __y);} + }; + +private: + param_type __p_; + normal_distribution __nd_; + +public: + // constructor and reset functions + explicit student_t_distribution(result_type __n = 1) + : __p_(param_type(__n)) {} + explicit student_t_distribution(const param_type& __p) + : __p_(__p) {} + void reset() {__nd_.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 + result_type n() const {return __p_.n();} + + param_type param() const {return __p_;} + void param(const param_type& __p) {return __p_ = __p;} + + result_type min() const {return -numeric_limits::infinity();} + result_type max() const {return numeric_limits::infinity();} + + friend bool operator==(const student_t_distribution& __x, + const student_t_distribution& __y) + {return __x.__p_ == __y.__p_;} + friend bool operator!=(const student_t_distribution& __x, + const student_t_distribution& __y) + {return !(__x == __y);} +}; + +template +template +_RealType +student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) +{ + gamma_distribution __gd(__p.n() * .5, 2); + return __nd_(__g) * _STD::sqrt(__p.n()/__gd(__g)); +} + +template +basic_ostream<_CharT, _Traits>& +operator<<(basic_ostream<_CharT, _Traits>& __os, + const student_t_distribution<_RT>& __x) +{ + __save_flags<_CharT, _Traits> _(__os); + __os.flags(ios_base::dec | ios_base::left); + __os << __x.n(); + return __os; +} + +template +basic_istream<_CharT, _Traits>& +operator>>(basic_istream<_CharT, _Traits>& __is, + student_t_distribution<_RT>& __x) +{ + typedef student_t_distribution<_RT> _Eng; + typedef typename _Eng::result_type result_type; + typedef typename _Eng::param_type param_type; + __save_flags<_CharT, _Traits> _(__is); + __is.flags(ios_base::dec | ios_base::skipws); + result_type __n; + __is >> __n; + if (!__is.fail()) + __x.param(param_type(__n)); + return __is; +} + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_RANDOM diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp new file mode 100644 index 00000000..5fcd0c90 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution + +// student_t_distribution& operator=(const student_t_distribution&); + +#include +#include + +void +test1() +{ + typedef std::student_t_distribution<> D; + D d1(20.75); + D d2; + assert(d1 != d2); + d2 = d1; + assert(d1 == d2); +} + +int main() +{ + test1(); +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp new file mode 100644 index 00000000..251ebd95 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution + +// student_t_distribution(const student_t_distribution&); + +#include +#include + +void +test1() +{ + typedef std::student_t_distribution<> D; + D d1(21.75); + D d2 = d1; + assert(d1 == d2); +} + +int main() +{ + test1(); +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp new file mode 100644 index 00000000..e032d41f --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution + +// explicit student_t_distribution(result_type alpha = 0, result_type beta = 1); + +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + D d; + assert(d.n() == 1); + } + { + typedef std::student_t_distribution<> D; + D d(14.5); + assert(d.n() == 14.5); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp new file mode 100644 index 00000000..f8555e87 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution + +// explicit student_t_distribution(const param_type& parm); + +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + typedef D::param_type P; + P p(0.25); + D d(p); + assert(d.n() == 0.25); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp new file mode 100644 index 00000000..088f1b10 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution + +// bool operator=(const student_t_distribution& x, +// const student_t_distribution& y); +// bool operator!(const student_t_distribution& x, +// const student_t_distribution& y); + +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + D d1(2.5); + D d2(2.5); + assert(d1 == d2); + } + { + typedef std::student_t_distribution<> D; + D d1(4); + D d2(4.5); + assert(d1 != d2); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp new file mode 100644 index 00000000..86ffd793 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp @@ -0,0 +1,140 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_distribution + +// template result_type operator()(_URNG& g); + +#include +#include +#include +#include + +template +inline +T +sqr(T x) +{ + return x * x; +} + +int main() +{ + { + typedef std::student_t_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d(5.5); + const int N = 1000000; + 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; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = 0; + double x_var = d.n() / (d.n() - 2); + double x_skew = 0; + double x_kurtosis = 6 / (d.n() - 4); + assert(std::abs(mean - x_mean) < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.2); + } + { + typedef std::student_t_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d(10); + const int N = 1000000; + 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; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = 0; + double x_var = d.n() / (d.n() - 2); + double x_skew = 0; + double x_kurtosis = 6 / (d.n() - 4); + assert(std::abs(mean - x_mean) < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.04); + } + { + typedef std::student_t_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d(100); + const int N = 1000000; + 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; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = 0; + double x_var = d.n() / (d.n() - 2); + double x_skew = 0; + double x_kurtosis = 6 / (d.n() - 4); + assert(std::abs(mean - x_mean) < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.02); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp new file mode 100644 index 00000000..18207701 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp @@ -0,0 +1,143 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class student_t_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::student_t_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d; + P p(5.5); + const int N = 1000000; + 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; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = 0; + double x_var = p.n() / (p.n() - 2); + double x_skew = 0; + double x_kurtosis = 6 / (p.n() - 4); + assert(std::abs(mean - x_mean) < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.2); + } + { + typedef std::student_t_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d; + P p(10); + const int N = 1000000; + 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; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = 0; + double x_var = p.n() / (p.n() - 2); + double x_skew = 0; + double x_kurtosis = 6 / (p.n() - 4); + assert(std::abs(mean - x_mean) < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.04); + } + { + typedef std::student_t_distribution<> D; + typedef D::param_type P; + typedef std::minstd_rand G; + G g; + D d; + P p(100); + const int N = 1000000; + 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; + double skew = 0; + double kurtosis = 0; + for (int i = 0; i < u.size(); ++i) + { + double d = (u[i] - mean); + double d2 = sqr(d); + var += d2; + skew += d * d2; + kurtosis += d2 * d2; + } + var /= u.size(); + double dev = std::sqrt(var); + skew /= u.size() * dev * var; + kurtosis /= u.size() * var * var; + kurtosis -= 3; + double x_mean = 0; + double x_var = p.n() / (p.n() - 2); + double x_skew = 0; + double x_kurtosis = 6 / (p.n() - 4); + assert(std::abs(mean - x_mean) < 0.01); + assert(std::abs(var - x_var) / x_var < 0.01); + assert(std::abs(skew - x_skew) < 0.01); + assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.02); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp new file mode 100644 index 00000000..5574c01e --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution + +// param_type param() const; + +#include +#include + +int main() +{ + { + typedef std::student_t_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.norm/rand.dist.norm.t/io.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp new file mode 100644 index 00000000..f2e0a3cb --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const student_t_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// student_t_distribution& x); + +#include +#include +#include + +int main() +{ + { + typedef std::student_t_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.norm/rand.dist.norm.t/max.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp new file mode 100644 index 00000000..1ada3be6 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution + +// result_type max() const; + +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + D d(5); + D::result_type m = d.max(); + assert(m == INFINITY); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp new file mode 100644 index 00000000..c9317c2f --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution + +// result_type min() const; + +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + D d(.5); + assert(d.min() == -INFINITY); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp new file mode 100644 index 00000000..8ee88c76 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + typedef D::param_type param_type; + param_type p0(.75); + param_type p; + p = p0; + assert(p.n() == .75); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp new file mode 100644 index 00000000..341c43f5 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + typedef D::param_type param_type; + param_type p0(10); + param_type p = p0; + assert(p.n() == 10); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp new file mode 100644 index 00000000..3a334dc1 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + typedef D::param_type param_type; + param_type p; + assert(p.n() == 1); + } + { + typedef std::student_t_distribution<> D; + typedef D::param_type param_type; + param_type p(10); + assert(p.n() == 10); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp new file mode 100644 index 00000000..2bee65e6 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + typedef D::param_type param_type; + param_type p1(0.75); + param_type p2(0.75); + assert(p1 == p2); + } + { + typedef std::student_t_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.norm/rand.dist.norm.t/param_types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp new file mode 100644 index 00000000..1ccad536 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution +// { +// class param_type; + +#include +#include + +int main() +{ + { + typedef std::student_t_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.norm/rand.dist.norm.t/set_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp new file mode 100644 index 00000000..be305851 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution; + +// void param(const param_type& parm); + +#include +#include + +int main() +{ + { + typedef std::student_t_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.norm/rand.dist.norm.t/types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp new file mode 100644 index 00000000..fb569dec --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/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 student_t_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::student_t_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::student_t_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } +}