From d7d01132954e05ba41137195f26a265e7e255e6a Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Mon, 17 May 2010 21:55:46 +0000 Subject: [PATCH] [rand.dist.norm.cauchy]. I'm having trouble testing the output as all statistical properties are undefined. They do not converge upon any one value as the number of samples increases. Suggestions for tests welcome. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@103983 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/random | 174 +++++++++++++++++- .../rand.dist.norm.cauchy/assign.pass.cpp | 34 ++++ .../rand.dist.norm.cauchy/copy.pass.cpp | 32 ++++ .../ctor_double_double.pass.cpp | 40 ++++ .../rand.dist.norm.cauchy/ctor_param.pass.cpp | 30 +++ .../rand.dist.norm.cauchy/eq.pass.cpp | 37 ++++ .../rand.dist.norm.cauchy/eval.pass.cpp | 30 +++ .../rand.dist.norm.cauchy/eval_param.pass.cpp | 31 ++++ .../rand.dist.norm.cauchy/get_param.pass.cpp | 29 +++ .../rand.dist.norm.cauchy/io.pass.cpp | 41 +++++ .../rand.dist.norm.cauchy/max.pass.cpp | 28 +++ .../rand.dist.norm.cauchy/min.pass.cpp | 27 +++ .../param_assign.pass.cpp | 32 ++++ .../rand.dist.norm.cauchy/param_copy.pass.cpp | 31 ++++ .../rand.dist.norm.cauchy/param_ctor.pass.cpp | 44 +++++ .../rand.dist.norm.cauchy/param_eq.pass.cpp | 37 ++++ .../param_types.pass.cpp | 28 +++ .../rand.dist.norm.cauchy/set_param.pass.cpp | 30 +++ .../rand.dist.norm.cauchy/types.pass.cpp | 34 ++++ 19 files changed, 767 insertions(+), 2 deletions(-) create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp create mode 100644 test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp diff --git a/include/random b/include/random index a1278fe1d..c1734146d 100644 --- a/include/random +++ b/include/random @@ -1219,7 +1219,6 @@ public: result_type min() const; result_type max() const; - friend bool operator==(const chi_squared_distribution& x, const chi_squared_distribution& y); friend bool operator!=(const chi_squared_distribution& x, @@ -1239,7 +1238,62 @@ public: }; template - class cauchy_distribution; +class cauchy_distribution +{ +public: + // types + typedef RealType result_type; + + class param_type + { + public: + typedef cauchy_distribution distribution_type; + + explicit param_type(result_type a = 0, result_type b = 1); + + result_type a() const; + result_type b() 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 cauchy_distribution(result_type a = 0, result_type b = 1); + explicit cauchy_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 a() const; + result_type b() const; + + param_type param() const; + void param(const param_type& parm); + + result_type min() const; + result_type max() const; + + friend bool operator==(const cauchy_distribution& x, + const cauchy_distribution& y); + friend bool operator!=(const cauchy_distribution& x, + const cauchy_distribution& y); + + template + friend + basic_ostream& + operator<<(basic_ostream& os, + const cauchy_distribution& x); + + template + friend + basic_istream& + operator>>(basic_istream& is, + cauchy_distribution& x); +}; template class fisher_f_distribution; @@ -4807,6 +4861,122 @@ operator>>(basic_istream<_CharT, _Traits>& __is, return __is; } +// cauchy_distribution + +template +class cauchy_distribution +{ +public: + // types + typedef _RealType result_type; + + class param_type + { + result_type __a_; + result_type __b_; + public: + typedef cauchy_distribution distribution_type; + + explicit param_type(result_type __a = 0, result_type __b = 1) + : __a_(__a), __b_(__b) {} + + result_type a() const {return __a_;} + result_type b() const {return __b_;} + + friend bool operator==(const param_type& __x, const param_type& __y) + {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} + friend bool operator!=(const param_type& __x, const param_type& __y) + {return !(__x == __y);} + }; + +private: + param_type __p_; + +public: + // constructor and reset functions + explicit cauchy_distribution(result_type __a = 0, result_type __b = 1) + : __p_(param_type(__a, __b)) {} + explicit cauchy_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 + result_type a() const {return __p_.a();} + result_type b() const {return __p_.b();} + + param_type param() const {return __p_;} + void param(const param_type& __p) {__p_ = __p;} + + result_type min() const {return -numeric_limits::infinity();} + result_type max() const {return numeric_limits::infinity();} + + friend bool operator==(const cauchy_distribution& __x, + const cauchy_distribution& __y) + {return __x.__p_ == __y.__p_;} + friend bool operator!=(const cauchy_distribution& __x, + const cauchy_distribution& __y) + {return !(__x == __y);} + + template + friend + basic_ostream<_CharT, _Traits>& + operator<<(basic_ostream<_CharT, _Traits>& __os, + const cauchy_distribution<_RT>& __x); + + template + friend + basic_istream<_CharT, _Traits>& + operator>>(basic_istream<_CharT, _Traits>& __is, + cauchy_distribution<_RT>& __x); +}; + +template +template +inline +_RealType +cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) +{ + uniform_real_distribution __gen; + // purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite + return __p.a() + __p.b() * _STD::tan(3.1415926535897932384626433832795 * __gen(__g)); +} + +template +basic_ostream<_CharT, _Traits>& +operator<<(basic_ostream<_CharT, _Traits>& __os, + const cauchy_distribution<_RT>& __x) +{ + __save_flags<_CharT, _Traits> _(__os); + __os.flags(ios_base::dec | ios_base::left); + _CharT __sp = __os.widen(' '); + __os.fill(__sp); + __os << __x.a() << __sp << __x.b(); + return __os; +} + +template +basic_istream<_CharT, _Traits>& +operator>>(basic_istream<_CharT, _Traits>& __is, + cauchy_distribution<_RT>& __x) +{ + typedef cauchy_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 __a; + result_type __b; + __is >> __a >> __b; + if (!__is.fail()) + __x.param(param_type(__a, __b)); + return __is; +} + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_RANDOM diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp new file mode 100644 index 000000000..228fe9af2 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution + +// cauchy_distribution& operator=(const cauchy_distribution&); + +#include +#include + +void +test1() +{ + typedef std::cauchy_distribution<> D; + D d1(.5, 2); + 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.cauchy/copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp new file mode 100644 index 000000000..0b0803817 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution + +// cauchy_distribution(const cauchy_distribution&); + +#include +#include + +void +test1() +{ + typedef std::cauchy_distribution<> D; + D d1(.5, 1.75); + D d2 = d1; + assert(d1 == d2); +} + +int main() +{ + test1(); +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp new file mode 100644 index 000000000..a91fcac3f --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution + +// explicit cauchy_distribution(result_type a = 0, result_type b = 1); + +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + D d; + assert(d.a() == 0); + assert(d.b() == 1); + } + { + typedef std::cauchy_distribution<> D; + D d(14.5); + assert(d.a() == 14.5); + assert(d.b() == 1); + } + { + typedef std::cauchy_distribution<> D; + D d(14.5, 5.25); + assert(d.a() == 14.5); + assert(d.b() == 5.25); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp new file mode 100644 index 000000000..fc614641a --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_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 cauchy_distribution + +// explicit cauchy_distribution(const param_type& parm); + +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + typedef D::param_type P; + P p(0.25, 10); + D d(p); + assert(d.a() == 0.25); + assert(d.b() == 10); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp new file mode 100644 index 000000000..fb1706a11 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution + +// bool operator=(const cauchy_distribution& x, +// const cauchy_distribution& y); +// bool operator!(const cauchy_distribution& x, +// const cauchy_distribution& y); + +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + D d1(2.5, 4); + D d2(2.5, 4); + assert(d1 == d2); + } + { + typedef std::cauchy_distribution<> D; + D d1(2.5, 4); + D d2(2.5, 4.5); + assert(d1 != d2); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp new file mode 100644 index 000000000..3ab9d54ab --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.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 cauchy_distribution + +// template result_type operator()(_URNG& g); + +#include + +int main() +{ + typedef std::cauchy_distribution<> D; + typedef D::param_type P; + typedef std::mt19937 G; + G g; + D d(0.5, 2); + D::result_type v = d(g); + +// If anyone can figure out a better test than this, +// it would be more than welcome! +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp new file mode 100644 index 000000000..c9cdad49d --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.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 cauchy_distribution + +// template result_type operator()(_URNG& g, const param_type& parm); + +#include + +int main() +{ + typedef std::cauchy_distribution<> D; + typedef D::param_type P; + typedef std::mt19937 G; + G g; + D d(0.5, 2); + P p(3, 4); + D::result_type v = d(g, p); + +// If anyone can figure out a better test than this, +// it would be more than welcome! +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp new file mode 100644 index 000000000..229555a1a --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution + +// param_type param() const; + +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + typedef D::param_type P; + P p(.125, .5); + D d(p); + assert(d.param() == p); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp new file mode 100644 index 000000000..76f7c27d6 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution + +// template +// basic_ostream& +// operator<<(basic_ostream& os, +// const cauchy_distribution& x); + +// template +// basic_istream& +// operator>>(basic_istream& is, +// cauchy_distribution& x); + +#include +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + D d1(7.5, 5.5); + 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.cauchy/max.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp new file mode 100644 index 000000000..3c914aa0b --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution + +// result_type max() const; + +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + D d(5, .25); + D::result_type m = d.max(); + assert(m == INFINITY); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp new file mode 100644 index 000000000..3313eb339 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution + +// result_type min() const; + +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + D d(.5, .5); + assert(d.min() == -INFINITY); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp new file mode 100644 index 000000000..dd1b524fd --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.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 cauchy_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + typedef D::param_type param_type; + param_type p0(.75, 6); + param_type p; + p = p0; + assert(p.a() == .75); + assert(p.b() == 6); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp new file mode 100644 index 000000000..dc66d887e --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.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 cauchy_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + typedef D::param_type param_type; + param_type p0(10, .125); + param_type p = p0; + assert(p.a() == 10); + assert(p.b() == .125); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp new file mode 100644 index 000000000..076cd0829 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp @@ -0,0 +1,44 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class cauchy_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + typedef D::param_type param_type; + param_type p; + assert(p.a() == 0); + assert(p.b() == 1); + } + { + typedef std::cauchy_distribution<> D; + typedef D::param_type param_type; + param_type p(10); + assert(p.a() == 10); + assert(p.b() == 1); + } + { + typedef std::cauchy_distribution<> D; + typedef D::param_type param_type; + param_type p(10, 5); + assert(p.a() == 10); + assert(p.b() == 5); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp new file mode 100644 index 000000000..b8acc98b1 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution +// { +// class param_type; + +#include +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + typedef D::param_type param_type; + param_type p1(0.75, .5); + param_type p2(0.75, .5); + assert(p1 == p2); + } + { + typedef std::cauchy_distribution<> D; + typedef D::param_type param_type; + param_type p1(0.75, .5); + param_type p2(0.5, .5); + assert(p1 != p2); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp new file mode 100644 index 000000000..6ed11ecf0 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution +// { +// class param_type; + +#include +#include + +int main() +{ + { + typedef std::cauchy_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.cauchy/set_param.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp new file mode 100644 index 000000000..725c74452 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution; + +// void param(const param_type& parm); + +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + typedef D::param_type P; + P p(0.25, 5.5); + D d(0.75, 4); + d.param(p); + assert(d.param() == p); + } +} diff --git a/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp new file mode 100644 index 000000000..c631e4f78 --- /dev/null +++ b/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/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 cauchy_distribution +// { +// public: +// // types +// typedef RealType result_type; + +#include +#include + +int main() +{ + { + typedef std::cauchy_distribution<> D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } + { + typedef std::cauchy_distribution D; + typedef D::result_type result_type; + static_assert((std::is_same::value), ""); + } +}