[rand.dist.norm.f]
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@104035 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/chrono b/include/chrono
index 911a95e..1c79c68 100644
--- a/include/chrono
+++ b/include/chrono
@@ -264,7 +264,7 @@
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/include/cstddef b/include/cstddef
index c939f0e..11d07a2 100644
--- a/include/cstddef
+++ b/include/cstddef
@@ -57,13 +57,13 @@
_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/include/random b/include/random
index c173414..f1ae33b 100644
--- a/include/random
+++ b/include/random
@@ -1296,7 +1296,62 @@
};
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 @@
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 @@
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/include/ratio b/include/ratio
index 2d217c1..ca5be9c 100644
--- a/include/ratio
+++ b/include/ratio
@@ -239,7 +239,7 @@
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/include/type_traits b/include/type_traits
index b838b17..37e9708 100644
--- a/include/type_traits
+++ b/include/type_traits
@@ -395,7 +395,7 @@
// 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 @@
#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