summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-05-18 17:32:30 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-05-18 17:32:30 +0000
commite31e36f9109a77fba5beffceedfa1f1172c669b6 (patch)
tree522eb1f7d7e24f05f653ea966a086dd62acde2af
parent4843178d6bd2083b88908ada581188c2b7aa226a (diff)
downloadbcm5719-llvm-e31e36f9109a77fba5beffceedfa1f1172c669b6.tar.gz
bcm5719-llvm-e31e36f9109a77fba5beffceedfa1f1172c669b6.zip
[rand.dist.norm.f]
llvm-svn: 104035
-rw-r--r--libcxx/include/chrono2
-rw-r--r--libcxx/include/cstddef8
-rw-r--r--libcxx/include/random172
-rw-r--r--libcxx/include/ratio2
-rw-r--r--libcxx/include/type_traits72
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp34
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp32
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp40
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp30
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp37
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp104
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp107
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp29
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp41
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp28
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp27
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp32
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp31
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp44
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp37
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp28
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp30
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp34
23 files changed, 946 insertions, 55 deletions
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 911a95ec72c..1c79c6840f3 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -264,7 +264,7 @@ namespace chrono
template <class _Rep, class _Period = ratio<1> > class duration;
-template <class T>
+template <class _Tp>
struct __is_duration : false_type {};
template <class _Rep, class _Period>
diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef
index c939f0ea915..11d07a2ec29 100644
--- a/libcxx/include/cstddef
+++ b/libcxx/include/cstddef
@@ -57,13 +57,13 @@ struct nullptr_t
_LIBCPP_ALWAYS_INLINE operator int __nat::*() const {return 0;}
- template <class T>
+ template <class _Tp>
_LIBCPP_ALWAYS_INLINE
- operator T* () const {return 0;}
+ operator _Tp* () const {return 0;}
- template <class T, class U>
+ template <class _Tp, class _Up>
_LIBCPP_ALWAYS_INLINE
- operator T U::* () const {return 0;}
+ operator _Tp _Up::* () const {return 0;}
friend _LIBCPP_ALWAYS_INLINE bool operator==(nullptr_t, nullptr_t) {return true;}
friend _LIBCPP_ALWAYS_INLINE bool operator!=(nullptr_t, nullptr_t) {return false;}
diff --git a/libcxx/include/random b/libcxx/include/random
index c1734146d1e..f1ae33b3b9d 100644
--- a/libcxx/include/random
+++ b/libcxx/include/random
@@ -1296,7 +1296,62 @@ public:
};
template<class RealType = double>
- class fisher_f_distribution;
+class fisher_f_distribution
+{
+public:
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef result_type distribution_type;
+
+ explicit param_type(result_type m = 1, result_type n = 1);
+
+ result_type m() const;
+ 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 fisher_f_distribution(result_type m = 1, result_type n = 1);
+ explicit fisher_f_distribution(const param_type& parm);
+ void reset();
+
+ // generating functions
+ template<class URNG> result_type operator()(URNG& g);
+ template<class URNG> result_type operator()(URNG& g, const param_type& parm);
+
+ // property functions
+ result_type m() const;
+ 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 fisher_f_distribution& x,
+ const fisher_f_distribution& y);
+ friend bool operator!=(const fisher_f_distribution& x,
+ const fisher_f_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const fisher_f_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ fisher_f_distribution& x);
+};
template<class RealType = double>
class student_t_distribution;
@@ -4921,18 +4976,6 @@ public:
friend bool operator!=(const cauchy_distribution& __x,
const cauchy_distribution& __y)
{return !(__x == __y);}
-
- template <class _CharT, class _Traits, class _RT>
- friend
- basic_ostream<_CharT, _Traits>&
- operator<<(basic_ostream<_CharT, _Traits>& __os,
- const cauchy_distribution<_RT>& __x);
-
- template <class _CharT, class _Traits, class _RT>
- friend
- basic_istream<_CharT, _Traits>&
- operator>>(basic_istream<_CharT, _Traits>& __is,
- cauchy_distribution<_RT>& __x);
};
template <class _RealType>
@@ -4977,6 +5020,109 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
return __is;
}
+// fisher_f_distribution
+
+template<class _RealType = double>
+class fisher_f_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class param_type
+ {
+ result_type __m_;
+ result_type __n_;
+ public:
+ typedef fisher_f_distribution distribution_type;
+
+ explicit param_type(result_type __m = 1, result_type __n = 1)
+ : __m_(__m), __n_(__n) {}
+
+ result_type m() const {return __m_;}
+ result_type n() const {return __n_;}
+
+ friend bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__m_ == __y.__m_ && __x.__n_ == __y.__n_;}
+ friend bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+ explicit fisher_f_distribution(result_type __m = 1, result_type __n = 1)
+ : __p_(param_type(__m, __n)) {}
+ explicit fisher_f_distribution(const param_type& __p)
+ : __p_(__p) {}
+ void reset() {}
+
+ // generating functions
+ template<class _URNG> result_type operator()(_URNG& __g)
+ {return (*this)(__g, __p_);}
+ template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p);
+
+ // property functions
+ result_type m() const {return __p_.m();}
+ result_type n() const {return __p_.n();}
+
+ 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<result_type>::infinity();}
+
+ friend bool operator==(const fisher_f_distribution& __x,
+ const fisher_f_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend bool operator!=(const fisher_f_distribution& __x,
+ const fisher_f_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _RealType>
+template<class _URNG>
+_RealType
+fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ gamma_distribution<result_type> __gdm(__p.m() * result_type(.5));
+ gamma_distribution<result_type> __gdn(__p.n() * result_type(.5));
+ return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g));
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const fisher_f_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.m() << __sp << __x.n();
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ fisher_f_distribution<_RT>& __x)
+{
+ typedef fisher_f_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 __m;
+ result_type __n;
+ __is >> __m >> __n;
+ if (!__is.fail())
+ __x.param(param_type(__m, __n));
+ return __is;
+}
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_RANDOM
diff --git a/libcxx/include/ratio b/libcxx/include/ratio
index 2d217c129b4..ca5be9cd963 100644
--- a/libcxx/include/ratio
+++ b/libcxx/include/ratio
@@ -239,7 +239,7 @@ public:
template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::num;
template <intmax_t _Num, intmax_t _Den> const intmax_t ratio<_Num, _Den>::den;
-template <class T> struct __is_ratio : false_type {};
+template <class _Tp> struct __is_ratio : false_type {};
template <intmax_t _Num, intmax_t _Den> struct __is_ratio<ratio<_Num, _Den> > : true_type {};
typedef ratio<1LL, 1000000000000000000LL> atto;
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index b838b17628c..37e97081598 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -395,7 +395,7 @@ template <class _Tp> struct add_volatile {typedef typename __add_volatile<_Tp>::
// add_cv
-template <class T> struct add_cv {typedef typename add_const<typename add_volatile<T>::type>::type type;};
+template <class _Tp> struct add_cv {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;};
// remove_reference
@@ -1154,86 +1154,86 @@ forward(_Up&& __t)
#else // _LIBCPP_MOVE
-template <class T>
+template <class _Tp>
class __rv
{
- typedef typename remove_reference<T>::type Trr;
- Trr& t_;
+ typedef typename remove_reference<_Tp>::type _Trr;
+ _Trr& t_;
public:
- Trr* operator->() {return &t_;}
- explicit __rv(Trr& t) : t_(t) {}
+ _Trr* operator->() {return &t_;}
+ explicit __rv(_Trr& __t) : t_(__t) {}
};
-template <class T>
+template <class _Tp>
inline
typename enable_if
<
- !is_convertible<T, __rv<T> >::value,
- T&
+ !is_convertible<_Tp, __rv<_Tp> >::value,
+ _Tp&
>::type
-move(T& t)
+move(_Tp& __t)
{
- return t;
+ return __t;
}
-template <class T>
+template <class _Tp>
inline
typename enable_if
<
- is_convertible<T, __rv<T> >::value,
- T
+ is_convertible<_Tp, __rv<_Tp> >::value,
+ _Tp
>::type
-move(T& t)
+move(_Tp& __t)
{
- return T(__rv<T>(t));
+ return _Tp(__rv<_Tp>(__t));
}
-template <class T, class U>
+template <class _Tp, class _Up>
inline
typename enable_if
<
- !is_convertible<T, __rv<T> >::value,
- typename add_lvalue_reference<T>::type
+ !is_convertible<_Tp, __rv<_Tp> >::value,
+ typename add_lvalue_reference<_Tp>::type
>::type
-forward(U& t)
+forward(_Up& __t)
{
- return t;
+ return __t;
}
-template <class T, class U>
+template <class _Tp, class _Up>
inline
typename enable_if
<
- !is_convertible<T, __rv<T> >::value,
- typename add_lvalue_reference<T>::type
+ !is_convertible<_Tp, __rv<_Tp> >::value,
+ typename add_lvalue_reference<_Tp>::type
>::type
-forward(const U& t)
+forward(const _Up& __t)
{
- return t;
+ return __t;
}
-template <class T, class U>
+template <class _Tp, class _Up>
inline
typename enable_if
<
- is_convertible<T, __rv<T> >::value,
- T
+ is_convertible<_Tp, __rv<_Tp> >::value,
+ _Tp
>::type
-forward(U& t)
+forward(_Up& __t)
{
- return T(__rv<T>(t));
+ return _Tp(__rv<_Tp>(__t));
}
-template <class T, class U>
+template <class _Tp, class _Up>
inline
typename enable_if
<
- is_convertible<T, __rv<T> >::value,
- T
+ is_convertible<_Tp, __rv<_Tp> >::value,
+ _Tp
>::type
-forward(const U& t)
+forward(const _Up& __t)
{
- return T(__rv<T>(t));
+ return _Tp(__rv<_Tp>(__t));
}
#endif // _LIBCPP_MOVE
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp
new file mode 100644
index 00000000000..57d1270fec4
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// fisher_f_distribution& operator=(const fisher_f_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::fisher_f_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp
new file mode 100644
index 00000000000..128325f05b4
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// fisher_f_distribution(const fisher_f_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::fisher_f_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp
new file mode 100644
index 00000000000..c496a886f55
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// explicit fisher_f_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d;
+ assert(d.m() == 1);
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(14.5);
+ assert(d.m() == 14.5);
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.m() == 14.5);
+ assert(d.n() == 5.25);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp
new file mode 100644
index 00000000000..c6d0a9c15c6
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// explicit fisher_f_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.m() == 0.25);
+ assert(d.n() == 10);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp
new file mode 100644
index 00000000000..352ddbc1e3e
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// bool operator=(const fisher_f_distribution& x,
+// const fisher_f_distribution& y);
+// bool operator!(const fisher_f_distribution& x,
+// const fisher_f_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp
new file mode 100644
index 00000000000..4352f577aa7
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+
+double fac(double x)
+{
+ double r = 1;
+ for (; x > 1; --x)
+ r *= x;
+ return r;
+}
+
+double
+I(double x, unsigned a, unsigned b)
+{
+ double r = 0;
+ for (int j = a; j <= a+b-1; ++j)
+ r += fac(a+b-1)/(fac(j) * fac(a + b - 1 - j)) * std::pow(x, j) *
+ std::pow(1-x, a+b-1-j);
+ return r;
+}
+
+double
+f(double x, double m, double n)
+{
+ return I(m * x / (m*x + n), static_cast<unsigned>(m/2), static_cast<unsigned>(n/2));
+}
+
+int main()
+{
+ // Purposefully only testing even integral values of m and n (for now)
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 4);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(4, 2);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(18, 20);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp
new file mode 100644
index 00000000000..e9ad52f1811
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+
+double fac(double x)
+{
+ double r = 1;
+ for (; x > 1; --x)
+ r *= x;
+ return r;
+}
+
+double
+I(double x, unsigned a, unsigned b)
+{
+ double r = 0;
+ for (int j = a; j <= a+b-1; ++j)
+ r += fac(a+b-1)/(fac(j) * fac(a + b - 1 - j)) * std::pow(x, j) *
+ std::pow(1-x, a+b-1-j);
+ return r;
+}
+
+double
+f(double x, double m, double n)
+{
+ return I(m * x / (m*x + n), static_cast<unsigned>(m/2), static_cast<unsigned>(n/2));
+}
+
+int main()
+{
+ // Purposefully only testing even integral values of m and n (for now)
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 4);
+ P p(4, 2);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(4, 2);
+ P p(6, 8);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(18, 20);
+ P p(16, 14);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp
new file mode 100644
index 00000000000..af7f70f0460
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp
new file mode 100644
index 00000000000..66d3b274034
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const fisher_f_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// fisher_f_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp
new file mode 100644
index 00000000000..a388d15be61
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp
new file mode 100644
index 00000000000..7e7aae6b996
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp
new file mode 100644
index 00000000000..b335b1fbe44
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.m() == .75);
+ assert(p.n() == 6);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp
new file mode 100644
index 00000000000..37539b6bdde
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.m() == 10);
+ assert(p.n() == .125);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp
new file mode 100644
index 00000000000..90ac5373088
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.m() == 1);
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.m() == 10);
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.m() == 10);
+ assert(p.n() == 5);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp
new file mode 100644
index 00000000000..d2b16ba3255
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_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::fisher_f_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/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp
new file mode 100644
index 00000000000..3649c8fc7d7
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp
new file mode 100644
index 00000000000..a0f1be0aa0d
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_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/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp
new file mode 100644
index 00000000000..ede9ae79b80
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::fisher_f_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
OpenPOWER on IntegriCloud