[cfe-commits] [libcxx] r104224 - in /libcxx/trunk: include/ test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ te...
Howard Hinnant
hhinnant at apple.com
Thu May 20 08:11:46 PDT 2010
Author: hhinnant
Date: Thu May 20 10:11:46 2010
New Revision: 104224
URL: http://llvm.org/viewvc/llvm-project?rev=104224&view=rev
Log:
[rand.dist.samp.pconst] plus some bug fixes in the tests of the other distributions
Added:
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp
Modified:
libcxx/trunk/include/random
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.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.norm/rand.dist.norm.chisq/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp
libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp
libcxx/trunk/test/numerics/rand/rand.predef/default_random_engine.pass.cpp
Modified: libcxx/trunk/include/random
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Thu May 20 10:11:46 2010
@@ -371,7 +371,7 @@
typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24;
typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48;
typedef shuffle_order_engine<minstd_rand0, 256> knuth_b;
-typedef minstd_rand0 default_random_engine;
+typedef minstd_rand default_random_engine;
// Generators
@@ -1477,7 +1477,79 @@
};
template<class RealType = double>
- class piecewise_constant_distribution;
+class piecewise_constant_distribution
+{
+ // types
+ typedef RealType result_type;
+
+ class param_type
+ {
+ public:
+ typedef piecewise_constant_distribution distribution_type;
+
+ param_type();
+ template<class InputIteratorB, class InputIteratorW>
+ param_type(InputIteratorB firstB, InputIteratorB lastB,
+ InputIteratorW firstW);
+ template<class UnaryOperation>
+ param_type(initializer_list<result_type> bl, UnaryOperation fw);
+ template<class UnaryOperation>
+ param_type(size_t nw, result_type xmin, result_type xmax,
+ UnaryOperation fw);
+
+ vector<result_type> intervals() const;
+ vector<double> densities() 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
+ piecewise_constant_distribution();
+ template<class InputIteratorB, class InputIteratorW>
+ piecewise_constant_distribution(InputIteratorB firstB,
+ InputIteratorB lastB,
+ InputIteratorW firstW);
+ template<class UnaryOperation>
+ piecewise_constant_distribution(initializer_list<result_type> bl,
+ UnaryOperation fw);
+ template<class UnaryOperation>
+ piecewise_constant_distribution(size_t nw, result_type xmin,
+ result_type xmax, UnaryOperation fw);
+ explicit piecewise_constant_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
+ vector<result_type> intervals() const;
+ vector<double> densities() const;
+
+ param_type param() const;
+ void param(const param_type& parm);
+
+ result_type min() const;
+ result_type max() const;
+
+ friend bool operator==(const piecewise_constant_distribution& x,
+ const piecewise_constant_distribution& y);
+ friend bool operator!=(const piecewise_constant_distribution& x,
+ const piecewise_constant_distribution& y);
+
+ template <class charT, class traits>
+ friend
+ basic_ostream<charT, traits>&
+ operator<<(basic_ostream<charT, traits>& os,
+ const piecewise_constant_distribution& x);
+
+ template <class charT, class traits>
+ friend
+ basic_istream<charT, traits>&
+ operator>>(basic_istream<charT, traits>& is,
+ piecewise_constant_distribution& x);
+};
template<class RealType = double>
class piecewise_linear_distribution;
@@ -1825,9 +1897,9 @@
typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>
minstd_rand0;
-typedef minstd_rand0 default_random_engine;
typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>
minstd_rand;
+typedef minstd_rand default_random_engine;
// mersenne_twister_engine
template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
@@ -3655,7 +3727,8 @@
bernoulli_distribution::result_type
bernoulli_distribution::operator()(_URNG& __g, const param_type& __p)
{
- return (__g() - __g.min()) < __p.p() * (__g.max() - __g.min() + 1.);
+ uniform_real_distribution<double> __gen;
+ return __gen(__g) < __p.p();
}
template <class _CharT, class _Traits>
@@ -5535,11 +5608,305 @@
__is.flags(ios_base::dec | ios_base::skipws);
size_t __n;
__is >> __n;
- std::vector<double> __p(__n);
+ vector<double> __p(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __is >> __p[__i];
+ if (!__is.fail())
+ swap(__x.__p_.__p_, __p);
+ return __is;
+}
+
+// piecewise_constant_distribution
+
+template<class _RealType = double>
+class piecewise_constant_distribution
+{
+public:
+ // types
+ typedef _RealType result_type;
+
+ class param_type
+ {
+ vector<double> __p_;
+ vector<result_type> __b_;
+ public:
+ typedef piecewise_constant_distribution distribution_type;
+
+ param_type();
+ template<class _InputIteratorB, class _InputIteratorW>
+ param_type(_InputIteratorB __fB, _InputIteratorB __lB,
+ _InputIteratorW __fW);
+ template<class _UnaryOperation>
+ param_type(initializer_list<result_type> __bl, _UnaryOperation __fw);
+ template<class _UnaryOperation>
+ param_type(size_t __nw, result_type __xmin, result_type __xmax,
+ _UnaryOperation __fw);
+
+ vector<result_type> intervals() const {return __b_;}
+ vector<double> densities() const;
+
+ friend bool operator==(const param_type& __x, const param_type& __y)
+ {return __x.__p_ == __y.__p_ && __x.__b_ == __y.__b_;}
+ friend bool operator!=(const param_type& __x, const param_type& __y)
+ {return !(__x == __y);}
+
+ private:
+ void __init();
+
+ friend class piecewise_constant_distribution;
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const piecewise_constant_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ piecewise_constant_distribution<_RT>& __x);
+ };
+
+private:
+ param_type __p_;
+
+public:
+ // constructor and reset functions
+ piecewise_constant_distribution() {}
+ template<class _InputIteratorB, class _InputIteratorW>
+ piecewise_constant_distribution(_InputIteratorB __fB,
+ _InputIteratorB __lB,
+ _InputIteratorW __fW)
+ : __p_(__fB, __lB, __fW) {}
+
+ template<class _UnaryOperation>
+ piecewise_constant_distribution(initializer_list<result_type> __bl,
+ _UnaryOperation __fw)
+ : __p_(__bl, __fw) {}
+
+ template<class _UnaryOperation>
+ piecewise_constant_distribution(size_t __nw, result_type __xmin,
+ result_type __xmax, _UnaryOperation __fw)
+ : __p_(__nw, __xmin, __xmax, __fw) {}
+
+ explicit piecewise_constant_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
+ vector<result_type> intervals() const {return __p_.intervals();}
+ vector<double> densities() const {return __p_.densities();}
+
+ param_type param() const {return __p_;}
+ void param(const param_type& __p) {__p_ = __p;}
+
+ result_type min() const {return __p_.__b_.front();}
+ result_type max() const {return __p_.__b_.back();}
+
+ friend bool operator==(const piecewise_constant_distribution& __x,
+ const piecewise_constant_distribution& __y)
+ {return __x.__p_ == __y.__p_;}
+ friend bool operator!=(const piecewise_constant_distribution& __x,
+ const piecewise_constant_distribution& __y)
+ {return !(__x == __y);}
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_ostream<_CharT, _Traits>&
+ operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const piecewise_constant_distribution<_RT>& __x);
+
+ template <class _CharT, class _Traits, class _RT>
+ friend
+ basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>& __is,
+ piecewise_constant_distribution<_RT>& __x);
+};
+
+template<class _RealType>
+void
+piecewise_constant_distribution<_RealType>::param_type::__init()
+{
+ if (!__p_.empty())
+ {
+ if (__p_.size() > 1)
+ {
+ double __s = _STD::accumulate(__p_.begin(), __p_.end(), 0.0);
+ for (_STD::vector<double>::iterator __i = __p_.begin(), __e = __p_.end();
+ __i < __e; ++__i)
+ *__i /= __s;
+ vector<double> __t(__p_.size() - 1);
+ _STD::partial_sum(__p_.begin(), __p_.end() - 1, __t.begin());
+ swap(__p_, __t);
+ }
+ else
+ {
+ __p_.clear();
+ __p_.shrink_to_fit();
+ }
+ }
+}
+
+template<class _RealType>
+piecewise_constant_distribution<_RealType>::param_type::param_type()
+ : __b_(2)
+{
+ __b_[1] = 1;
+}
+
+template<class _RealType>
+template<class _InputIteratorB, class _InputIteratorW>
+piecewise_constant_distribution<_RealType>::param_type::param_type(
+ _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW)
+ : __b_(__fB, __lB)
+{
+ if (__b_.size() < 2)
+ {
+ __b_.resize(2);
+ __b_[0] = 0;
+ __b_[1] = 1;
+ }
+ else
+ {
+ __p_.reserve(__b_.size() - 1);
+ for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__fW)
+ __p_.push_back(*__fW);
+ __init();
+ }
+}
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_constant_distribution<_RealType>::param_type::param_type(
+ initializer_list<result_type> __bl, _UnaryOperation __fw)
+ : __b_(__bl.begin(), __bl.end())
+{
+ if (__b_.size() < 2)
+ {
+ __b_.resize(2);
+ __b_[0] = 0;
+ __b_[1] = 1;
+ }
+ else
+ {
+ __p_.reserve(__b_.size() - 1);
+ for (size_t __i = 0; __i < __b_.size() - 1; ++__i)
+ __p_.push_back(__fw((__b_[__i+1] + __b_[__i])*.5));
+ __init();
+ }
+}
+
+template<class _RealType>
+template<class _UnaryOperation>
+piecewise_constant_distribution<_RealType>::param_type::param_type(
+ size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw)
+ : __b_(__nw == 0 ? 2 : __nw + 1)
+{
+ size_t __n = __b_.size() - 1;
+ result_type __d = (__xmax - __xmin) / __n;
+ __p_.reserve(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ {
+ __b_[__i] = __xmin + __i * __d;
+ __p_.push_back(__fw(__b_[__i] + __d*.5));
+ }
+ __b_[__n] = __xmax;
+ __init();
+}
+
+template<class _RealType>
+vector<double>
+piecewise_constant_distribution<_RealType>::param_type::densities() const
+{
+ const size_t __n = __b_.size() - 1;
+ vector<double> __d(__n);
+ if (__n == 1)
+ __d[0] = 1/(__b_[1] - __b_[0]);
+ else
+ {
+ __d[0] = __p_[0] / (__b_[1] - __b_[0]);
+ for (size_t __i = 1; __i < __n - 1; ++__i)
+ __d[__i] = (__p_[__i] - __p_[__i-1]) / (__b_[__i+1] - __b_[__i]);
+ __d[__n-1] = (1 - __p_[__n-2]) / (__b_[__n] - __b_[__n-1]);
+ }
+ return __d;
+};
+
+
+template<class _RealType>
+template<class _URNG>
+_RealType
+piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p)
+{
+ typedef uniform_real_distribution<result_type> _Gen;
+ if (__p.__b_.size() == 2)
+ return _Gen(__p.__b_[0], __p.__b_[1])(__g);
+ result_type __u = _Gen()(__g);
+ const vector<double>& __dd = __p.__p_;
+ size_t __k = static_cast<size_t>(_STD::upper_bound(__dd.begin(),
+ __dd.end(), static_cast<double>(__u)) - __dd.begin());
+ if (__k == 0)
+ return static_cast<result_type>(__u * (__p.__b_[1] - __p.__b_[0]) /
+ __dd[0] + __p.__b_[0]);
+ __u -= __dd[__k-1];
+ if (__k == __dd.size())
+ return static_cast<result_type>(__u * (__p.__b_[__k+1] - __p.__b_[__k]) /
+ (1 - __dd[__k-1]) + __p.__b_[__k]);
+ return static_cast<result_type>(__u * (__p.__b_[__k+1] - __p.__b_[__k]) /
+ (__dd[__k] - __dd[__k-1]) + __p.__b_[__k]);
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_ostream<_CharT, _Traits>&
+operator<<(basic_ostream<_CharT, _Traits>& __os,
+ const piecewise_constant_distribution<_RT>& __x)
+{
+ __save_flags<_CharT, _Traits> _(__os);
+ __os.flags(ios_base::dec | ios_base::left);
+ _CharT __sp = __os.widen(' ');
+ __os.fill(__sp);
+ size_t __n = __x.__p_.__p_.size();
+ __os << __n;
+ for (size_t __i = 0; __i < __n; ++__i)
+ __os << __sp << __x.__p_.__p_[__i];
+ __n = __x.__p_.__b_.size();
+ __os << __sp << __n;
+ for (size_t __i = 0; __i < __n; ++__i)
+ __os << __sp << __x.__p_.__b_[__i];
+ return __os;
+}
+
+template <class _CharT, class _Traits, class _RT>
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __is,
+ piecewise_constant_distribution<_RT>& __x)
+{
+ typedef piecewise_constant_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);
+ size_t __n;
+ __is >> __n;
+ vector<double> __p(__n);
for (size_t __i = 0; __i < __n; ++__i)
__is >> __p[__i];
+ __is >> __n;
+ vector<result_type> __b(__n);
+ for (size_t __i = 0; __i < __n; ++__i)
+ __is >> __b[__i];
if (!__is.fail())
+ {
swap(__x.__p_.__p_, __p);
+ swap(__x.__p_.__b_, __b);
+ }
return __is;
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -59,10 +59,10 @@
double x_var = d.p()*(1-d.p());
double x_skew = (1 - 2 * d.p())/std::sqrt(x_var);
double x_kurtosis = (6 * sqr(d.p()) - 6 * d.p() + 1)/x_var;
- 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);
+ 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);
}
{
typedef std::bernoulli_distribution D;
@@ -95,9 +95,9 @@
double x_var = d.p()*(1-d.p());
double x_skew = (1 - 2 * d.p())/std::sqrt(x_var);
double x_kurtosis = (6 * sqr(d.p()) - 6 * d.p() + 1)/x_var;
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -61,10 +61,10 @@
double x_var = p.p()*(1-p.p());
double x_skew = (1 - 2 * p.p())/std::sqrt(x_var);
double x_kurtosis = (6 * sqr(p.p()) - 6 * p.p() + 1)/x_var;
- 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);
+ 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);
}
{
typedef std::bernoulli_distribution D;
@@ -99,9 +99,9 @@
double x_var = p.p()*(1-p.p());
double x_skew = (1 - 2 * p.p())/std::sqrt(x_var);
double x_kurtosis = (6 * sqr(p.p()) - 6 * p.p() + 1)/x_var;
- 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);
+ 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);
}
}
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=104224&r1=104223&r2=104224&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 Thu May 20 10:11:46 2010
@@ -31,10 +31,10 @@
{
{
typedef std::binomial_distribution<> D;
- typedef std::minstd_rand G;
+ typedef std::mt19937_64 G;
G g;
D d(5, .75);
- const int N = 100000;
+ const int N = 1000000;
std::vector<D::result_type> u;
for (int i = 0; i < N; ++i)
{
@@ -64,10 +64,10 @@
double x_var = x_mean*(1-d.p());
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
- 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);
+ 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.04);
}
{
typedef std::binomial_distribution<> D;
@@ -104,10 +104,10 @@
double x_var = x_mean*(1-d.p());
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
- 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);
+ 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::binomial_distribution<> D;
@@ -144,10 +144,10 @@
double x_var = x_mean*(1-d.p());
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
- 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.03);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ 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.03);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.3);
}
{
typedef std::binomial_distribution<> D;
@@ -260,10 +260,10 @@
double x_var = x_mean*(1-d.p());
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) < 0.01);
}
{
typedef std::binomial_distribution<> D;
@@ -300,10 +300,10 @@
double x_var = x_mean*(1-d.p());
double x_skew = (1-2*d.p()) / std::sqrt(x_var);
double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::binomial_distribution<> D;
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -32,11 +32,11 @@
{
typedef std::binomial_distribution<> D;
typedef D::param_type P;
- typedef std::minstd_rand G;
+ typedef std::mt19937_64 G;
G g;
D d(16, .75);
P p(5, .75);
- const int N = 100000;
+ const int N = 1000000;
std::vector<D::result_type> u;
for (int i = 0; i < N; ++i)
{
@@ -66,10 +66,10 @@
double x_var = x_mean*(1-p.p());
double x_skew = (1-2*p.p()) / std::sqrt(x_var);
double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var;
- 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);
+ 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.04);
}
{
typedef std::binomial_distribution<> D;
@@ -108,10 +108,10 @@
double x_var = x_mean*(1-p.p());
double x_skew = (1-2*p.p()) / std::sqrt(x_var);
double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var;
- 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);
+ 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::binomial_distribution<> D;
@@ -120,7 +120,7 @@
G g;
D d(16, .75);
P p(40, .25);
- const int N = 100000;
+ const int N = 1000000;
std::vector<D::result_type> u;
for (int i = 0; i < N; ++i)
{
@@ -150,9 +150,9 @@
double x_var = x_mean*(1-p.p());
double x_skew = (1-2*p.p()) / std::sqrt(x_var);
double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var;
- 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.03);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ 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.3);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -64,10 +64,10 @@
double x_var = x_mean / d.p();
double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
double x_kurtosis = 6 + sqr(d.p()) / (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);
+ 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::geometric_distribution<> D;
@@ -104,10 +104,10 @@
double x_var = x_mean / d.p();
double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
double x_kurtosis = 6 + sqr(d.p()) / (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);
+ 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::geometric_distribution<> D;
@@ -144,10 +144,10 @@
double x_var = x_mean / d.p();
double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
double x_kurtosis = 6 + sqr(d.p()) / (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);
+ 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);
}
{
typedef std::geometric_distribution<> D;
@@ -184,10 +184,10 @@
double x_var = x_mean / d.p();
double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
double x_kurtosis = 6 + sqr(d.p()) / (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);
+ 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);
}
{
typedef std::geometric_distribution<> D;
@@ -224,10 +224,10 @@
double x_var = x_mean / d.p();
double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
double x_kurtosis = 6 + sqr(d.p()) / (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);
+ 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);
}
{
typedef std::geometric_distribution<> D;
@@ -264,9 +264,9 @@
double x_var = x_mean / d.p();
double x_skew = (2 - d.p()) / std::sqrt((1 - d.p()));
double x_kurtosis = 6 + sqr(d.p()) / (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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -66,10 +66,10 @@
double x_var = x_mean / p.p();
double x_skew = (2 - p.p()) / std::sqrt((1 - p.p()));
double x_kurtosis = 6 + sqr(p.p()) / (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);
+ 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::geometric_distribution<> D;
@@ -108,10 +108,10 @@
double x_var = x_mean / p.p();
double x_skew = (2 - p.p()) / std::sqrt((1 - p.p()));
double x_kurtosis = 6 + sqr(p.p()) / (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);
+ 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::geometric_distribution<> D;
@@ -150,9 +150,9 @@
double x_var = x_mean / p.p();
double x_skew = (2 - p.p()) / std::sqrt((1 - p.p()));
double x_kurtosis = 6 + sqr(p.p()) / (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);
+ 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);
}
}
Modified: 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=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -64,10 +64,10 @@
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);
+ 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);
}
{
typedef std::negative_binomial_distribution<> D;
@@ -104,10 +104,10 @@
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);
+ 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;
@@ -144,10 +144,10 @@
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);
+ 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;
@@ -222,10 +222,10 @@
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);
+ 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;
@@ -262,9 +262,9 @@
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);
+ 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);
}
}
Modified: 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=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -66,10 +66,10 @@
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);
+ 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;
@@ -108,10 +108,10 @@
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);
+ 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;
@@ -150,9 +150,9 @@
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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -64,10 +64,10 @@
double x_var = 2 * d.n();
double x_skew = std::sqrt(8 / d.n());
double x_kurtosis = 12 / d.n();
- 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);
+ 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::chi_squared_distribution<> D;
@@ -104,10 +104,10 @@
double x_var = 2 * d.n();
double x_skew = std::sqrt(8 / d.n());
double x_kurtosis = 12 / d.n();
- 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);
+ 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::chi_squared_distribution<> D;
@@ -144,9 +144,9 @@
double x_var = 2 * d.n();
double x_skew = std::sqrt(8 / d.n());
double x_kurtosis = 12 / d.n();
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -65,10 +65,10 @@
double x_var = 2 * p.n();
double x_skew = std::sqrt(8 / p.n());
double x_kurtosis = 12 / p.n();
- 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);
+ 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::chi_squared_distribution<> D;
@@ -106,10 +106,10 @@
double x_var = 2 * p.n();
double x_skew = std::sqrt(8 / p.n());
double x_kurtosis = 12 / p.n();
- 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);
+ 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::chi_squared_distribution<> D;
@@ -147,9 +147,9 @@
double x_var = 2 * p.n();
double x_skew = std::sqrt(8 / p.n());
double x_kurtosis = 12 / p.n();
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -66,10 +66,10 @@
std::sqrt((std::exp(sqr(d.s())) - 1));
double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
3*std::exp(2*sqr(d.s())) - 6;
- 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.05);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.25);
+ 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.05);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.25);
}
{
typedef std::lognormal_distribution<> D;
@@ -108,10 +108,10 @@
std::sqrt((std::exp(sqr(d.s())) - 1));
double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
3*std::exp(2*sqr(d.s())) - 6;
- 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);
+ 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::lognormal_distribution<> D;
@@ -150,10 +150,10 @@
std::sqrt((std::exp(sqr(d.s())) - 1));
double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
3*std::exp(2*sqr(d.s())) - 6;
- 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.02);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.05);
+ 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.02);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.05);
}
{
typedef std::lognormal_distribution<> D;
@@ -192,10 +192,10 @@
std::sqrt((std::exp(sqr(d.s())) - 1));
double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
3*std::exp(2*sqr(d.s())) - 6;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.02);
- assert(std::abs(skew - x_skew) / x_skew < 0.08);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.4);
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.02);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.08);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.4);
}
{
typedef std::lognormal_distribution<> D;
@@ -234,9 +234,9 @@
std::sqrt((std::exp(sqr(d.s())) - 1));
double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
3*std::exp(2*sqr(d.s())) - 6;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.04);
- assert(std::abs(skew - x_skew) / x_skew < 0.2);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.7);
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.04);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.2);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.7);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -68,10 +68,10 @@
std::sqrt((std::exp(sqr(p.s())) - 1));
double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
3*std::exp(2*sqr(p.s())) - 6;
- 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.05);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.25);
+ 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.05);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.25);
}
{
typedef std::lognormal_distribution<> D;
@@ -111,10 +111,10 @@
std::sqrt((std::exp(sqr(p.s())) - 1));
double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
3*std::exp(2*sqr(p.s())) - 6;
- 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);
+ 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::lognormal_distribution<> D;
@@ -154,10 +154,10 @@
std::sqrt((std::exp(sqr(p.s())) - 1));
double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
3*std::exp(2*sqr(p.s())) - 6;
- 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.02);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.05);
+ 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.02);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.05);
}
{
typedef std::lognormal_distribution<> D;
@@ -197,10 +197,10 @@
std::sqrt((std::exp(sqr(p.s())) - 1));
double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
3*std::exp(2*sqr(p.s())) - 6;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.02);
- assert(std::abs(skew - x_skew) / x_skew < 0.08);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.4);
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.02);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.08);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.4);
}
{
typedef std::lognormal_distribution<> D;
@@ -240,9 +240,9 @@
std::sqrt((std::exp(sqr(p.s())) - 1));
double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
3*std::exp(2*sqr(p.s())) - 6;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.04);
- assert(std::abs(skew - x_skew) / x_skew < 0.2);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.7);
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.04);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.2);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.7);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -60,8 +60,8 @@
double x_var = sqr(d.stddev());
double x_skew = 0;
double x_kurtosis = 0;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
assert(std::abs(kurtosis - x_kurtosis) < 0.01);
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -61,8 +61,8 @@
double x_var = sqr(p.stddev());
double x_skew = 0;
double x_kurtosis = 0;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
assert(std::abs(kurtosis - x_kurtosis) < 0.01);
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -61,9 +61,9 @@
double x_skew = 0;
double x_kurtosis = 6 / (d.n() - 4);
assert(std::abs(mean - x_mean) < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
assert(std::abs(skew - x_skew) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.2);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.2);
}
{
typedef std::student_t_distribution<> D;
@@ -97,9 +97,9 @@
double x_skew = 0;
double x_kurtosis = 6 / (d.n() - 4);
assert(std::abs(mean - x_mean) < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
assert(std::abs(skew - x_skew) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.04);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
}
{
typedef std::student_t_distribution<> D;
@@ -133,8 +133,8 @@
double x_skew = 0;
double x_kurtosis = 6 / (d.n() - 4);
assert(std::abs(mean - x_mean) < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
assert(std::abs(skew - x_skew) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.02);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -62,9 +62,9 @@
double x_skew = 0;
double x_kurtosis = 6 / (p.n() - 4);
assert(std::abs(mean - x_mean) < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
assert(std::abs(skew - x_skew) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.2);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.2);
}
{
typedef std::student_t_distribution<> D;
@@ -99,9 +99,9 @@
double x_skew = 0;
double x_kurtosis = 6 / (p.n() - 4);
assert(std::abs(mean - x_mean) < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
assert(std::abs(skew - x_skew) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.04);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
}
{
typedef std::student_t_distribution<> D;
@@ -136,8 +136,8 @@
double x_skew = 0;
double x_kurtosis = 6 / (p.n() - 4);
assert(std::abs(mean - x_mean) < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
assert(std::abs(skew - x_skew) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.02);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -64,10 +64,10 @@
double x_var = 1/sqr(d.lambda());
double x_skew = 2;
double x_kurtosis = 6;
- 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);
+ 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::exponential_distribution<> D;
@@ -104,10 +104,10 @@
double x_var = 1/sqr(d.lambda());
double x_skew = 2;
double x_kurtosis = 6;
- 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);
+ 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::exponential_distribution<> D;
@@ -144,9 +144,9 @@
double x_var = 1/sqr(d.lambda());
double x_skew = 2;
double x_kurtosis = 6;
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -65,9 +65,9 @@
double x_var = 1/sqr(p.lambda());
double x_skew = 2;
double x_kurtosis = 6;
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -63,10 +63,10 @@
double x_var = sqr(d.b()) * 1.644934067;
double x_skew = 1.139547;
double x_kurtosis = 12./5;
- 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);
+ 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::extreme_value_distribution<> D;
@@ -102,10 +102,10 @@
double x_var = sqr(d.b()) * 1.644934067;
double x_skew = 1.139547;
double x_kurtosis = 12./5;
- 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);
+ 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::extreme_value_distribution<> D;
@@ -141,10 +141,10 @@
double x_var = sqr(d.b()) * 1.644934067;
double x_skew = 1.139547;
double x_kurtosis = 12./5;
- 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);
+ 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::extreme_value_distribution<> D;
@@ -180,9 +180,9 @@
double x_var = sqr(d.b()) * 1.644934067;
double x_skew = 1.139547;
double x_kurtosis = 12./5;
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -64,10 +64,10 @@
double x_var = sqr(p.b()) * 1.644934067;
double x_skew = 1.139547;
double x_kurtosis = 12./5;
- 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);
+ 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::extreme_value_distribution<> D;
@@ -104,10 +104,10 @@
double x_var = sqr(p.b()) * 1.644934067;
double x_skew = 1.139547;
double x_kurtosis = 12./5;
- 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);
+ 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::extreme_value_distribution<> D;
@@ -144,10 +144,10 @@
double x_var = sqr(p.b()) * 1.644934067;
double x_skew = 1.139547;
double x_kurtosis = 12./5;
- 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);
+ 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::extreme_value_distribution<> D;
@@ -184,9 +184,9 @@
double x_var = sqr(p.b()) * 1.644934067;
double x_skew = 1.139547;
double x_kurtosis = 12./5;
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -64,10 +64,10 @@
double x_var = d.alpha() * sqr(d.beta());
double x_skew = 2 / std::sqrt(d.alpha());
double x_kurtosis = 6 / d.alpha();
- 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);
+ 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::gamma_distribution<> D;
@@ -104,10 +104,10 @@
double x_var = d.alpha() * sqr(d.beta());
double x_skew = 2 / std::sqrt(d.alpha());
double x_kurtosis = 6 / d.alpha();
- 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);
+ 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::gamma_distribution<> D;
@@ -144,9 +144,9 @@
double x_var = d.alpha() * sqr(d.beta());
double x_skew = 2 / std::sqrt(d.alpha());
double x_kurtosis = 6 / d.alpha();
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -65,10 +65,10 @@
double x_var = p.alpha() * sqr(p.beta());
double x_skew = 2 / std::sqrt(p.alpha());
double x_kurtosis = 6 / p.alpha();
- 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);
+ 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::gamma_distribution<> D;
@@ -106,10 +106,10 @@
double x_var = p.alpha() * sqr(p.beta());
double x_skew = 2 / std::sqrt(p.alpha());
double x_kurtosis = 6 / p.alpha();
- 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);
+ 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::gamma_distribution<> D;
@@ -147,9 +147,9 @@
double x_var = p.alpha() * sqr(p.beta());
double x_skew = 2 / std::sqrt(p.alpha());
double x_kurtosis = 6 / p.alpha();
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -63,10 +63,10 @@
double x_var = d.mean();
double x_skew = 1 / std::sqrt(x_var);
double x_kurtosis = 1 / x_var;
- 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);
+ 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::poisson_distribution<> D;
@@ -102,10 +102,10 @@
double x_var = d.mean();
double x_skew = 1 / std::sqrt(x_var);
double x_kurtosis = 1 / x_var;
- 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.04);
+ 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.04);
}
{
typedef std::poisson_distribution<> D;
@@ -141,9 +141,9 @@
double x_var = d.mean();
double x_skew = 1 / std::sqrt(x_var);
double x_kurtosis = 1 / x_var;
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -65,10 +65,10 @@
double x_var = p.mean();
double x_skew = 1 / std::sqrt(x_var);
double x_kurtosis = 1 / x_var;
- 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);
+ 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::poisson_distribution<> D;
@@ -106,10 +106,10 @@
double x_var = p.mean();
double x_skew = 1 / std::sqrt(x_var);
double x_kurtosis = 1 / x_var;
- 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.04);
+ 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.04);
}
{
typedef std::poisson_distribution<> D;
@@ -147,9 +147,9 @@
double x_var = p.mean();
double x_skew = 1 / std::sqrt(x_var);
double x_kurtosis = 1 / x_var;
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -68,10 +68,10 @@
double x_kurtosis = (sqr(sqr(d.b())) * std::tgamma(1 + 4/d.a()) -
4*x_skew*x_var*sqrt(x_var)*x_mean -
6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
- 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);
+ 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::weibull_distribution<> D;
@@ -112,10 +112,10 @@
double x_kurtosis = (sqr(sqr(d.b())) * std::tgamma(1 + 4/d.a()) -
4*x_skew*x_var*sqrt(x_var)*x_mean -
6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
- 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);
+ 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::weibull_distribution<> D;
@@ -156,9 +156,9 @@
double x_kurtosis = (sqr(sqr(d.b())) * std::tgamma(1 + 4/d.a()) -
4*x_skew*x_var*sqrt(x_var)*x_mean -
6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
- 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);
+ 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);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -69,10 +69,10 @@
double x_kurtosis = (sqr(sqr(p.b())) * std::tgamma(1 + 4/p.a()) -
4*x_skew*x_var*sqrt(x_var)*x_mean -
6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
- 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);
+ 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::weibull_distribution<> D;
@@ -114,10 +114,10 @@
double x_kurtosis = (sqr(sqr(p.b())) * std::tgamma(1 + 4/p.a()) -
4*x_skew*x_var*sqrt(x_var)*x_mean -
6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
- 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);
+ 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::weibull_distribution<> D;
@@ -159,9 +159,9 @@
double x_kurtosis = (sqr(sqr(p.b())) * std::tgamma(1 + 4/p.a()) -
4*x_skew*x_var*sqrt(x_var)*x_mean -
6*sqr(x_mean)*x_var - sqr(sqr(x_mean))) / sqr(x_var) - 3;
- 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);
+ 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.samp/rand.dist.samp.pconst/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// piecewise_constant_distribution& operator=(const piecewise_constant_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::piecewise_constant_distribution<> D;
+ double p[] = {2, 4, 1, 8};
+ double b[] = {2, 4, 5, 8, 9};
+ D d1(b, b+5, p);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+
+// piecewise_constant_distribution(const piecewise_constant_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::piecewise_constant_distribution<> D;
+ double p[] = {2, 4, 1, 8};
+ double b[] = {2, 4, 5, 8, 9};
+ D d1(b, b+5, p);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// piecewise_constant_distribution(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d;
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// template<class UnaryOperation>
+// piecewise_constant_distribution(size_t nw, result_type xmin,
+// result_type xmax, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return 2*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d(0, 0, 1, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d(1, 10, 12, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d(2, 6, 14, fw);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.1);
+ assert(dn[1] == 0.15);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// piecewise_constant_distribution(initializer_list<result_type> bl,
+// UnaryOperation fw);
+
+#include <iostream>
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+ return x*2;
+}
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d({}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d({12}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d({12, 14}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 12);
+ assert(iv[1] == 14);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d({5.5, 7.5, 11.5}, f);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 5.5);
+ assert(iv[1] == 7.5);
+ assert(iv[2] == 11.5);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.203125);
+ assert(dn[1] == 0.1484375);
+ }
+#endif
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_iterator.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// template<class InputIterator>
+// piecewise_constant_distribution(InputIteratorB firstB,
+// InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10};
+ double p[] = {12};
+ D d(b, b+1, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 15};
+ double p[] = {12};
+ D d(b, b+2, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1/5.);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75};
+ D d(b, b+3, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == .25/5.);
+ assert(dn[1] == .75);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ D d(b, b+4, p);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .0625);
+ assert(dn[1] == .3125);
+ assert(dn[2] == .125);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_param.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+
+// explicit piecewise_constant_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P pa(b, b+4, p);
+ D d(pa);
+ std::vector<double> iv = d.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = d.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .0625);
+ assert(dn[1] == .3125);
+ assert(dn[2] == .125);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eq.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// bool operator=(const piecewise_constant_distribution& x,
+// const piecewise_constant_distribution& y);
+// bool operator!(const piecewise_constant_distribution& x,
+// const piecewise_constant_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ D d1;
+ D d2;
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ D d1(b, b+4, p);
+ D d2(b, b+4, p);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ D d1(b, b+4, p);
+ D d2;
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,693 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 0, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 0, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 25, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {0, 0, 1};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {75, 25};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {0, 25};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16};
+ double p[] = {1, 0};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14};
+ double p[] = {1};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ const int N = 100000;
+ 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);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <iterator>
+#include <numeric>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d;
+ P pa(b, b+Np+1, p);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, pa);
+ assert(10 <= v && v < 17);
+ u.push_back(v);
+ }
+ std::vector<double> prob(std::begin(p), std::end(p));
+ double s = std::accumulate(prob.begin(), prob.end(), 0.0);
+ for (int i = 0; i < prob.size(); ++i)
+ prob[i] /= s;
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < Np; ++i)
+ {
+ typedef std::vector<D::result_type>::iterator I;
+ I lb = std::lower_bound(u.begin(), u.end(), b[i]);
+ I ub = std::lower_bound(u.begin(), u.end(), b[i+1]);
+ const size_t Ni = ub - lb;
+ if (prob[i] == 0)
+ assert(Ni == 0);
+ else
+ {
+ assert(std::abs((double)Ni/N - prob[i]) / prob[i] < .01);
+ double mean = std::accumulate(lb, ub, 0.0) / Ni;
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (I j = lb; j != ub; ++j)
+ {
+ double d = (*j - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= Ni;
+ double dev = std::sqrt(var);
+ skew /= Ni * dev * var;
+ kurtosis /= Ni * var * var;
+ kurtosis -= 3;
+ double x_mean = (b[i+1] + b[i]) / 2;
+ double x_var = sqr(b[i+1] - b[i]) / 12;
+ double x_skew = 0;
+ double x_kurtosis = -6./5;
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ }
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/get_param.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P pa(b, b+Np+1, p);
+ D d(pa);
+ assert(d.param() == pa);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/io.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const piecewise_constant_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// piecewise_constant_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d1(b, b+Np+1, p);
+ 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.samp/rand.dist.samp.pconst/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/max.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ assert(d.max() == 17);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/min.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ D d(b, b+Np+1, p);
+ assert(d.min() == 10);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_assign.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np+1, p);
+ P p1;
+ p1 = p0;
+ assert(p1 == p0);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_copy.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ const size_t Np = sizeof(p) / sizeof(p[0]);
+ P p0(b, b+Np+1, p);
+ P p1 = p0;
+ assert(p1 == p0);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_default.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+
+// param_type();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa;
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_func.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// template<class UnaryOperation>
+// param_type(size_t nw, double xmin, double xmax,
+// UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return 2*x;
+}
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa(0, 0, 1, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa(1, 10, 12, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 12);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa(2, 6, 14, fw);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 6);
+ assert(iv[1] == 10);
+ assert(iv[2] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.1);
+ assert(dn[1] == 0.15);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_init_func.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// param_type(initializer_list<result_type> bl, UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double f(double x)
+{
+ return x*2;
+}
+
+int main()
+{
+#ifdef _LIBCPP_MOVE
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({12}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({12, 14}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 12);
+ assert(iv[1] == 14);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 0.5);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ P pa({5.5, 7.5, 11.5}, f);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 5.5);
+ assert(iv[1] == 7.5);
+ assert(iv[2] == 11.5);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == 0.203125);
+ assert(dn[1] == 0.1484375);
+ }
+#endif
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_ctor_iterator.pass.cpp Thu May 20 10:11:46 2010
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 piecewise_constant_distribution
+
+// template<class InputIterator>
+// param_type(InputIteratorB firstB, InputIteratorB lastB,
+// InputIteratorW firstW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10};
+ double p[] = {12};
+ P pa(b, b+1, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 0);
+ assert(iv[1] == 1);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15};
+ double p[] = {12};
+ P pa(b, b+2, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 2);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 1);
+ assert(dn[0] == 1/5.);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 15, 16};
+ double p[] = {.25, .75};
+ P pa(b, b+3, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 3);
+ assert(iv[0] == 10);
+ assert(iv[1] == 15);
+ assert(iv[2] == 16);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 2);
+ assert(dn[0] == .25/5.);
+ assert(dn[1] == .75);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P pa(b, b+4, p);
+ std::vector<double> iv = pa.intervals();
+ assert(iv.size() == 4);
+ assert(iv[0] == 10);
+ assert(iv[1] == 14);
+ assert(iv[2] == 16);
+ assert(iv[3] == 17);
+ std::vector<double> dn = pa.densities();
+ assert(dn.size() == 3);
+ assert(dn[0] == .0625);
+ assert(dn[1] == .3125);
+ assert(dn[2] == .125);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_eq.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P p1(b, b+4, p);
+ P p2(b, b+4, p);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P p1(b, b+3, p);
+ P p2(b, b+4, p);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/param_types.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_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.samp/rand.dist.samp.pconst/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/set_param.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::param_type P;
+ double b[] = {10, 14, 16, 17};
+ double p[] = {25, 62.5, 12.5};
+ P pa(b, b+4, p);
+ D d;
+ d.param(pa);
+ assert(d.param() == pa);
+ }
+}
Added: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp?rev=104224&view=auto
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp (added)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/types.pass.cpp Thu May 20 10:11:46 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 RealType = double>
+// class piecewise_constant_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::piecewise_constant_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::piecewise_constant_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -65,10 +65,10 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_int_distribution<> D;
@@ -106,10 +106,10 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_int_distribution<> D;
@@ -147,10 +147,10 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_int_distribution<> D;
@@ -188,10 +188,10 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_int_distribution<> D;
@@ -229,10 +229,10 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_int_distribution<> D;
@@ -270,10 +270,10 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_int_distribution<> D;
@@ -311,10 +311,10 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_int_distribution<> D;
@@ -352,10 +352,10 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_int_distribution<> D;
@@ -393,10 +393,10 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_int_distribution<> D;
@@ -445,9 +445,9 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)d.b() - d.a() + 1) + 1) /
(5. * (sqr((double)d.b() - d.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -67,9 +67,9 @@
double x_skew = 0;
double x_kurtosis = -6. * (sqr((double)p.b() - p.a() + 1) + 1) /
(5. * (sqr((double)p.b() - p.a() + 1) - 1));
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval.pass.cpp Thu May 20 10:11:46 2010
@@ -64,10 +64,10 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -104,10 +104,10 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -144,10 +144,10 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -184,10 +184,10 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -224,10 +224,10 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.02);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -264,10 +264,10 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -304,10 +304,10 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -344,10 +344,10 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -384,10 +384,10 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -425,9 +425,9 @@
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
assert(std::abs(mean - x_mean) < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
assert(std::abs(skew - x_skew) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
{
typedef std::uniform_real_distribution<> D;
@@ -464,9 +464,9 @@
D::result_type x_var = sqr(d.b() - d.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/eval_param.pass.cpp Thu May 20 10:11:46 2010
@@ -66,9 +66,9 @@
D::result_type x_var = sqr(p.b() - p.a()) / 12;
D::result_type x_skew = 0;
D::result_type x_kurtosis = -6./5;
- assert(std::abs(mean - x_mean) / x_mean < 0.01);
- assert(std::abs(var - x_var) / x_var < 0.01);
+ 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) < 0.01);
- assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
}
}
Modified: libcxx/trunk/test/numerics/rand/rand.predef/default_random_engine.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/numerics/rand/rand.predef/default_random_engine.pass.cpp?rev=104224&r1=104223&r2=104224&view=diff
==============================================================================
--- libcxx/trunk/test/numerics/rand/rand.predef/default_random_engine.pass.cpp (original)
+++ libcxx/trunk/test/numerics/rand/rand.predef/default_random_engine.pass.cpp Thu May 20 10:11:46 2010
@@ -20,5 +20,5 @@
{
std::default_random_engine e;
e.discard(9999);
- assert(e() == 1043618065u);
+ assert(e() == 399268537u);
}
More information about the cfe-commits
mailing list