[cfe-commits] [libcxx] r103916 - in /libcxx/trunk: include/ test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ test/numerics/rand/rand.util/rand.util.canonical/
Howard Hinnant
hhinnant at apple.com
Sun May 16 17:09:38 PDT 2010
Author: hhinnant
Date: Sun May 16 19:09:38 2010
New Revision: 103916
URL: http://llvm.org/viewvc/llvm-project?rev=103916&view=rev
Log:
[rand.dist.bern.negbin]
Added:
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp
Modified:
libcxx/trunk/include/random
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp
Modified: libcxx/trunk/include/random
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=103916&r1=103915&r2=103916&view=diff
==============================================================================
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Sun May 16 19:09:38 2010
@@ -669,7 +669,62 @@
class geometric_distribution;
template<class IntType = int>
- class negative_binomial_distribution;
+class negative_binomial_distribution
+{
+public:
+ // types
+ typedef IntType result_type;
+
+ class param_type
+ {
+ public:
+ typedef negative_binomial_distribution distribution_type;
+
+ explicit param_type(result_type k = 1, double p = 0.5);
+
+ result_type k() const;
+ double p() 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 negative_binomial_distribution(result_type k = 1, double p = 0.5);
+ explicit negative_binomial_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 k() const;
+ double p() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const negative_binomial_distribution& x,
+ const negative_binomial_distribution& y);
+ friend bool operator!=(const negative_binomial_distribution& x,
+ const negative_binomial_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const negative_binomial_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ negative_binomial_distribution& x);
+};
template<class IntType = int>
class poisson_distribution
@@ -4098,6 +4153,122 @@
return __is;
}
+// negative_binomial_distribution
+
+template<class _IntType = int>
+class negative_binomial_distribution
+{
+public:
+ // types
+ typedef _IntType result_type;
+
+ class param_type
+ {
+ result_type __k_;
+ double __p_;
+ public:
+ typedef negative_binomial_distribution distribution_type;
+
+ explicit param_type(result_type __k = 1, double __p = 0.5)
+ : __k_(__k), __p_(__p) {}
+
+ result_type k() const {return __k_;}
+ double p() const {return __p_;}
+
+ friend bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__k_ == __y.__k_ && __x.__p_ == __y.__p_;}
+ friend bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+ explicit negative_binomial_distribution(result_type __k = 1, double __p = 0.5)
+ : __p_(__k, __p) {}
+ explicit negative_binomial_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 k() const {return __p_.k();}
+ double p() const {return __p_.p();}
+
+ 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>::max();}
+
+ friend bool operator==(const negative_binomial_distribution& __x,
+ const negative_binomial_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend bool operator!=(const negative_binomial_distribution& __x,
+ const negative_binomial_distribution& __y)
+ {return !(__x == __y);}
+};
+
+template <class _IntType>
+template<class _URNG>
+_IntType
+negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr)
+{
+ result_type __k = __pr.k();
+ double __p = __pr.p();
+ if (__k <= 21 * __p)
+ {
+ bernoulli_distribution __gen(__p);
+ result_type __f = 0;
+ result_type __s = 0;
+ while (__s < __k)
+ {
+ if (__gen(__urng))
+ ++__s;
+ else
+ ++__f;
+ }
+ return __f;
+ }
+ return poisson_distribution<result_type>(gamma_distribution<double>
+ (__k, (1-__p)/__p)(__urng))(__urng);
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const negative_binomial_distribution<_IntType>& __x)
+{
+ __save_flags<_CharT, _Traits> _(__os);
+ __os.flags(ios_base::dec | ios_base::left);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ return __os << __x.k() << __sp << __x.p();
+}
+
+template <class _CharT, class _Traits, class _IntType>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ negative_binomial_distribution<_IntType>& __x)
+{
+ typedef negative_binomial_distribution<_IntType> _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 __k;
+ double __p;
+ __is >> __k >> __p;
+ if (!__is.fail())
+ __x.param(param_type(__k, __p));
+ return __is;
+}
+
// chi_squared_distribution
template<class _RealType = double>
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp?rev=103916&r1=103915&r2=103916&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp Sun May 16 19:09:38 2010
@@ -14,8 +14,6 @@
// template<class _URNG> result_type operator()(_URNG& g);
-#include <iostream>
-
#include <random>
#include <numeric>
#include <vector>
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+
+// negative_binomial_distribution& operator=(const negative_binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::negative_binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+
+// negative_binomial_distribution(const negative_binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::negative_binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+
+// explicit negative_binomial_distribution(IntType t = 1, double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d;
+ assert(d.k() == 1);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(3);
+ assert(d.k() == 3);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(3, 0.75);
+ assert(d.k() == 3);
+ assert(d.p() == 0.75);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+
+// explicit negative_binomial_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, 0.25);
+ D d(p);
+ assert(d.k() == 5);
+ assert(d.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp Sun May 16 19:09:38 2010
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// bool operator=(const negative_binomial_distribution& x,
+// const negative_binomial_distribution& y);
+// bool operator!(const negative_binomial_distribution& x,
+// const negative_binomial_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(3, .25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(3, .28);
+ D d2(3, .25);
+ assert(d1 != d2);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(4, .25);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp Sun May 16 19:09:38 2010
@@ -0,0 +1,270 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(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 = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs(skew - x_skew) / x_skew < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(30, .03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(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 = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs(skew - x_skew) / x_skew < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(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 = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs(skew - x_skew) / x_skew < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.03);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, 1);
+ const int N = 1000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(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 = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(mean == x_mean);
+ assert(var == x_var);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(400, 0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(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 = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs(skew - x_skew) / x_skew < 0.04);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.05);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, 0.05);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(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 = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs(skew - x_skew) / x_skew < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.02);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp Sun May 16 19:09:38 2010
@@ -0,0 +1,158 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(16, .75);
+ P p(5, .75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(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 = p.k() * (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+ double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs(skew - x_skew) / x_skew < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(30, .03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(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 = p.k() * (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+ double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs(skew - x_skew) / x_skew < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(40, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(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 = p.k() * (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+ double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs(skew - x_skew) / x_skew < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.03);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, .125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const negative_binomial_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// negative_binomial_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(7, .25);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(4, .25);
+ assert(d.max() == std::numeric_limits<int>::max());
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(4, .5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(6, .7);
+ param_type p;
+ p = p0;
+ assert(p.k() == 6);
+ assert(p.p() == .7);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.k() == 10);
+ assert(p.p() == .125);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.k() == 1);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.k() == 10);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 0.25);
+ assert(p.k() == 10);
+ assert(p.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(10, 0.25);
+ D d(8, 0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp?rev=103916&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp Sun May 16 19:09:38 2010
@@ -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 IntType = int>
+// class negative_binomial_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::negative_binomial_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
Modified: libcxx/trunk/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp?rev=103916&r1=103915&r2=103916&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.util/rand.util.canonical/generate_canonical.pass.cpp Sun May 16 19:09:38 2010
@@ -15,8 +15,6 @@
#include <random>
#include <cassert>
-#include <iostream>
-
int main()
{
{
More information about the cfe-commits
mailing list