[libcxx] r224658 - Move test into test/std subdirectory.
Eric Fiselier
eric at efcs.ca
Fri Dec 19 17:40:31 PST 2014
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.assign/slice_array.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// const slice_array& operator=(const slice_array& sa) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ const std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] = v2[std::slice(2, 5, 2)];
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -3);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -5);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -7);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -9);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -11);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+ }
+ // Test return value of assignment.
+ {
+ int a1[] = {0, 1, 2};
+ int a2[] = {3, 4, 3};
+ std::valarray<int> v1(a1, 3);
+ std::slice_array<int> s1 = v1[std::slice(1, 1, 1)];
+ std::slice_array<int> s2 = v1[std::slice(0, 1, 1)];
+ std::slice_array<int> const & s3 = (s1 = s2);
+ assert(&s1 == &s3);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.assign/valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] = v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -2);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -3);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -4);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -5);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/addition.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator+= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] += v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 0);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 2);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 6);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 8);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/and.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator&= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] &= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 3);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 0);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 5);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/divide.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator/= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] /= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -2);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -2);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -2);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -2);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/modulo.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator%= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] %= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 0);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 0);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 1);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 2);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 3);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/multiply.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator*= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] *= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -8);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -21);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -40);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -65);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/or.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator|= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] |= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 7);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 14);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 13);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_left.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator<<=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] <<= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 2);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 16);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 56);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 160);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 416);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/shift_right.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator>>=(const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] >>= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 0);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 1);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 0);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 0);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 0);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/subtraction.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator-= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] -= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 2);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 10);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 14);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 18);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.comp.assign/xor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator^= (const valarray<value_type>& v) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {1, 2, 3, 4, 5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] ^= v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 0);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 6);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 4);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 14);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 8);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/slice.arr.fill/assign_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T> class slice_array
+
+// void operator=(const value_type& x) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ v1[std::slice(1, 5, 3)] = 20;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 20);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == 20);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == 20);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == 20);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == 20);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.slice.array/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.slice.array/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.slice.array/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.slice.array/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template <class T>
+// class slice_array
+// {
+// public:
+// typedef T value_type;
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::slice_array<int>::value_type, int>::value), "");
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T>
+// class valarray
+// {
+// public:
+// typedef T value_type;
+// ...
+
+#include <valarray>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::valarray<int>::value_type, int>::value), "");
+ static_assert((std::is_same<std::valarray<double>::value_type, double>::value), "");
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.access/access.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type& operator[](size_t i);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {5, 4, 3, 2, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v[i] == a[i]);
+ v[i] = i;
+ assert(v[i] == i);
+ }
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.access/const_access.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// const value_type& operator[](size_t i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {5, 4, 3, 2, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ const std::valarray<T> v(a, N);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v[i] == a[i]);
+ }
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/copy_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2;
+ v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2;
+ v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2(a, N-2);
+ v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == v[i][j]);
+ }
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/gslice_array_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const gslice_array<value_type>& ga);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ std::valarray<int> v(24);
+ v = v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))];
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/indirect_array_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const indirect_array<value_type>& ia);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ std::valarray<int> v1(a, N1);
+ std::valarray<std::size_t> ia(s, S);
+ std::valarray<int> v(24);
+ v = v1[ia];
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/initializer_list_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(initializer_list<value_type> il);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v2;
+ v2 = {1, 2, 3, 4, 5};
+ assert(v2.size() == N);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v2;
+ v2 = {1, 2.5, 3, 4.25, 5};
+ assert(v2.size() == N);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v2(a, N-2);
+ v2 = {T(1), T(2), T(3), T(4), T(5)};
+ assert(v2.size() == N);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == a[i].size());
+ for (int j = 0; j < a[i].size(); ++j)
+ assert(v2[i][j] == a[i][j]);
+ }
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/mask_array_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const mask_array<value_type>& ma);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<bool> vb(b, N1);
+ std::valarray<int> v2(5);
+ v2 = v1[vb];
+ assert(v2.size() == 5);
+ assert(v2[ 0] == 0);
+ assert(v2[ 1] == 3);
+ assert(v2[ 2] == 4);
+ assert(v2[ 3] == 7);
+ assert(v2[ 4] == 11);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/move_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(valarray&& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2;
+ v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2;
+ v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2(a, N-2);
+ v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == a[i].size());
+ for (int j = 0; j < a[i].size(); ++j)
+ assert(v2[i][j] == a[i][j]);
+ }
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/slice_array_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const slice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::valarray<int> v(5);
+ v = v1[std::slice(1, 5, 3)];
+ assert(v.size() == 5);
+ assert(v[0] == 1);
+ assert(v[1] == 4);
+ assert(v[2] == 7);
+ assert(v[3] == 10);
+ assert(v[4] == 13);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.assign/value_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ v = 7;
+ assert(v.size() == N);
+ for (int i = 0; i < v.size(); ++i)
+ assert(v[i] == 7);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/and_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator&=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {0, 2, 0, 0, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 &= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/and_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator&=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 1, 2, 3, 0, 1};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 &= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator/=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {6, 14, 24, 36, 50};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v3 /= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/divide_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator/=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 12, 18, 24, 30};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v2 /= 6;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator-=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 9, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v3 -= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/minus_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator-=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = {-2, -1, 0, 1, 2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 -= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator%=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {0, 1, 2, 1, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v2 %= v1;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v2[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/modulo_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator%=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {1, 2, 0, 1, 2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 %= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/or_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator|=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 7, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 |= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/or_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator|=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 3, 3, 3, 7, 7};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 |= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator+=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 9, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 += v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/plus_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator+=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {4, 5, 6, 7, 8};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 += 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator<<=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 6, 7, 8, 9, 10};
+ T a3[] = {64, 256, 768, 2048, 5120};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 <<= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_left_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator<<=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 8, 16, 24, 32, 40};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 <<= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator>>=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 6, 7, 8, 9, 10};
+ T a3[] = {64, 256, 768, 2048, 5120};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v3 >>= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/shift_right_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator>>=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 8, 16, 24, 32, 40};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v2 >>= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/times_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator*=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {6, 14, 24, 36, 50};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 *= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/times_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator*=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 12, 18, 24, 30};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 *= 6;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator^=(const valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 5, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3(a3, N);
+ v1 ^= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cassign/xor_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray& operator^=(const value_type& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 2, 1, 0, 7, 6};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ v1 ^= 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const valarray<value_type>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == v[i][j]);
+ }
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray();
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ std::valarray<int> v;
+ assert(v.size() == 0);
+ }
+ {
+ std::valarray<float> v;
+ assert(v.size() == 0);
+ }
+ {
+ std::valarray<double> v;
+ assert(v.size() == 0);
+ }
+ {
+ std::valarray<std::valarray<double> > v;
+ assert(v.size() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/gslice_array.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const gslice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ std::valarray<int> v(v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))]);
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/indirect_array.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const indirect_array<value_type>& ia);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ std::valarray<int> v1(a, N1);
+ std::valarray<std::size_t> ia(s, S);
+ std::valarray<int> v(v1[ia]);
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/initializer_list.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(initializer_list<value_type>);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v = {1, 2, 3, 4, 5};
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ assert(v[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v = {1, 2, 3, 4, 5};
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ assert(v[i] == a[i]);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/mask_array.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const mask_array<value_type>& ma);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<bool> vb(b, N1);
+ std::valarray<int> v2(v1[vb]);
+ assert(v2.size() == 5);
+ assert(v2[ 0] == 0);
+ assert(v2[ 1] == 3);
+ assert(v2[ 2] == 4);
+ assert(v2[ 3] == 7);
+ assert(v2[ 4] == 11);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const valarray<value_type>& v);
+
+#include <valarray>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = std::move(v);
+ assert(v2.size() == N);
+ assert(v.size() == 0);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == a[i].size());
+ for (int j = 0; j < v2[i].size(); ++j)
+ assert(v2[i][j] == a[i][j]);
+ }
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/pointer_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const value_type* p, size_t n);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ assert(v[i] == a[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ assert(v[i] == a[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ assert(v.size() == N);
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v[i].size() == a[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v[i][j] == a[i][j]);
+ }
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// explicit valarray(size_t);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ std::valarray<int> v(100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i] == 0);
+ }
+ {
+ std::valarray<double> v(100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i] == 0);
+ }
+ {
+ std::valarray<std::valarray<double> > v(100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i].size() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/slice_array.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const slice_array<value_type>& sa);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::valarray<int> v(v1[std::slice(1, 5, 3)]);
+ assert(v.size() == 5);
+ assert(v[0] == 1);
+ assert(v[1] == 4);
+ assert(v[2] == 7);
+ assert(v[3] == 10);
+ assert(v[4] == 13);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.cons/value_size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray(const value_type& x, size_t n);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ std::valarray<int> v(5, 100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i] == 5);
+ }
+ {
+ std::valarray<double> v(2.5, 100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i] == 2.5);
+ }
+ {
+ std::valarray<std::valarray<double> > v(std::valarray<double>(10), 100);
+ assert(v.size() == 100);
+ for (int i = 0; i < 100; ++i)
+ assert(v[i].size() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/apply_cref.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray apply(value_type f(const value_type&)) const;
+
+#include <valarray>
+#include <cassert>
+
+typedef int T;
+
+T f(const T& t) {return t + 5;}
+
+int main()
+{
+ {
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.apply(f);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2 = v1.apply(f);
+ assert(v2.size() == N1);
+ }
+ {
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {7, 9, 11, 13, 15, 17, 19, 21, 23, 25};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1+v1).apply(f);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/apply_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray apply(value_type f(value_type)) const;
+
+#include <valarray>
+#include <cassert>
+
+typedef int T;
+
+T f(T t) {return t + 5;}
+
+int main()
+{
+ {
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.apply(f);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2 = v1.apply(f);
+ assert(v2.size() == N1);
+ }
+ {
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {7, 9, 11, 13, 15, 17, 19, 21, 23, 25};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1+v1).apply(f);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/cshift.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray cshift(int i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(0);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {4, 5, 6, 7, 8, 9, 10, 1, 2, 3};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(10);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(17);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {8, 9, 10, 1, 2, 3, 4, 5, 6, 7};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(-3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(-10);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {4, 5, 6, 7, 8, 9, 10, 1, 2, 3};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.cshift(-17);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2 = v1.cshift(-17);
+ assert(v2.size() == N1);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {8, 10, 12, 14, 16, 18, 20, 2, 4, 6};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1 + v1).cshift(3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {16, 18, 20, 2, 4, 6, 8, 10, 12, 14};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1 + v1).cshift(-3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type max() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, -3, 4, -5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert(v1.max() == 4.0);
+ }
+ {
+ typedef double T;
+ std::valarray<T> v1;
+ v1.max();
+ }
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, -3, 4, -5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert((2*v1).max() == 8.0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type min() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, -3, 4, 5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert(v1.min() == -3.0);
+ }
+ {
+ typedef double T;
+ std::valarray<T> v1;
+ v1.min();
+ }
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, -3, 4, 5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert((2*v1).min() == -6.0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/resize.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// void resize(size_t n, value_type x = value_type());
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ v1.resize(8);
+ assert(v1.size() == 8);
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == 0);
+ v1.resize(0);
+ assert(v1.size() == 0);
+ v1.resize(80);
+ assert(v1.size() == 80);
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == 0);
+ v1.resize(40);
+ assert(v1.size() == 40);
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/shift.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray shift(int i) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(0);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(1);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {10, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(9);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(90);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(-1);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(-9);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = v1.shift(-90);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2 = v1.shift(-90);
+ assert(v2.size() == N1);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {8, 10, 12, 14, 16, 18, 20, 0, 0, 0};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1 + v1).shift(3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ T a2[] = {0, 0, 0, 2, 4, 6, 8, 10, 12, 14};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2 = (v1 + v1).shift(-3);
+ assert(v2.size() == N1);
+ for (unsigned i = 0; i < N1; ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/size.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/size.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/size.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/size.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// size_t size() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert(v1.size() == N1);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = 0;
+ std::valarray<T> v1(a1, N1);
+ assert(v1.size() == N1);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ std::valarray<T> v1;
+ assert(v1.size() == N1);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/sum.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// value_type sum() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {1.5, 2.5, 3, 4, 5.5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N1);
+ assert(v1.sum() == 16.5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.members/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// void swap(valarray& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10, 11, 12};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2(a2, N2);
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ v1.swap(v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ const unsigned N2 = 0;
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2;
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ v1.swap(v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ T a2[] = {6, 7, 8, 9, 10, 11, 12};
+ const unsigned N1 = 0;
+ const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v1;
+ std::valarray<T> v2(a2, N2);
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ v1.swap(v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ const unsigned N2 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2;
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ v1.swap(v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// gslice_array<value_type> operator[](const gslice& gs);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ int a2[] = { -0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11,
+ -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))] = v2;
+ assert(v1.size() == 41);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == 1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 0);
+ assert(v1[ 4] == -1);
+ assert(v1[ 5] == -2);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -3);
+ assert(v1[ 8] == -4);
+ assert(v1[ 9] == -5);
+ assert(v1[10] == 10);
+ assert(v1[11] == -6);
+ assert(v1[12] == -7);
+ assert(v1[13] == -8);
+ assert(v1[14] == 14);
+ assert(v1[15] == -9);
+ assert(v1[16] == -10);
+ assert(v1[17] == -11);
+ assert(v1[18] == 18);
+ assert(v1[19] == 19);
+ assert(v1[20] == 20);
+ assert(v1[21] == 21);
+ assert(v1[22] == -12);
+ assert(v1[23] == -13);
+ assert(v1[24] == -14);
+ assert(v1[25] == 25);
+ assert(v1[26] == -15);
+ assert(v1[27] == -16);
+ assert(v1[28] == -17);
+ assert(v1[29] == 29);
+ assert(v1[30] == -18);
+ assert(v1[31] == -19);
+ assert(v1[32] == -20);
+ assert(v1[33] == 33);
+ assert(v1[34] == -21);
+ assert(v1[35] == -22);
+ assert(v1[36] == -23);
+ assert(v1[37] == 37);
+ assert(v1[38] == 38);
+ assert(v1[39] == 39);
+ assert(v1[40] == 40);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/gslice_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const gslice& gs) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ std::valarray<int> v1(a, sizeof(a)/sizeof(a[0]));
+ std::size_t sz[] = {2, 4, 3};
+ std::size_t st[] = {19, 4, 1};
+ typedef std::valarray<std::size_t> sizes;
+ typedef std::valarray<std::size_t> strides;
+ std::valarray<int> v(v1[std::gslice(3, sizes(sz, sizeof(sz)/sizeof(sz[0])),
+ strides(st, sizeof(st)/sizeof(st[0])))]);
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const valarray<size_t>& vs) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ const std::valarray<int> v1(a, N1);
+ std::valarray<std::size_t> ia(s, S);
+ std::valarray<int> v = v1[ia];
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/indirect_array_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// indirect_array<value_type> operator[](const valarray<size_t>& vs);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
+ 36, 37, 38, 39, 40};
+ const std::size_t N1 = sizeof(a)/sizeof(a[0]);
+ std::size_t s[] = { 3, 4, 5, 7, 8, 9, 11, 12, 13, 15, 16, 17,
+ 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36};
+ const std::size_t S = sizeof(s)/sizeof(s[0]);
+ std::valarray<int> v1(a, N1);
+ std::valarray<std::size_t> ia(s, S);
+ std::valarray<int> v(24);
+ v = v1[ia];
+ assert(v.size() == 24);
+ assert(v[ 0] == 3);
+ assert(v[ 1] == 4);
+ assert(v[ 2] == 5);
+ assert(v[ 3] == 7);
+ assert(v[ 4] == 8);
+ assert(v[ 5] == 9);
+ assert(v[ 6] == 11);
+ assert(v[ 7] == 12);
+ assert(v[ 8] == 13);
+ assert(v[ 9] == 15);
+ assert(v[10] == 16);
+ assert(v[11] == 17);
+ assert(v[12] == 22);
+ assert(v[13] == 23);
+ assert(v[14] == 24);
+ assert(v[15] == 26);
+ assert(v[16] == 27);
+ assert(v[17] == 28);
+ assert(v[18] == 30);
+ assert(v[19] == 31);
+ assert(v[20] == 32);
+ assert(v[21] == 34);
+ assert(v[22] == 35);
+ assert(v[23] == 36);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/slice_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](slice s) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2 = v1[std::slice(1, 5, 3)];
+ assert(v2.size() == 5);
+ assert(v2[0] == 1);
+ assert(v2[1] == 4);
+ assert(v2[2] == 7);
+ assert(v2[3] == 10);
+ assert(v2[4] == 13);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/slice_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// slice_array<value_type> operator[](slice s);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ int a2[] = {-1, -2, -3, -4, -5};
+ std::valarray<int> v1(a1, sizeof(a1)/sizeof(a1[0]));
+ std::valarray<int> v2(a2, sizeof(a2)/sizeof(a2[0]));
+ v1[std::slice(1, 5, 3)] = v2;
+ assert(v1.size() == 16);
+ assert(v1[ 0] == 0);
+ assert(v1[ 1] == -1);
+ assert(v1[ 2] == 2);
+ assert(v1[ 3] == 3);
+ assert(v1[ 4] == -2);
+ assert(v1[ 5] == 5);
+ assert(v1[ 6] == 6);
+ assert(v1[ 7] == -3);
+ assert(v1[ 8] == 8);
+ assert(v1[ 9] == 9);
+ assert(v1[10] == -4);
+ assert(v1[11] == 11);
+ assert(v1[12] == 12);
+ assert(v1[13] == -5);
+ assert(v1[14] == 14);
+ assert(v1[15] == 15);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator[](const valarray<bool>& vb) const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<bool> vb(b, N1);
+ std::valarray<int> v2(v1[vb]);
+ assert(v2.size() == 5);
+ assert(v2[ 0] == 0);
+ assert(v2[ 1] == 3);
+ assert(v2[ 2] == 4);
+ assert(v2[ 3] == 7);
+ assert(v2[ 4] == 11);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.sub/valarray_bool_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// mask_array<value_type> operator[](const valarray<bool>& vb);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ const std::size_t N1 = sizeof(a1)/sizeof(a1[0]);
+ bool b[N1] = {true, false, false, true, true, false,
+ false, true, false, false, false, true};
+ std::valarray<int> v1(a1, N1);
+ std::valarray<bool> vb(b, N1);
+ std::valarray<int> v2(5);
+ v2 = v1[vb];
+ assert(v2.size() == 5);
+ assert(v2[ 0] == 0);
+ assert(v2[ 1] == 3);
+ assert(v2[ 2] == 4);
+ assert(v2[ 3] == 7);
+ assert(v2[ 4] == 11);
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/bit_not.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator~() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = ~v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == ~v[i]);
+ }
+ {
+ typedef std::valarray<int> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = ~v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == ~v[i][j]);
+ }
+ }
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = ~(v + v);
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == ~(2*v[i]));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/negate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator-() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = -v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == -v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = -v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == -v[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = -v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == -v[i][j]);
+ }
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = -(v + v);
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == -2*v[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/not.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray<bool> operator!() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<bool> v2 = !v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == !v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<bool> v2 = !(v + v);
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == !2*v[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/template.valarray/valarray.unary/plus.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// valarray operator+() const;
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = +v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == +v[i]);
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = +v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == +v[i]);
+ }
+ {
+ typedef std::valarray<double> T;
+ T a[] = {T(1), T(2), T(3), T(4), T(5)};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = +v;
+ assert(v2.size() == v.size());
+ for (int i = 0; i < N; ++i)
+ {
+ assert(v2[i].size() == v[i].size());
+ for (int j = 0; j < v[i].size(); ++j)
+ assert(v2[i][j] == +v[i][j]);
+ }
+ }
+ {
+ typedef double T;
+ T a[] = {1, 2.5, 3, 4.25, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ std::valarray<T> v2 = +(v + v);
+ assert(v2.size() == v.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == +2*v[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {0, 2, 0, 0, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 & v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 1, 2, 3, 0, 1};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 & 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator&(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 1, 2, 3, 0, 1};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 & v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {6, 14, 24, 36, 50};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 / v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {6, 12, 18, 24, 30};
+ T a2[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 / 6;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator/(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {3, 1, 1, 0, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 / v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {7, 9, 11, 13, 15};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 - v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = {-2, -1, 0, 1, 2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 - 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator-(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 2, 1, 0, -1, -2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 - v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {6, 7, 8, 9, 10};
+ T a2[] = {1, 2, 3, 4, 5};
+ T a3[] = {0, 1, 2, 1, 0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 % v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {1, 2, 0, 1, 2};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 % 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator%(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {0, 1, 0, 3, 3};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 % v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 7, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 | v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 3, 3, 3, 7, 7};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 | 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator|(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 3, 3, 3, 7, 7};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 | v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 9, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 + v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {4, 5, 6, 7, 8};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 + 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {4, 5, 6, 7, 8};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 + v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 6, 7, 8, 9, 10};
+ T a3[] = {64, 256, 768, 2048, 5120};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 << v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 8, 16, 24, 32, 40};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 << 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 6, 12, 24, 48, 96};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 << v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {64, 256, 768, 2048, 5120};
+ T a2[] = { 6, 7, 8, 9, 10};
+ T a3[] = { 1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 >> v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 8, 16, 24, 32, 40};
+ T a2[] = { 1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 >> 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = {20, 10, 5, 2, 1};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 40 >> v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator*(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {6, 14, 24, 36, 50};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 * v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator+(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 12, 18, 24, 30};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 * 6;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator*(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 12, 18, 24, 30};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 6 * v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10};
+ T a3[] = {7, 5, 11, 13, 15};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = v1 ^ v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 2, 1, 0, 7, 6};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = v1 ^ 3;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T> valarray<T> operator^(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = { 1, 2, 3, 4, 5};
+ T a2[] = { 2, 1, 0, 7, 6};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2 = 3 ^ v1;
+ assert(v1.size() == v2.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == a2[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator&&(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ T a2[] = {6, 7, 0, 9, 10};
+ bool a3[] = {true, true, false, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 && v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator&&(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 && 5;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, false, false, false, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 && 0;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/and_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator&&(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 5 && v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, false, false, false, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 0 && v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator==(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 9, 10};
+ bool a3[] = {false, false, true, false, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 == v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator==(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, true, false, false, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 == 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/equal_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator==(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, true, false, false, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 == v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 2, 1};
+ bool a3[] = {false, false, true, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 >= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, true, true, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 >= 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_equal_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, false, false, true};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 >= v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 2, 1};
+ bool a3[] = {false, false, false, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 > v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, false, true, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 > 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/greater_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator>(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, false, false, false, true};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 > v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 2, 1};
+ bool a3[] = {true, true, true, false, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 <= v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, false, false, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 <= 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_equal_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, true, true, true, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 <= v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 2, 1};
+ bool a3[] = {true, true, false, false, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 < v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, false, false, false, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 < 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/less_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator<(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {false, false, true, true, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 < v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator!=(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 10};
+ T a2[] = {6, 7, 0, 9, 10};
+ bool a3[] = {true, true, false, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 != v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator!=(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, false, true, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 != 2;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/not_equal_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator!=(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, false, true, true, true};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 2 != v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator||(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 0, 4, 0};
+ T a2[] = {6, 7, 0, 9, 10};
+ bool a3[] = {true, true, false, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = v1 || v2;
+ assert(v1.size() == v2.size());
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator||(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, true};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 || 5;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, false};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<bool> v3 = v1 || 0;
+ assert(v1.size() == v3.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.comparison/or_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<bool>
+// operator||(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, true};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 5 || v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+ {
+ typedef int T;
+ T a2[] = {1, 2, 3, 4, 0};
+ bool a3[] = {true, true, true, true, false};
+ const unsigned N = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v2(a2, N);
+ std::valarray<bool> v3 = 0 || v2;
+ assert(v2.size() == v3.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.special/swap.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// void
+// swap(valarray<T>& x, valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ T a2[] = {6, 7, 8, 9, 10, 11, 12};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2(a2, N2);
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ swap(v1, v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ T a1[] = {1, 2, 3, 4, 5};
+ const unsigned N1 = sizeof(a1)/sizeof(a1[0]);
+ const unsigned N2 = 0;
+ std::valarray<T> v1(a1, N1);
+ std::valarray<T> v2;
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ swap(v1, v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ T a2[] = {6, 7, 8, 9, 10, 11, 12};
+ const unsigned N1 = 0;
+ const unsigned N2 = sizeof(a2)/sizeof(a2[0]);
+ std::valarray<T> v1;
+ std::valarray<T> v2(a2, N2);
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ swap(v1, v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+ {
+ typedef int T;
+ const unsigned N1 = 0;
+ const unsigned N2 = 0;
+ std::valarray<T> v1;
+ std::valarray<T> v2;
+ std::valarray<T> v1_save = v1;
+ std::valarray<T> v2_save = v2;
+ swap(v1, v2);
+ assert(v1.size() == v2_save.size());
+ for (int i = 0; i < v1.size(); ++i)
+ assert(v1[i] == v2_save[i]);
+ assert(v2.size() == v1_save.size());
+ for (int i = 0; i < v2.size(); ++i)
+ assert(v2[i] == v1_save[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/abs_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// abs(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {1.5, -2.5, 3.4, -4.5, -5.0};
+ T a3[] = {1.5, 2.5, 3.4, 4.5, 5.0};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = abs(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(v3[i] == a3[i]);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/acos_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// acos(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {2.6905658417935308e+00,
+ 2.0943951023931957e+00,
+ 1.5707963267948966e+00,
+ 1.0471975511965976e+00,
+ 7.2273424781341566e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = acos(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/asin_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// asin(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-1.1197695149986342e+00,
+ -5.2359877559829882e-01,
+ 0.0000000000000000e+00,
+ 5.2359877559829882e-01,
+ 8.4806207898148100e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = asin(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// atan2(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a2[] = {-.8, .25, 0.375, -.5, .75};
+ T a3[] = {-2.2974386674766221e+00,
+ -1.1071487177940904e+00,
+ 0.0000000000000000e+00,
+ 2.3561944901923448e+00,
+ 7.8539816339744828e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = atan2(v1, v2);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// atan2(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-8.7605805059819342e-01,
+ -5.8800260354756750e-01,
+ 0.0000000000000000e+00,
+ 5.8800260354756750e-01,
+ 7.8539816339744828e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = atan2(v1, .75);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan2_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// atan2(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {2.4468543773930902e+00,
+ 2.1587989303424640e+00,
+ 1.5707963267948966e+00,
+ 9.8279372324732905e-01,
+ 7.8539816339744828e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = atan2(.75, v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/atan_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// atan(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-7.3281510178650666e-01,
+ -4.6364760900080615e-01,
+ 0.0000000000000000e+00,
+ 4.6364760900080615e-01,
+ 6.4350110879328437e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = atan(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cos_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// cos(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {6.2160996827066450e-01,
+ 8.7758256189037276e-01,
+ 1.0000000000000000e+00,
+ 8.7758256189037276e-01,
+ 7.3168886887382090e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = cos(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/cosh_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// cosh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {1.4330863854487743e+00,
+ 1.1276259652063807e+00,
+ 1.0000000000000000e+00,
+ 1.1276259652063807e+00,
+ 1.2946832846768448e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = cosh(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/exp_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// exp(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {4.0656965974059911e-01,
+ 6.0653065971263342e-01,
+ 1.0000000000000000e+00,
+ 1.6487212707001282e+00,
+ 2.1170000166126748e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = exp(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log10_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// log10(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.5, .75, 1, 3, 7};
+ T a3[] = {-3.0102999566398120e-01,
+ -1.2493873660829995e-01,
+ 0.0000000000000000e+00,
+ 4.7712125471966244e-01,
+ 8.4509804001425681e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = log10(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/log_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// log(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.5, .75, 1, 3, 7};
+ T a3[] = {-6.9314718055994529e-01,
+ -2.8768207245178090e-01,
+ 0.0000000000000000e+00,
+ 1.0986122886681098e+00,
+ 1.9459101490553132e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = log(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// pow(const valarray<T>& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.9, .5, 0., .5, .75};
+ T a2[] = {-.8, .25, 0.375, -.5, .75};
+ T a3[] = {1.0879426248455297e+00,
+ 8.4089641525371450e-01,
+ 0.0000000000000000e+00,
+ 1.4142135623730949e+00,
+ 8.0592744886765644e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v2(a2, N);
+ std::valarray<T> v3 = pow(v1, v2);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_valarray_value.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// pow(const valarray<T>& x, const T& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.9, .5, 0., .5, .75};
+ T a3[] = {8.1000000000000005e-01,
+ 2.5000000000000000e-01,
+ 0.0000000000000000e+00,
+ 2.5000000000000000e-01,
+ 5.6250000000000000e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = pow(v1, 2.0);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/pow_value_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// pow(const T& x, const valarray<T>& y);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.9, .5, 0., .5, .75};
+ T a3[] = {1.8660659830736148e+00,
+ 1.4142135623730951e+00,
+ 1.0000000000000000e+00,
+ 1.4142135623730951e+00,
+ 1.6817928305074290e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = pow(2.0, v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sin_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// sin(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-7.8332690962748330e-01,
+ -4.7942553860420301e-01,
+ 0.0000000000000000e+00,
+ 4.7942553860420301e-01,
+ 6.8163876002333423e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = sin(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sinh_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// sinh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-1.0265167257081753e+00,
+ -5.2109530549374738e-01,
+ 0.0000000000000000e+00,
+ 5.2109530549374738e-01,
+ 8.2231673193582999e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = sinh(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/sqrt_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// sqrt(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {.5, .75, 1, 3, 7};
+ T a3[] = {7.0710678118654757e-01,
+ 8.6602540378443860e-01,
+ 1.0000000000000000e+00,
+ 1.7320508075688772e+00,
+ 2.6457513110645907e+00};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = sqrt(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tan_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// tan(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-1.2601582175503390e+00,
+ -5.4630248984379048e-01,
+ 0.0000000000000000e+00,
+ 5.4630248984379048e-01,
+ 9.3159645994407259e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = tan(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.nonmembers/valarray.transcend/tanh_valarray.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template<class T>
+// valarray<T>
+// tanh(const valarray<T>& x);
+
+#include <valarray>
+#include <cassert>
+#include <sstream>
+
+bool is_about(double x, double y, int p)
+{
+ std::ostringstream o;
+ o.precision(p);
+ scientific(o);
+ o << x;
+ std::string a = o.str();
+ o.str("");
+ o << y;
+ return a == o.str();
+}
+
+int main()
+{
+ {
+ typedef double T;
+ T a1[] = {-.9, -.5, 0., .5, .75};
+ T a3[] = {-7.1629787019902447e-01,
+ -4.6211715726000974e-01,
+ 0.0000000000000000e+00,
+ 4.6211715726000974e-01,
+ 6.3514895238728730e-01};
+ const unsigned N = sizeof(a1)/sizeof(a1[0]);
+ std::valarray<T> v1(a1, N);
+ std::valarray<T> v3 = tanh(v1);
+ assert(v3.size() == v1.size());
+ for (int i = 0; i < v3.size(); ++i)
+ assert(is_about(v3[i], a3[i], 10));
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.range/begin_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.range/begin_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.range/begin_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.range/begin_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+// unspecified1
+// begin(const valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ const std::valarray<T> v(a, N);
+ assert(v[0] == 1);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.range/begin_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.range/begin_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.range/begin_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.range/begin_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+// unspecified1
+// begin(valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ *begin(v) = 10;
+ assert(v[0] == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.range/end_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.range/end_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.range/end_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.range/end_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+// unspecified1
+// end(const valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ const std::valarray<T> v(a, N);
+ assert(v[v.size()-1] == 5);
+ assert(end(v) - begin(v) == v.size());
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.range/end_non_const.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.range/end_non_const.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.range/end_non_const.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.range/end_non_const.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+// template<class T> class valarray;
+
+// template <class T>
+// unspecified1
+// end(valarray<T>& v);
+
+#include <valarray>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef int T;
+ T a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::valarray<T> v(a, N);
+ *(end(v) - 1) = 10;
+ assert(v[v.size()-1] == 10);
+ assert(end(v) - begin(v) == v.size());
+ }
+}
Added: libcxx/trunk/test/std/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/valarray.syn/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/numarray/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numarray/version.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numarray/version.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numarray/version.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <valarray>
+
+#include <valarray>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/accumulate/accumulate.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter, MoveConstructible T>
+// requires HasPlus<T, Iter::reference>
+// && HasAssign<T, HasPlus<T, Iter::reference>::result_type>
+// T
+// accumulate(Iter first, Iter last, T init);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, T init, T x)
+{
+ assert(std::accumulate(first, last, init) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5, 6};
+ unsigned sa = sizeof(ia) / sizeof(ia[0]);
+ test(Iter(ia), Iter(ia), 0, 0);
+ test(Iter(ia), Iter(ia), 10, 10);
+ test(Iter(ia), Iter(ia+1), 0, 1);
+ test(Iter(ia), Iter(ia+1), 10, 11);
+ test(Iter(ia), Iter(ia+2), 0, 3);
+ test(Iter(ia), Iter(ia+2), 10, 13);
+ test(Iter(ia), Iter(ia+sa), 0, 21);
+ test(Iter(ia), Iter(ia+sa), 10, 31);
+}
+
+int main()
+{
+ test<input_iterator<const int*> >();
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/accumulate/accumulate_op.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter, MoveConstructible T,
+// Callable<auto, const T&, Iter::reference> BinaryOperation>
+// requires HasAssign<T, BinaryOperation::result_type>
+// && CopyConstructible<BinaryOperation>
+// T
+// accumulate(Iter first, Iter last, T init, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter, class T>
+void
+test(Iter first, Iter last, T init, T x)
+{
+ assert(std::accumulate(first, last, init, std::multiplies<T>()) == x);
+}
+
+template <class Iter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5, 6};
+ unsigned sa = sizeof(ia) / sizeof(ia[0]);
+ test(Iter(ia), Iter(ia), 1, 1);
+ test(Iter(ia), Iter(ia), 10, 10);
+ test(Iter(ia), Iter(ia+1), 1, 1);
+ test(Iter(ia), Iter(ia+1), 10, 10);
+ test(Iter(ia), Iter(ia+2), 1, 2);
+ test(Iter(ia), Iter(ia+2), 10, 20);
+ test(Iter(ia), Iter(ia+sa), 1, 720);
+ test(Iter(ia), Iter(ia+sa), 10, 7200);
+}
+
+int main()
+{
+ test<input_iterator<const int*> >();
+ test<forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*> >();
+ test<const int*>();
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter,
+// OutputIterator<auto, const InIter::value_type&> OutIter>
+// requires HasMinus<InIter::value_type, InIter::value_type>
+// && Constructible<InIter::value_type, InIter::reference>
+// && OutputIterator<OutIter,
+// HasMinus<InIter::value_type, InIter::value_type>::result_type>
+// && MoveAssignable<InIter::value_type>
+// OutIter
+// adjacent_difference(InIter first, InIter last, OutIter result);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {15, 10, 6, 3, 1};
+ int ir[] = {15, -5, -4, -3, -2};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ int ib[s] = {0};
+ OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib));
+ assert(base(r) == ib + s);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ib[i] == ir[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class Y;
+
+class X
+{
+ int i_;
+
+ X& operator=(const X&);
+public:
+ explicit X(int i) : i_(i) {}
+ X(const X& x) : i_(x.i_) {}
+ X& operator=(X&& x)
+ {
+ i_ = x.i_;
+ x.i_ = -1;
+ return *this;
+ }
+
+ friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
+
+ friend class Y;
+};
+
+class Y
+{
+ int i_;
+
+ Y& operator=(const Y&);
+public:
+ explicit Y(int i) : i_(i) {}
+ Y(const Y& y) : i_(y.i_) {}
+ void operator=(const X& x) {i_ = x.i_;}
+};
+
+#endif
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ X x[3] = {X(1), X(2), X(3)};
+ Y y[3] = {Y(1), Y(2), Y(3)};
+ std::adjacent_difference(x, x+3, y);
+#endif
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/adjacent.difference/adjacent_difference_op.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter,
+// OutputIterator<auto, const InIter::value_type&> OutIter,
+// Callable<auto, const InIter::value_type&, const InIter::value_type&> BinaryOperation>
+// requires Constructible<InIter::value_type, InIter::reference>
+// && OutputIterator<OutIter, BinaryOperation::result_type>
+// && MoveAssignable<InIter::value_type>
+// && CopyConstructible<BinaryOperation>
+// OutIter
+// adjacent_difference(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {15, 10, 6, 3, 1};
+ int ir[] = {15, 25, 16, 9, 4};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ int ib[s] = {0};
+ OutIter r = std::adjacent_difference(InIter(ia), InIter(ia+s), OutIter(ib),
+ std::plus<int>());
+ assert(base(r) == ib + s);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ib[i] == ir[i]);
+}
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class Y;
+
+class X
+{
+ int i_;
+
+ X& operator=(const X&);
+public:
+ explicit X(int i) : i_(i) {}
+ X(const X& x) : i_(x.i_) {}
+ X& operator=(X&& x)
+ {
+ i_ = x.i_;
+ x.i_ = -1;
+ return *this;
+ }
+
+ friend X operator-(const X& x, const X& y) {return X(x.i_ - y.i_);}
+
+ friend class Y;
+};
+
+class Y
+{
+ int i_;
+
+ Y& operator=(const Y&);
+public:
+ explicit Y(int i) : i_(i) {}
+ Y(const Y& y) : i_(y.i_) {}
+ void operator=(const X& x) {i_ = x.i_;}
+};
+
+#endif
+
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ X x[3] = {X(1), X(2), X(3)};
+ Y y[3] = {Y(1), Y(2), Y(3)};
+ std::adjacent_difference(x, x+3, y, std::minus<X>());
+#endif
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/inner.product/inner_product.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T>
+// requires HasMultiply<Iter1::reference, Iter2::reference>
+// && HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type>
+// && HasAssign<T,
+// HasPlus<T,
+// HasMultiply<Iter1::reference,
+// Iter2::reference>::result_type>::result_type>
+// T
+// inner_product(Iter1 first1, Iter1 last1, Iter2 first2, T init);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class T>
+void
+test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
+{
+ assert(std::inner_product(first1, last1, first2, init) == x);
+}
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int a[] = {1, 2, 3, 4, 5, 6};
+ int b[] = {6, 5, 4, 3, 2, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ test(Iter1(a), Iter1(a), Iter2(b), 0, 0);
+ test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
+ test(Iter1(a), Iter1(a+1), Iter2(b), 0, 6);
+ test(Iter1(a), Iter1(a+1), Iter2(b), 10, 16);
+ test(Iter1(a), Iter1(a+2), Iter2(b), 0, 16);
+ test(Iter1(a), Iter1(a+2), Iter2(b), 10, 26);
+ test(Iter1(a), Iter1(a+sa), Iter2(b), 0, 56);
+ test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 66);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*> >();
+ test<input_iterator<const int*>, const int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<forward_iterator<const int*>, const int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, const int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, const int*>();
+
+ test<const int*, input_iterator<const int*> >();
+ test<const int*, forward_iterator<const int*> >();
+ test<const int*, bidirectional_iterator<const int*> >();
+ test<const int*, random_access_iterator<const int*> >();
+ test<const int*, const int*>();
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/inner.product/inner_product_comp.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator Iter1, InputIterator Iter2, MoveConstructible T,
+// class BinaryOperation1,
+// Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2>
+// requires Callable<BinaryOperation1, const T&, BinaryOperation2::result_type>
+// && HasAssign<T, BinaryOperation1::result_type>
+// && CopyConstructible<BinaryOperation1>
+// && CopyConstructible<BinaryOperation2>
+// T
+// inner_product(Iter1 first1, Iter1 last1, Iter2 first2,
+// T init, BinaryOperation1 binary_op1, BinaryOperation2 binary_op2);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class Iter1, class Iter2, class T>
+void
+test(Iter1 first1, Iter1 last1, Iter2 first2, T init, T x)
+{
+ assert(std::inner_product(first1, last1, first2, init,
+ std::multiplies<int>(), std::plus<int>()) == x);
+}
+
+template <class Iter1, class Iter2>
+void
+test()
+{
+ int a[] = {1, 2, 3, 4, 5, 6};
+ int b[] = {6, 5, 4, 3, 2, 1};
+ unsigned sa = sizeof(a) / sizeof(a[0]);
+ test(Iter1(a), Iter1(a), Iter2(b), 1, 1);
+ test(Iter1(a), Iter1(a), Iter2(b), 10, 10);
+ test(Iter1(a), Iter1(a+1), Iter2(b), 1, 7);
+ test(Iter1(a), Iter1(a+1), Iter2(b), 10, 70);
+ test(Iter1(a), Iter1(a+2), Iter2(b), 1, 49);
+ test(Iter1(a), Iter1(a+2), Iter2(b), 10, 490);
+ test(Iter1(a), Iter1(a+sa), Iter2(b), 1, 117649);
+ test(Iter1(a), Iter1(a+sa), Iter2(b), 10, 1176490);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, input_iterator<const int*> >();
+ test<input_iterator<const int*>, forward_iterator<const int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<input_iterator<const int*>, random_access_iterator<const int*> >();
+ test<input_iterator<const int*>, const int*>();
+
+ test<forward_iterator<const int*>, input_iterator<const int*> >();
+ test<forward_iterator<const int*>, forward_iterator<const int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<const int*> >();
+ test<forward_iterator<const int*>, const int*>();
+
+ test<bidirectional_iterator<const int*>, input_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >();
+ test<bidirectional_iterator<const int*>, const int*>();
+
+ test<random_access_iterator<const int*>, input_iterator<const int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<const int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<const int*> >();
+ test<random_access_iterator<const int*>, const int*>();
+
+ test<const int*, input_iterator<const int*> >();
+ test<const int*, forward_iterator<const int*> >();
+ test<const int*, bidirectional_iterator<const int*> >();
+ test<const int*, random_access_iterator<const int*> >();
+ test<const int*, const int*>();
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/numeric.iota/iota.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <class ForwardIterator, class T>
+// void iota(ForwardIterator first, ForwardIterator last, T value);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5};
+ int ir[] = {5, 6, 7, 8, 9};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ std::iota(InIter(ia), InIter(ia+s), 5);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ia[i] == ir[i]);
+}
+
+int main()
+{
+ test<forward_iterator<int*> >();
+ test<bidirectional_iterator<int*> >();
+ test<random_access_iterator<int*> >();
+ test<int*>();
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/partial.sum/partial_sum.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template <InputIterator InIter, OutputIterator<auto, const InIter::value_type&> OutIter>
+// requires HasPlus<InIter::value_type, InIter::reference>
+// && HasAssign<InIter::value_type,
+// HasPlus<InIter::value_type, InIter::reference>::result_type>
+// && Constructible<InIter::value_type, InIter::reference>
+// OutIter
+// partial_sum(InIter first, InIter last, OutIter result);
+
+#include <numeric>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5};
+ int ir[] = {1, 3, 6, 10, 15};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ int ib[s] = {0};
+ OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib));
+ assert(base(r) == ib + s);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/partial.sum/partial_sum_op.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+// template<InputIterator InIter,
+// OutputIterator<auto, const InIter::value_type&> OutIter,
+// Callable<auto, const InIter::value_type&, InIter::reference> BinaryOperation>
+// requires HasAssign<InIter::value_type, BinaryOperation::result_type>
+// && Constructible<InIter::value_type, InIter::reference>
+// && CopyConstructible<BinaryOperation>
+// OutIter
+// partial_sum(InIter first, InIter last, OutIter result, BinaryOperation binary_op);
+
+#include <numeric>
+#include <functional>
+#include <cassert>
+
+#include "test_iterators.h"
+
+template <class InIter, class OutIter>
+void
+test()
+{
+ int ia[] = {1, 2, 3, 4, 5};
+ int ir[] = {1, -1, -4, -8, -13};
+ const unsigned s = sizeof(ia) / sizeof(ia[0]);
+ int ib[s] = {0};
+ OutIter r = std::partial_sum(InIter(ia), InIter(ia+s), OutIter(ib), std::minus<int>());
+ assert(base(r) == ib + s);
+ for (unsigned i = 0; i < s; ++i)
+ assert(ib[i] == ir[i]);
+}
+
+int main()
+{
+ test<input_iterator<const int*>, output_iterator<int*> >();
+ test<input_iterator<const int*>, forward_iterator<int*> >();
+ test<input_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<input_iterator<const int*>, random_access_iterator<int*> >();
+ test<input_iterator<const int*>, int*>();
+
+ test<forward_iterator<const int*>, output_iterator<int*> >();
+ test<forward_iterator<const int*>, forward_iterator<int*> >();
+ test<forward_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<forward_iterator<const int*>, random_access_iterator<int*> >();
+ test<forward_iterator<const int*>, int*>();
+
+ test<bidirectional_iterator<const int*>, output_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, forward_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, random_access_iterator<int*> >();
+ test<bidirectional_iterator<const int*>, int*>();
+
+ test<random_access_iterator<const int*>, output_iterator<int*> >();
+ test<random_access_iterator<const int*>, forward_iterator<int*> >();
+ test<random_access_iterator<const int*>, bidirectional_iterator<int*> >();
+ test<random_access_iterator<const int*>, random_access_iterator<int*> >();
+ test<random_access_iterator<const int*>, int*>();
+
+ test<const int*, output_iterator<int*> >();
+ test<const int*, forward_iterator<int*> >();
+ test<const int*, bidirectional_iterator<int*> >();
+ test<const int*, random_access_iterator<int*> >();
+ test<const int*, int*>();
+}
Added: libcxx/trunk/test/std/numerics/numeric.ops/version.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/version.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/version.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.ops/version.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <numeric>
+
+#include <numeric>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/numeric.requirements/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.requirements/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.requirements/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numeric.requirements/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/numerics.general/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numerics.general/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/numerics.general/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/numerics.general/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine& operator=(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ E e1(3);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// discard_block_engine(const discard_block_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::ranlux24_base Engine;
+ typedef std::ranlux24 Adaptor;
+ Engine e;
+ Adaptor a(e);
+ assert(a.base() == e);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::ranlux24_base Engine;
+ typedef std::ranlux24 Adaptor;
+ Engine e;
+ Engine e0 = e;
+ Adaptor a(std::move(e0));
+ assert(a.base() == e);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+ "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+ "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+ "5707268 2355175 0 0";
+ std::ranlux24 e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "10880375256626 126660097854724 33643165434010 "
+ "78293780235492 179418984296008 96783156950859 238199764491708 "
+ "34339434557790 155299155394531 29014415493780 209265474179052 "
+ "263777435457028 0 0";
+ std::ranlux48 e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> explicit discard_block_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+ "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+ "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+ "889045 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::ranlux24 e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "241408498702289 172342669275054 191026374555184 "
+ "61020585639411 231929771458953 142769679250755 198672786411514 "
+ "183712717244841 227473912549724 62843577252444 68782400568421 "
+ "159248704678140 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::ranlux48 e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// explicit discard_block_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24 e1;
+ std::ranlux24 e2(std::ranlux24_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 15039276);
+}
+
+void
+test2()
+{
+ std::ranlux48 e1;
+ std::ranlux48 e2(std::ranlux48_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 23459059301164ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24 e1;
+ std::ranlux24 e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ std::ranlux48 e1;
+ std::ranlux48 e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::ranlux24 e;
+ assert(e() == 15039276u);
+ assert(e() == 16323925u);
+ assert(e() == 14283486u);
+}
+
+void
+test2()
+{
+ std::ranlux48 e;
+ assert(e() == 23459059301164ull);
+ assert(e() == 28639057539807ull);
+ assert(e() == 276846226770426ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template <class charT, class traits,
+// class Engine, size_t p, size_t r>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const discard_block_engine<Engine, p, r>& x);
+//
+// template <class charT, class traits,
+// class Engine, size_t p, size_t r>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// discard_block_engine<Engine, p, r>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::ranlux24::result_type,
+ std::uint_fast32_t>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::ranlux48::result_type,
+ std::uint_fast64_t>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::ranlux24 E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+void
+test2()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::ranlux48 E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::ranlux24 e1;
+ std::ranlux24 e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::ranlux48 e1;
+ std::ranlux48 e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t p, size_t r>
+// class discard_block_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+//
+// // engine characteristics
+// static constexpr size_t block_size = p;
+// static constexpr size_t used_block = r;
+// static constexpr result_type min() { return Engine::min(); }
+// static constexpr result_type max() { return Engine::max(); }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+ typedef std::ranlux24 E;
+ static_assert((E::block_size == 223), "");
+ static_assert((E::used_block == 23), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
+ where(E::block_size);
+ where(E::used_block);
+}
+
+void
+test2()
+{
+ typedef std::ranlux48 E;
+ static_assert((E::block_size == 389), "");
+ static_assert((E::used_block == 11), "");
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
+ where(E::block_size);
+ where(E::used_block);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine& operator=(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1(3);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// independent_bits_engine(const independent_bits_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::mt19937 Engine;
+ typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
+ Engine e;
+ Adaptor a(e);
+ assert(a.base() == e);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_engine_move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::mt19937 Engine;
+ typedef std::independent_bits_engine<Engine, 24, unsigned> Adaptor;
+ Engine e;
+ Engine e0 = e;
+ Adaptor a(std::move(e0));
+ assert(a.base() == e);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 "
+ "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 "
+ "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 "
+ "5707268 2355175 0 0";
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "10880375256626 126660097854724 33643165434010 "
+ "78293780235492 179418984296008 96783156950859 238199764491708 "
+ "34339434557790 155299155394531 29014415493780 209265474179052 "
+ "263777435457028 0 0";
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(0);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> explicit independent_bits_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
+ "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
+ "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
+ "889045 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+void
+test2()
+{
+ const char* a = "241408498702289 172342669275054 191026374555184 "
+ "61020585639411 231929771458953 142769679250755 198672786411514 "
+ "183712717244841 227473912549724 62843577252444 68782400568421 "
+ "159248704678140 0 0";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// explicit independent_bits_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(std::ranlux24_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 2066486613);
+}
+
+void
+test2()
+{
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(std::ranlux48_base::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 18223106896348967647ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/discard.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 10>, 16, unsigned> E;
+
+ E e;
+ assert(e() == 6958);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 100>, 16, unsigned> E;
+
+ E e;
+ assert(e() == 66);
+}
+
+void
+test3()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 32, unsigned> E;
+
+ E e(5);
+ assert(e() == 5);
+}
+
+void
+test4()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 0, 0xFFFFFFFF>, 7, unsigned> E;
+
+ E e(129);
+ assert(e() == 1);
+}
+
+void
+test5()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 1, unsigned> E;
+
+ E e(6);
+ assert(e() == 1);
+}
+
+void
+test6()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 11, unsigned> E;
+
+ E e(6);
+ assert(e() == 1365);
+}
+
+void
+test7()
+{
+ typedef std::independent_bits_engine<rand1<unsigned, 2, 3>, 32, unsigned> E;
+
+ E e(6);
+ assert(e() == 2863311530u);
+}
+
+void
+test8()
+{
+ typedef std::independent_bits_engine<std::mt19937, 64, unsigned long long> E;
+
+ E e(6);
+ assert(e() == 16470362623952407241ull);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+ test6();
+ test7();
+ test8();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template <class charT, class traits,
+// class Engine, size_t w, class UIntType>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const independent_bits_engine<Engine, w, UIntType>& x);
+//
+// template <class charT, class traits,
+// class Engine, size_t w, class UIntType>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// independent_bits_engine<Engine, w, UIntType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ < Min)
+ x_ = Min;
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned>::result_type,
+ unsigned>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::independent_bits_engine<rand1<unsigned long, 0, 10>, 16, unsigned long long>::result_type,
+ unsigned long long>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+void
+test2()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/seed_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e1;
+ std::independent_bits_engine<std::ranlux24, 32, unsigned> e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+void
+test2()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e1;
+ std::independent_bits_engine<std::ranlux48, 64, unsigned long long> e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/values.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t w, class UIntType>
+// class independent_bits_engine
+// {
+// public:
+// // types
+// typedef UIntType result_type;
+//
+// // engine characteristics
+// static constexpr result_type min() { return 0; }
+// static constexpr result_type max() { return 2^w - 1; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E;
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/);
+}
+
+void
+test2()
+{
+ typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E;
+ /*static_*/assert((E::min() == 0)/*, ""*/);
+ /*static_*/assert((E::max() == 0xFFFFFFFFFFFFFFFFull)/*, ""*/);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine& operator=(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ E e1(2);
+ e1();
+ E e2(5);
+ e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// shuffle_order_engine(const shuffle_order_engine&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ E e1;
+ e1();
+ E e2 = e1;
+ assert(e1 == e2);
+ assert(e1() == e2());
+ E::result_type k = e1();
+ assert(e1 != e2);
+ assert(e2() == k);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::minstd_rand0 Engine;
+ typedef std::knuth_b Adaptor;
+ Engine e;
+ Adaptor a(e);
+ for (unsigned k = 0; k <= Adaptor::table_size; ++k)
+ e();
+ assert(a.base() == e);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_engine_move.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(const Engine& e);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::minstd_rand0 Engine;
+ typedef std::knuth_b Adaptor;
+ Engine e;
+ Engine e0 = e;
+ Adaptor a(std::move(e0));
+ for (unsigned k = 0; k <= Adaptor::table_size; ++k)
+ e();
+ assert(a.base() == e);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine(result_type s = default_seed);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "1771550148 168070 677268843 1194115201 1259501992 "
+ "703671065 407145426 1010275440 1693606898 1702877348 745024267 "
+ "1793193459 416963415 664975744 742430420 1148079870 637806795 "
+ "1527921388 165317290 1791337459 1435426120 375508442 1863429808 "
+ "1910758855 653618747 991426424 578291095 1974930990 1157900898 "
+ "343583572 25567821 221638147 1335692731 1341167826 1019292670 "
+ "774852571 606325389 700907908 1211405961 1955012967 1403137269 "
+ "1010152376 1772753897 486628401 1145807831 1106352968 1560917450 "
+ "679350398 1819071734 1561434646 781928982 1427964481 1669276942 "
+ "811199786 1608612146 1272705739 1428231253 1857946652 2097152784 "
+ "197742477 1300609030 99924397 97128425 349867255 408729299 1860625187 "
+ "2018133942 1420442476 1948474080 1025729457 1583749330 15184745 "
+ "1806938869 1655319056 296727307 638820415 1383963552 880037807 "
+ "1075545360 1321008721 1507631161 597371974 544717293 340756290 "
+ "1899563128 1465595994 634440068 777915521 545718511 2135841687 "
+ "1902073804 712854586 135760289 1095544109 285050585 1956649285 "
+ "987446484 259432572 891434194 1488577086 330596852 801096775 "
+ "1458514382 1872871416 1682074633 1153627723 1538775345 51662594 "
+ "709823970 739804705 2114844452 1188863267 1037076781 1172179215 "
+ "1948572574 533634468 902793804 1283497773 273836696 315894151 "
+ "653420473 1954002600 1601768276 64415940 306945492 577163950 "
+ "210874151 813838307 857078006 1737226413 376658679 1868110244 "
+ "1117951768 1080937173 1746896638 1842856729 1883887269 2141922362 "
+ "1020763473 1872318475 978729834 1935067665 1189895487 1205729145 "
+ "1034046923 1788963337 188263312 898072753 1393688555 1119406056 "
+ "1900835472 1375045132 1312008157 559007303 2142269543 413383599 "
+ "628550348 573639243 1100665718 464587168 65992084 1027393936 "
+ "1641360472 1918007189 69800406 609352380 35938117 569027612 902394793 "
+ "1019770837 221470752 669768613 1839284764 1979413630 1335703733 "
+ "1526078440 1403144959 1139398206 753967943 1785700701 1187714882 "
+ "1063522909 1123137582 192083544 680202567 1109090588 327456556 "
+ "1709233078 191596027 1076438936 1306955024 1530346852 127901445 "
+ "8455468 377129974 1199230721 1336700752 1103107597 703058228 "
+ "844612202 530372344 1910850558 47387421 1871435357 1168551137 "
+ "1101007744 1918050856 803711675 309982095 73743043 301259382 "
+ "1647477295 1644236294 859823662 638826571 1487427444 335916581 "
+ "15468904 140348241 895842081 410006250 1847504174 536600445 "
+ "1359845362 1400027760 288242141 1910039802 1453396858 1761991428 "
+ "2137921913 357210187 1414819544 1933136424 943782705 841706193 "
+ "1081202962 1919045067 333546776 988345562 337850989 314809455 "
+ "1750287624 853099962 1450233962 142805884 1399258689 247367726 "
+ "2128513937 1151147433 654730608 351121428 12778440 18876380 "
+ "1575222551 587014441 411835569 380613902 1771550148";
+ std::knuth_b e1(10);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/ctor_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> explicit shuffle_order_engine(Sseq& q);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ const char* a = "1894661934 884942216 1899568837 1561547157 525417712 "
+ "242729120 1476874187 1208468883 1983666902 1953485886 1507290666 "
+ "1317123450 632390874 696850315 1734917114 218976032 1690682513 "
+ "1944862534 456017951 2072049961 1348874775 1700965693 828093387 "
+ "2071522749 1077957279 1055942061 413360419 238964088 475007126 "
+ "1248050783 1516729632 1044035134 9617501 580065782 1737324341 "
+ "2022534575 219953662 941840747 415472792 1381878747 200458524 "
+ "1852054372 1849850586 1318041283 1026024576 101363422 660501483 "
+ "705453438 298717379 1873705814 673416290 868766340 614560427 "
+ "1668238166 532360730 969915708 1972423626 1966307090 97417947 "
+ "920896215 588041576 495024338 522400288 1068491480 878048146 "
+ "1995051285 17282737 560668414 2143274709 127339385 1299331283 "
+ "99667038 66663006 1566161755 773555006 272986904 1065825536 "
+ "1168683925 1185292013 1144552919 1489883454 811887358 279732868 "
+ "628609193 1562647158 1833265343 1742736292 639398211 357562689 "
+ "896869717 501615326 1775469607 1032409784 43371928 955037563 "
+ "1023543663 1354331571 1071539244 562210166 138213162 1518791327 "
+ "1335204647 1727874626 2114964448 1058152392 1055171537 348065433 "
+ "190278003 399246038 1389247438 1639480282 382424917 2144508195 "
+ "1531185764 1342593547 1359065400 1176108308 1412845568 968776497 "
+ "5573525 1332437854 323541262 329396230 2097079291 1110029273 "
+ "1071549822 739994612 1011644107 1074473050 478563727 894301674 "
+ "290189565 280656618 1121689914 1630931232 579945916 1870220126 "
+ "71516543 1535179528 1893792038 1107650479 1893348357 93154853 "
+ "138035708 683805596 1535656875 1326628479 1469623399 1751042846 "
+ "661214234 1947241260 1780560187 690441964 1403944207 1687457460 "
+ "1428487938 1877084153 1618585041 1383427538 461185097 869443256 "
+ "1254069404 1739961370 1245924391 138197640 1257913073 1915996843 "
+ "641653536 1755587965 1889101622 1732723706 2009073422 1611621773 "
+ "315899200 738279016 94909546 1711873548 1620302377 181922632 "
+ "1704446343 1345319468 2076463060 357902023 157605314 1025175647 "
+ "865799248 138769064 124418006 1591838311 675218651 1096276609 "
+ "1858759850 732186041 769493777 735387805 894450150 638142050 "
+ "720101232 1671055379 636619387 898507955 118193981 63865192 "
+ "1787942091 204050966 2100684950 1580797970 1951284753 1020070334 "
+ "960149537 1041144801 823914651 558983501 1742229329 708805658 "
+ "804904097 1023665826 1260041465 1180659188 590074436 301564006 "
+ "324841922 714752380 1967212989 290476911 815113546 815183409 "
+ "1989370850 1182975807 870784323 171062356 1711897606 2024645183 "
+ "1333203966 314683764 1785282634 603713754 1904315050 1874254109 "
+ "1298675767 1967311508 1946285744 753588304 1847558969 1457540010 "
+ "528986741 97857407 1864449494 1868752281 1171249392 1353422942 "
+ "832597170 457192338 335135800 1925268166 1845956613 296546482 "
+ "1894661934";
+ unsigned as[] = {3, 5, 7};
+ std::seed_seq sseq(as, as+3);
+ std::knuth_b e1(sseq);
+ std::ostringstream os;
+ os << e1;
+ assert(os.str() == a);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// explicit shuffle_order_engine();
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::knuth_b e1;
+ std::knuth_b e2(std::minstd_rand0::default_seed);
+ assert(e1 == e2);
+ assert(e1() == 152607844u);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/discard.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void discard(unsigned long long z);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ std::knuth_b e1;
+ std::knuth_b e2 = e1;
+ assert(e1 == e2);
+ e1.discard(3);
+ assert(e1 != e2);
+ e2();
+ e2();
+ e2();
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+
+ E e;
+ assert(e() == 152607844u);
+}
+
+void
+test2()
+{
+ typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+ typedef std::shuffle_order_engine<E0, 101> E;
+ E e;
+ e.discard(400);
+ assert(e() == 501);
+}
+
+void
+test3()
+{
+ typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
+ typedef std::shuffle_order_engine<E0, 100> E;
+ E e;
+ e.discard(400);
+ assert(e() == 500);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template <class charT, class traits,
+// class Engine, size_t k>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const shuffle_order_engine<Engine, k>& x);
+//
+// template <class charT, class traits,
+// class Engine, size_t k>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// shuffle_order_engine<Engine, k>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ E e1;
+ e1.discard(100);
+ std::ostringstream os;
+ os << e1;
+ std::istringstream is(os.str());
+ E e2;
+ is >> e2;
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+
+#include <random>
+#include <type_traits>
+
+template <class UIntType, UIntType Min, UIntType Max>
+class rand1
+{
+public:
+ // types
+ typedef UIntType result_type;
+
+private:
+ result_type x_;
+
+ static_assert(Min < Max, "rand1 invalid parameters");
+public:
+
+#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+ // Workaround for lack of constexpr in C++03
+ static const result_type _Min = Min;
+ static const result_type _Max = Max;
+#endif
+
+ static _LIBCPP_CONSTEXPR result_type min() {return Min;}
+ static _LIBCPP_CONSTEXPR result_type max() {return Max;}
+
+ explicit rand1(result_type sd = Min) : x_(sd)
+ {
+ if (x_ < Min)
+ x_ = Min;
+ if (x_ > Max)
+ x_ = Max;
+ }
+
+ result_type operator()()
+ {
+ result_type r = x_;
+ if (x_ < Max)
+ ++x_;
+ else
+ x_ = Min;
+ return r;
+ }
+};
+
+void
+test1()
+{
+ static_assert((std::is_same<
+ std::shuffle_order_engine<rand1<unsigned long, 0, 10>, 16>::result_type,
+ unsigned long>::value), "");
+}
+
+void
+test2()
+{
+ static_assert((std::is_same<
+ std::shuffle_order_engine<rand1<unsigned long long, 0, 10>, 16>::result_type,
+ unsigned long long>::value), "");
+}
+
+int main()
+{
+ test1();
+ test2();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_result_type.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// void seed(result_type s = default_seed);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ for (int s = 0; s < 20; ++s)
+ {
+ typedef std::knuth_b E;
+ E e1(s);
+ E e2;
+ e2.seed(s);
+ assert(e1 == e2);
+ }
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/seed_sseq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+
+// template<class Sseq> void seed(Sseq& q);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ unsigned a[] = {3, 5, 7};
+ std::seed_seq sseq(a, a+3);
+ std::knuth_b e1;
+ std::knuth_b e2(sseq);
+ assert(e1 != e2);
+ e1.seed(sseq);
+ assert(e1 == e2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.adapt/rand.adapt.shuf/values.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class Engine, size_t k>
+// class shuffle_order_engine
+// {
+// public:
+// // types
+// typedef typename Engine::result_type result_type;
+//
+// // engine characteristics
+// static constexpr size_t table_size = k;
+// static constexpr result_type min() { return Engine::min; }
+// static constexpr result_type max() { return Engine::max; }
+
+#include <random>
+#include <type_traits>
+#include <cassert>
+
+template <class _Tp>
+void where(const _Tp &) {}
+
+void
+test1()
+{
+ typedef std::knuth_b E;
+ static_assert(E::table_size == 256, "");
+ /*static_*/assert((E::min() == 1)/*, ""*/);
+ /*static_*/assert((E::max() == 2147483646)/*, ""*/);
+ where(E::table_size);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// explicit random_device(const string& token = implementation-defined);
+
+// For the following ctors, the standard states: "The semantics and default
+// value of the token parameter are implementation-defined". Implementations
+// therefore aren't required to accept any string, but the default shouldn't
+// throw.
+
+#include <random>
+#include <cassert>
+#include <unistd.h>
+
+bool is_valid_random_device(const std::string &token) {
+#if defined(_WIN32)
+ return true;
+#elif defined(_LIBCPP_USING_NACL_RANDOM)
+ return token == "/dev/urandom";
+#else // !defined(_WIN32) && !defined(_LIBCPP_USING_NACL_RANDOM)
+ // Not an exhaustive list: they're the only tokens that are tested below.
+ return token == "/dev/urandom" || token == "/dev/random";
+#endif // defined(_WIN32) || defined(_LIBCPP_USING_NACL_RANDOM)
+}
+
+void check_random_device_valid(const std::string &token) {
+ std::random_device r(token);
+}
+
+void check_random_device_invalid(const std::string &token) {
+ try {
+ std::random_device r(token);
+ assert(false);
+ } catch (const std::system_error &e) {
+ }
+}
+
+int main() {
+ { std::random_device r; }
+
+ {
+ int ec;
+ ec = close(STDIN_FILENO);
+ assert(!ec);
+ ec = close(STDOUT_FILENO);
+ assert(!ec);
+ ec = close(STDERR_FILENO);
+ assert(!ec);
+ std::random_device r;
+ }
+
+ {
+ std::string token = "wrong file";
+ if (is_valid_random_device(token))
+ check_random_device_valid(token);
+ else
+ check_random_device_invalid(token);
+ }
+
+ {
+ std::string token = "/dev/urandom";
+ if (is_valid_random_device(token))
+ check_random_device_valid(token);
+ else
+ check_random_device_invalid(token);
+ }
+
+ {
+ std::string token = "/dev/random";
+ if (is_valid_random_device(token))
+ check_random_device_valid(token);
+ else
+ check_random_device_invalid(token);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.device/entropy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.device/entropy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.device/entropy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.device/entropy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// double entropy() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ std::random_device r;
+ double e = r.entropy();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class random_device;
+
+// result_type operator()();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ std::random_device r;
+ std::random_device::result_type e = r();
+ }
+
+ try
+ {
+ std::random_device r("/dev/null");
+ r();
+ assert(false);
+ }
+ catch (const std::system_error& e)
+ {
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bernoulli_distribution& operator=(const bernoulli_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::bernoulli_distribution D;
+ D d1(0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bernoulli_distribution(const bernoulli_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::bernoulli_distribution D;
+ D d1(0.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// explicit bernoulli_distribution(double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d;
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ D d(0);
+ assert(d.p() == 0);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ D d(0.75);
+ assert(d.p() == 0.75);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// explicit bernoulli_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// bool operator=(const bernoulli_distribution& x,
+// const bernoulli_distribution& y);
+// bool operator!(const bernoulli_distribution& x,
+// const bernoulli_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d1(.25);
+ D d2(.25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ D d1(.28);
+ D d2(.25);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.75);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.p();
+ 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.02);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.25);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.p();
+ 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.02);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.75);
+ P p(.25);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.p();
+ 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.02);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.25);
+ P p(.75);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.p();
+ 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.02);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const bernoulli_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// bernoulli_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d1(.25);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d(.25);
+ assert(d.max() == true);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ D d(.5);
+ assert(d.min() == false);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p0(.7);
+ param_type p;
+ p = p0;
+ assert(p.p() == .7);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p0(.125);
+ param_type p = p0;
+ assert(p.p() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p(0.25);
+ assert(p.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::bernoulli_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/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// class bernoulli_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::bernoulli_distribution D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, bool>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// binomial_distribution& operator=(const binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// binomial_distribution(const binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// explicit binomial_distribution(IntType t = 1, double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d;
+ assert(d.t() == 1);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ D d(3);
+ assert(d.t() == 3);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ D d(3, 0.75);
+ assert(d.t() == 3);
+ assert(d.p() == 0.75);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// explicit binomial_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, 0.25);
+ D d(p);
+ assert(d.t() == 5);
+ assert(d.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// bool operator=(const binomial_distribution& x,
+// const binomial_distribution& y);
+// bool operator!(const binomial_distribution& x,
+// const binomial_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(3, .25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ D d1(3, .28);
+ D d2(3, .25);
+ assert(d1 != d2);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(4, .25);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,475 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937_64 G;
+ G g;
+ D d(5, .75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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.04);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(30, .03125);
+ 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);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, .25);
+ 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);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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.3);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, 0);
+ 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);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, 1);
+ 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);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == -inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(400, 0.5);
+ 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);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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) < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, 0.5);
+ 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);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ const int N = 100000;
+ std::mt19937 gen1;
+ std::mt19937 gen2;
+
+ std::binomial_distribution<> dist1(5, 0.1);
+ std::binomial_distribution<unsigned> dist2(5, 0.1);
+
+ for(int i = 0; i < N; ++i)
+ assert(dist1(gen1) == dist2(gen2));
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0, 0.005);
+ 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);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0, 0);
+ 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);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0, 1);
+ 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);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ // In this case:
+ // skew computes to 0./0. == nan
+ // kurtosis computes to 0./0. == nan
+ // x_skew == -inf
+ // x_kurtosis == inf
+ // These tests are commented out because UBSan warns about division by 0
+// skew /= u.size() * dev * var;
+// kurtosis /= u.size() * var * var;
+// kurtosis -= 3;
+ double x_mean = d.t() * d.p();
+ 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(mean == x_mean);
+ assert(var == x_var);
+// assert(skew == x_skew);
+// assert(kurtosis == x_kurtosis);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937_64 G;
+ G g;
+ D d(16, .75);
+ P p(5, .75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(0 <= v && v <= p.t());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.t() * p.p();
+ 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.04);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(30, .03125);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(0 <= v && v <= p.t());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.t() * p.p();
+ 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);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(40, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(0 <= v && v <= p.t());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.t() * p.p();
+ 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.04);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.3);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, .125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const binomial_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// binomial_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d1(7, .25);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d(4, .25);
+ assert(d.max() == 4);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ D d(4, .5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(6, .7);
+ param_type p;
+ p = p0;
+ assert(p.t() == 6);
+ assert(p.p() == .7);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.t() == 10);
+ assert(p.p() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.t() == 1);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.t() == 10);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 0.25);
+ assert(p.t() == 10);
+ assert(p.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(10, 0.25);
+ D d(8, 0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class binomial_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::binomial_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::binomial_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// geometric_distribution& operator=(const geometric_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::geometric_distribution<> D;
+ D d1(0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// geometric_distribution(const geometric_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::geometric_distribution<> D;
+ D d1(0.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// explicit geometric_distribution(double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d;
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ D d(0.75);
+ assert(d.p() == 0.75);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// explicit geometric_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// bool operator=(const geometric_distribution& x,
+// const geometric_distribution& y);
+// bool operator!(const geometric_distribution& x,
+// const geometric_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d1(.25);
+ D d2(.25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ D d1(.28);
+ D d2(.25);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,274 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(.03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ 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);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.05);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ 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.03);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ 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);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ 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);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ 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);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.96875);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - d.p()) / d.p();
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(.75);
+ P p(.03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - p.p()) / p.p();
+ 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);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(.75);
+ P p(.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - p.p()) / p.p();
+ 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);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.5);
+ P p(.75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = (1 - p.p()) / p.p();
+ 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.02);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const geometric_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// geometric_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d1(.25);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d(.25);
+ assert(d.max() == std::numeric_limits<int>::max());
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ D d(.5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.7);
+ param_type p;
+ p = p0;
+ assert(p.p() == .7);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.125);
+ param_type p = p0;
+ assert(p.p() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(0.25);
+ assert(p.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::geometric_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/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class geometric_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::geometric_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::geometric_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// negative_binomial_distribution& operator=(const negative_binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::negative_binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// negative_binomial_distribution(const negative_binomial_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::negative_binomial_distribution<> D;
+ D d1(2, 0.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// explicit negative_binomial_distribution(IntType t = 1, double p = 0.5);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d;
+ assert(d.k() == 1);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(3);
+ assert(d.k() == 3);
+ assert(d.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(3, 0.75);
+ assert(d.k() == 3);
+ assert(d.p() == 0.75);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// explicit negative_binomial_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, 0.25);
+ D d(p);
+ assert(d.k() == 5);
+ assert(d.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// bool operator=(const negative_binomial_distribution& x,
+// const negative_binomial_distribution& y);
+// bool operator!(const negative_binomial_distribution& x,
+// const negative_binomial_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(3, .25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(3, .28);
+ D d2(3, .25);
+ assert(d1 != d2);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(3, .25);
+ D d2(4, .25);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,272 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(30, .03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(40, 1);
+ const int N = 1000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(mean == x_mean);
+ assert(var == x_var);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(400, 0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.04);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.05);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, 0.05);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.k() * (1 - d.p()) / d.p();
+ double x_var = x_mean / d.p();
+ double x_skew = (2 - d.p()) / std::sqrt(d.k() * (1 - d.p()));
+ double x_kurtosis = 6. / d.k() + sqr(d.p()) / (d.k() * (1 - d.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <numeric>
+#include <vector>
+#include <cassert>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(16, .75);
+ P p(5, .75);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.k() * (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+ double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(30, .03125);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.k() * (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+ double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(16, .75);
+ P p(40, .25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(),
+ double(0)) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.k() * (1 - p.p()) / p.p();
+ double x_var = x_mean / p.p();
+ double x_skew = (2 - p.p()) / std::sqrt(p.k() * (1 - p.p()));
+ double x_kurtosis = 6. / p.k() + sqr(p.p()) / (p.k() * (1 - p.p()));
+ assert(std::abs((mean - x_mean) / x_mean) < 0.01);
+ assert(std::abs((var - x_var) / x_var) < 0.01);
+ assert(std::abs((skew - x_skew) / x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.03);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(5, .125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const negative_binomial_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// negative_binomial_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d1(7, .25);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(4, .25);
+ assert(d.max() == std::numeric_limits<int>::max());
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ D d(4, .5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(6, .7);
+ param_type p;
+ p = p0;
+ assert(p.k() == 6);
+ assert(p.p() == .7);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.k() == 10);
+ assert(p.p() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.k() == 1);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.k() == 10);
+ assert(p.p() == 0.5);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 0.25);
+ assert(p.k() == 10);
+ assert(p.p() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(3, 0.75);
+ param_type p2(3, 0.5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::param_type P;
+ P p(10, 0.25);
+ D d(8, 0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class negative_binomial_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::negative_binomial_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::negative_binomial_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// cauchy_distribution& operator=(const cauchy_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::cauchy_distribution<> D;
+ D d1(.5, 2);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// cauchy_distribution(const cauchy_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::cauchy_distribution<> D;
+ D d1(.5, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// explicit cauchy_distribution(result_type a = 0, result_type b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d;
+ assert(d.a() == 0);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ D d(14.5);
+ assert(d.a() == 14.5);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.a() == 14.5);
+ assert(d.b() == 5.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// explicit cauchy_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.a() == 0.25);
+ assert(d.b() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// bool operator=(const cauchy_distribution& x,
+// const cauchy_distribution& y);
+// bool operator!(const cauchy_distribution& x,
+// const cauchy_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+
+double
+f(double x, double a, double b)
+{
+ return 1/3.1415926535897932 * std::atan((x - a)/b) + .5;
+}
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = 10;
+ const double b = .5;
+ D d(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = -1.5;
+ const double b = 1;
+ D d(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = .5;
+ const double b = 2;
+ D d(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+
+double
+f(double x, double a, double b)
+{
+ return 1/3.1415926535897932 * std::atan((x - a)/b) + .5;
+}
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = 10;
+ const double b = .5;
+ D d;
+ P p(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = -1.5;
+ const double b = 1;
+ D d;
+ P p(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ const double a = .5;
+ const double b = 2;
+ D d;
+ P p(a, b);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const cauchy_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// cauchy_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d1(7.5, 5.5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == -INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.a() == .75);
+ assert(p.b() == 6);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.a() == 10);
+ assert(p.b() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.a() == 0);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.a() == 10);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.a() == 10);
+ assert(p.b() == 5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class cauchy_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::cauchy_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::cauchy_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// chi_squared_distribution& operator=(const chi_squared_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::chi_squared_distribution<> D;
+ D d1(20.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// chi_squared_distribution(const chi_squared_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::chi_squared_distribution<> D;
+ D d1(21.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// explicit chi_squared_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d;
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d(14.5);
+ assert(d.n() == 14.5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// explicit chi_squared_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.n() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// bool operator=(const chi_squared_distribution& x,
+// const chi_squared_distribution& y);
+// bool operator!(const chi_squared_distribution& x,
+// const chi_squared_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d1(2.5);
+ D d2(2.5);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d1(4);
+ D d2(4.5);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.n();
+ 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);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(1);
+ 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);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.n();
+ 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);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2);
+ 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);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.n();
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(0.5);
+ P p(1);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.n();
+ 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);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1);
+ P p(2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.n();
+ 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);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(2);
+ P p(.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.n();
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const chi_squared_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// chi_squared_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d1(7);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d(5);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ D d(.5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75);
+ param_type p;
+ p = p0;
+ assert(p.n() == .75);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10);
+ param_type p = p0;
+ assert(p.n() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.n() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::chi_squared_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/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class chi_squared_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::chi_squared_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::chi_squared_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// fisher_f_distribution& operator=(const fisher_f_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::fisher_f_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// fisher_f_distribution(const fisher_f_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::fisher_f_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// explicit fisher_f_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d;
+ assert(d.m() == 1);
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(14.5);
+ assert(d.m() == 14.5);
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.m() == 14.5);
+ assert(d.n() == 5.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// explicit fisher_f_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.m() == 0.25);
+ assert(d.n() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// bool operator=(const fisher_f_distribution& x,
+// const fisher_f_distribution& y);
+// bool operator!(const fisher_f_distribution& x,
+// const fisher_f_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+
+double fac(double x)
+{
+ double r = 1;
+ for (; x > 1; --x)
+ r *= x;
+ return r;
+}
+
+double
+I(double x, unsigned a, unsigned b)
+{
+ double r = 0;
+ for (int j = a; j <= a+b-1; ++j)
+ r += fac(a+b-1)/(fac(j) * fac(a + b - 1 - j)) * std::pow(x, j) *
+ std::pow(1-x, a+b-1-j);
+ return r;
+}
+
+double
+f(double x, double m, double n)
+{
+ return I(m * x / (m*x + n), static_cast<unsigned>(m/2), static_cast<unsigned>(n/2));
+}
+
+int main()
+{
+ // Purposefully only testing even integral values of m and n (for now)
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 4);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(4, 2);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(18, 20);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], d.m(), d.n()) - double(i)/N) < .01);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+
+double fac(double x)
+{
+ double r = 1;
+ for (; x > 1; --x)
+ r *= x;
+ return r;
+}
+
+double
+I(double x, unsigned a, unsigned b)
+{
+ double r = 0;
+ for (int j = a; j <= a+b-1; ++j)
+ r += fac(a+b-1)/(fac(j) * fac(a + b - 1 - j)) * std::pow(x, j) *
+ std::pow(1-x, a+b-1-j);
+ return r;
+}
+
+double
+f(double x, double m, double n)
+{
+ return I(m * x / (m*x + n), static_cast<unsigned>(m/2), static_cast<unsigned>(n/2));
+}
+
+int main()
+{
+ // Purposefully only testing even integral values of m and n (for now)
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 4);
+ P p(4, 2);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(4, 2);
+ P p(6, 8);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(18, 20);
+ P p(16, 14);
+ const int N = 100000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v >= 0);
+ u.push_back(v);
+ }
+ std::sort(u.begin(), u.end());
+ for (int i = 0; i < N; ++i)
+ assert(std::abs(f(u[i], p.m(), p.n()) - double(i)/N) < .01);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const fisher_f_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// fisher_f_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.m() == .75);
+ assert(p.n() == 6);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.m() == 10);
+ assert(p.n() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.m() == 1);
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.m() == 10);
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.m() == 10);
+ assert(p.n() == 5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type param_type;
+ typedef param_type::distribution_type distribution_type;
+ static_assert((std::is_same<D, distribution_type>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class fisher_f_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::fisher_f_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::fisher_f_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// lognormal_distribution& operator=(const lognormal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::lognormal_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// lognormal_distribution(const lognormal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::lognormal_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// explicit lognormal_distribution(result_type mean = 0, result_type stddev = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d;
+ assert(d.m() == 0);
+ assert(d.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(14.5);
+ assert(d.m() == 14.5);
+ assert(d.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.m() == 14.5);
+ assert(d.s() == 5.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// explicit lognormal_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.m() == 0.25);
+ assert(d.s() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// bool operator=(const lognormal_distribution& x,
+// const lognormal_distribution& y);
+// bool operator!(const lognormal_distribution& x,
+// const lognormal_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,244 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-1./8192, 0.015625);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ 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);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-1./32, 0.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ 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);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-1./8, 0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ 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);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ 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);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.78125, 1.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,250 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-1./8192, 0.015625);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ 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);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-1./32, 0.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ 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);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-1./8, 0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ 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);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(3, 4);
+ P p;
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ 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);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-0.78125, 1.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const lognormal_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// lognormal_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.m() == .75);
+ assert(p.s() == 6);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.m() == 10);
+ assert(p.s() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.m() == 0);
+ assert(p.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.m() == 10);
+ assert(p.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.m() == 10);
+ assert(p.s() == 5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::lognormal_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/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::lognormal_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// normal_distribution& operator=(const normal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::normal_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// normal_distribution(const normal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::normal_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// explicit normal_distribution(result_type mean = 0, result_type stddev = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d;
+ assert(d.mean() == 0);
+ assert(d.stddev() == 1);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ D d(14.5);
+ assert(d.mean() == 14.5);
+ assert(d.stddev() == 1);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.mean() == 14.5);
+ assert(d.stddev() == 5.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// explicit normal_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.mean() == 0.25);
+ assert(d.stddev() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// bool operator=(const normal_distribution& x,
+// const normal_distribution& y);
+// bool operator!(const normal_distribution& x,
+// const normal_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5, 4);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.mean();
+ 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(skew - x_skew) < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) < 0.01);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5, 4);
+ P p(50, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.mean();
+ 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(skew - x_skew) < 0.01);
+ assert(std::abs(kurtosis - x_kurtosis) < 0.01);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const normal_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// normal_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == -INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.mean() == .75);
+ assert(p.stddev() == 6);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.mean() == 10);
+ assert(p.stddev() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.mean() == 0);
+ assert(p.stddev() == 1);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.mean() == 10);
+ assert(p.stddev() == 1);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.mean() == 10);
+ assert(p.stddev() == 5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::normal_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/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class normal_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::normal_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::normal_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// student_t_distribution& operator=(const student_t_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::student_t_distribution<> D;
+ D d1(20.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// student_t_distribution(const student_t_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::student_t_distribution<> D;
+ D d1(21.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// explicit student_t_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d;
+ assert(d.n() == 1);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ D d(14.5);
+ assert(d.n() == 14.5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// explicit student_t_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.n() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// bool operator=(const student_t_distribution& x,
+// const student_t_distribution& y);
+// bool operator!(const student_t_distribution& x,
+// const student_t_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d1(2.5);
+ D d2(2.5);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ D d1(4);
+ D d2(4.5);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,142 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(5.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = d.n() / (d.n() - 2);
+ 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(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.2);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(10);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = d.n() / (d.n() - 2);
+ 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(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(100);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = d.n() / (d.n() - 2);
+ 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(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ P p(5.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = p.n() / (p.n() - 2);
+ 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(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.2);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ P p(10);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = p.n() / (p.n() - 2);
+ 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(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ P p(100);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ u.push_back(d(g, p));
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 0;
+ double x_var = p.n() / (p.n() - 2);
+ 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(skew - x_skew) < 0.01);
+ assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.02);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const student_t_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// student_t_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d1(7);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d(5);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ D d(.5);
+ assert(d.min() == -INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75);
+ param_type p;
+ p = p0;
+ assert(p.n() == .75);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10);
+ param_type p = p0;
+ assert(p.n() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.n() == 1);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.n() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::student_t_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/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class student_t_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::student_t_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::student_t_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// exponential_distribution& operator=(const exponential_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::exponential_distribution<> D;
+ D d1(0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// exponential_distribution(const exponential_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::exponential_distribution<> D;
+ D d1(1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// explicit exponential_distribution(RealType lambda = 1.0);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d;
+ assert(d.lambda() == 1);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ D d(3.5);
+ assert(d.lambda() == 3.5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// explicit exponential_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.lambda() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// bool operator=(const exponential_distribution& x,
+// const exponential_distribution& y);
+// bool operator!(const exponential_distribution& x,
+// const exponential_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d1(.25);
+ D d2(.25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ D d1(.28);
+ D d2(.25);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(.75);
+ 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);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 1/d.lambda();
+ 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);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1);
+ 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);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 1/d.lambda();
+ 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);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(10);
+ 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);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 1/d.lambda();
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(.75);
+ P p(2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = 1/p.lambda();
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const exponential_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// exponential_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d1(7);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d(.25);
+ D::result_type m = d.max();
+ assert(m == std::numeric_limits<D::result_type>::infinity());
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ D d(.5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.7);
+ param_type p;
+ p = p0;
+ assert(p.lambda() == .7);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.125);
+ param_type p = p0;
+ assert(p.lambda() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.lambda() == 1);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.lambda() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::exponential_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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class exponential_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::exponential_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::exponential_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// extreme_value_distribution& operator=(const extreme_value_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::extreme_value_distribution<> D;
+ D d1(.5, 2);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// extreme_value_distribution(const extreme_value_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::extreme_value_distribution<> D;
+ D d1(.5, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// explicit extreme_value_distribution(result_type a = 0, result_type b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d;
+ assert(d.a() == 0);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d(14.5);
+ assert(d.a() == 14.5);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.a() == 14.5);
+ assert(d.b() == 5.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// explicit extreme_value_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.a() == 0.25);
+ assert(d.b() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// bool operator=(const extreme_value_distribution& x,
+// const extreme_value_distribution& y);
+// bool operator!(const extreme_value_distribution& x,
+// const extreme_value_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.a() + d.b() * 0.577215665;
+ 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);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.a() + d.b() * 0.577215665;
+ 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);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1.5, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.a() + d.b() * 0.577215665;
+ 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);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(3, 4);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.a() + d.b() * 0.577215665;
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.5, 1);
+ P p(0.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.a() + p.b() * 0.577215665;
+ 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);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.5, 1);
+ P p(1, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.a() + p.b() * 0.577215665;
+ 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);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.5, 1);
+ P p(1.5, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.a() + p.b() * 0.577215665;
+ 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);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.5, 1);
+ P p(3, 4);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.a() + p.b() * 0.577215665;
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const extreme_value_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// extreme_value_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d1(7.5, 5.5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == -INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.a() == .75);
+ assert(p.b() == 6);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.a() == 10);
+ assert(p.b() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.a() == 0);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.a() == 10);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.a() == 10);
+ assert(p.b() == 5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::extreme_value_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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class extreme_value_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::extreme_value_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::extreme_value_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// gamma_distribution& operator=(const gamma_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::gamma_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// gamma_distribution(const gamma_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::gamma_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// explicit gamma_distribution(result_type alpha = 0, result_type beta = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d;
+ assert(d.alpha() == 1);
+ assert(d.beta() == 1);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ D d(14.5);
+ assert(d.alpha() == 14.5);
+ assert(d.beta() == 1);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.alpha() == 14.5);
+ assert(d.beta() == 5.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// explicit gamma_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.alpha() == 0.25);
+ assert(d.beta() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// bool operator=(const gamma_distribution& x,
+// const gamma_distribution& y);
+// bool operator!(const gamma_distribution& x,
+// const gamma_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ 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);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.alpha() * d.beta();
+ 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);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.alpha() * d.beta();
+ 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);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 3);
+ 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);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.alpha() * d.beta();
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ P p(1, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.alpha() * p.beta();
+ 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);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, .5);
+ P p(2, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.alpha() * p.beta();
+ 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);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 3);
+ P p(.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() < v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.alpha() * p.beta();
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const gamma_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// gamma_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.alpha() == .75);
+ assert(p.beta() == 6);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.alpha() == 10);
+ assert(p.beta() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.alpha() == 1);
+ assert(p.beta() == 1);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.alpha() == 10);
+ assert(p.beta() == 1);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.alpha() == 10);
+ assert(p.beta() == 5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::gamma_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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class gamma_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::gamma_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::gamma_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// poisson_distribution& operator=(const poisson_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::poisson_distribution<> D;
+ D d1(0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// poisson_distribution(const poisson_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::poisson_distribution<> D;
+ D d1(1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// explicit poisson_distribution(RealType lambda = 1.0);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d;
+ assert(d.mean() == 1);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ D d(3.5);
+ assert(d.mean() == 3.5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// explicit poisson_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(p);
+ assert(d.mean() == 0.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// bool operator=(const poisson_distribution& x,
+// const poisson_distribution& y);
+// bool operator!(const poisson_distribution& x,
+// const poisson_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d1(.25);
+ D d2(.25);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ D d1(.28);
+ D d2(.25);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(2);
+ const int N = 100000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.mean();
+ 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);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d(0.75);
+ const int N = 100000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.mean();
+ 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);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef std::mt19937 G;
+ G g;
+ D d(20);
+ const int N = 1000000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.mean();
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(.75);
+ P p(2);
+ const int N = 100000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.mean();
+ 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);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d(2);
+ P p(.75);
+ const int N = 100000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.mean();
+ 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);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2);
+ P p(20);
+ const int N = 1000000;
+ std::vector<double> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v && v <= d.max());
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.mean();
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ P p(.125);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// template <class CharT, class Traits, class IntType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const poisson_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class IntType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// poisson_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d1(7);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d(.25);
+ D::result_type m = d.max();
+ assert(m == std::numeric_limits<int>::max());
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ D d(.5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.7);
+ param_type p;
+ p = p0;
+ assert(p.mean() == .7);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.125);
+ param_type p = p0;
+ assert(p.mean() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.mean() == 1);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.mean() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.75);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75);
+ param_type p2(0.5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::poisson_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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class poisson_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25);
+ D d(0.75);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class poisson_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::poisson_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::poisson_distribution<unsigned long long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, unsigned long long>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// weibull_distribution& operator=(const weibull_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::weibull_distribution<> D;
+ D d1(20, 0.75);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// weibull_distribution(const weibull_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::weibull_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// explicit weibull_distribution(result_type a = 0, result_type b = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d;
+ assert(d.a() == 1);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ D d(14.5);
+ assert(d.a() == 14.5);
+ assert(d.b() == 1);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.a() == 14.5);
+ assert(d.b() == 5.25);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// explicit weibull_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.a() == 0.25);
+ assert(d.b() == 10);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// bool operator=(const weibull_distribution& x,
+// const weibull_distribution& y);
+// bool operator!(const weibull_distribution& x,
+// const weibull_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,166 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ 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);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.b() * std::tgamma(1 + 1/d.a());
+ double x_var = sqr(d.b()) * std::tgamma(1 + 2/d.a()) - sqr(x_mean);
+ double x_skew = (sqr(d.b())*d.b() * std::tgamma(1 + 3/d.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ 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);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.b() * std::tgamma(1 + 1/d.a());
+ double x_var = sqr(d.b()) * std::tgamma(1 + 2/d.a()) - sqr(x_mean);
+ double x_skew = (sqr(d.b())*d.b() * std::tgamma(1 + 3/d.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ 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);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 3);
+ 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);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = d.b() * std::tgamma(1 + 1/d.a());
+ double x_var = sqr(d.b()) * std::tgamma(1 + 2/d.a()) - sqr(x_mean);
+ double x_skew = (sqr(d.b())*d.b() * std::tgamma(1 + 3/d.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,169 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(0.5, 2);
+ P p(1, .5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.b() * std::tgamma(1 + 1/p.a());
+ double x_var = sqr(p.b()) * std::tgamma(1 + 2/p.a()) - sqr(x_mean);
+ double x_skew = (sqr(p.b())*p.b() * std::tgamma(1 + 3/p.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ 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);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(1, .5);
+ P p(2, 3);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.b() * std::tgamma(1 + 1/p.a());
+ double x_var = sqr(p.b()) * std::tgamma(1 + 2/p.a()) - sqr(x_mean);
+ double x_skew = (sqr(p.b())*p.b() * std::tgamma(1 + 3/p.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ 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);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(2, 3);
+ P p(.5, 2);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(d.min() <= v);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.0) / u.size();
+ double var = 0;
+ double skew = 0;
+ double kurtosis = 0;
+ for (int i = 0; i < u.size(); ++i)
+ {
+ double d = (u[i] - mean);
+ double d2 = sqr(d);
+ var += d2;
+ skew += d * d2;
+ kurtosis += d2 * d2;
+ }
+ var /= u.size();
+ double dev = std::sqrt(var);
+ skew /= u.size() * dev * var;
+ kurtosis /= u.size() * var * var;
+ kurtosis -= 3;
+ double x_mean = p.b() * std::tgamma(1 + 1/p.a());
+ double x_var = sqr(p.b()) * std::tgamma(1 + 2/p.a()) - sqr(x_mean);
+ double x_skew = (sqr(p.b())*p.b() * std::tgamma(1 + 3/p.a()) -
+ 3*x_mean*x_var - sqr(x_mean)*x_mean) /
+ (std::sqrt(x_var)*x_var);
+ 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);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const weibull_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// weibull_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d1(7, 5);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.a() == .75);
+ assert(p.b() == 6);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.a() == 10);
+ assert(p.b() == .125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_ctor.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.a() == 1);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.a() == 10);
+ assert(p.b() == 1);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.a() == 10);
+ assert(p.b() == 5);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::weibull_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/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class weibull_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::weibull_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::weibull_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/nothing_to_do.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution& operator=(const discrete_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::discrete_distribution<> D;
+ double p[] = {2, 4, 1, 8};
+ D d1(p, p+4);
+ D d2;
+ assert(d1 != d2);
+ d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution(const discrete_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::discrete_distribution<> D;
+ double p[] = {2, 4, 1, 8};
+ D d1(p, p+4);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution();
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ D d;
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class UnaryOperation>
+// discrete_distribution(size_t nw, double xmin, double xmax,
+// UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return x+1;
+}
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ D d(0, 0, 1, fw);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d(1, 0, 1, fw);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d(2, 0.5, 1.5, fw);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == .4375);
+ assert(p[1] == .5625);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d(4, 0, 2, fw);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 4);
+ assert(p[0] == .15625);
+ assert(p[1] == .21875);
+ assert(p[2] == .28125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_init.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// discrete_distribution(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {10, 30};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {30, 10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {30, 0, 10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {0, 30, 10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0.75);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ D d = {0, 0, 10};
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0);
+ assert(p[2] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_iterator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class InputIterator>
+// discrete_distribution(InputIterator firstW, InputIterator lastW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {1};
+ D d(p0, p0);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {10};
+ D d(p0, p0+1);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {10, 30};
+ D d(p0, p0+2);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {30, 10};
+ D d(p0, p0+2);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {30, 0, 10};
+ D d(p0, p0+3);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {0, 30, 10};
+ D d(p0, p0+3);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0.75);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {0, 0, 10};
+ D d(p0, p0+3);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0);
+ assert(p[2] == 1);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/ctor_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// explicit discrete_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {10, 30};
+ P pa(p0, p0+2);
+ D d(pa);
+ std::vector<double> p = d.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// bool operator=(const discrete_distribution& x,
+// const discrete_distribution& y);
+// bool operator!(const discrete_distribution& x,
+// const discrete_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ D d1;
+ D d2;
+ assert(d1 == d2);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {1};
+ D d1(p0, p0+1);
+ D d2;
+ assert(d1 == d2);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {10, 30};
+ D d1(p0, p0+2);
+ D d2;
+ assert(d1 != d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,279 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ assert((double)u[i]/N == prob[i]);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {.3};
+ D d(p0, p0+1);
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ assert((double)u[i]/N == prob[i]);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {.75, .25};
+ D d(p0, p0+2);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {0, 1};
+ D d(p0, p0+2);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ assert((double)u[0]/N == prob[0]);
+ assert((double)u[1]/N == prob[1]);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {1, 0};
+ D d(p0, p0+2);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ assert((double)u[0]/N == prob[0]);
+ assert((double)u[1]/N == prob[1]);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {.3, .1, .6};
+ D d(p0, p0+3);
+ const int N = 10000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {0, 25, 75};
+ D d(p0, p0+3);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {25, 0, 75};
+ D d(p0, p0+3);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {25, 75, 0};
+ D d(p0, p0+3);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {0, 0, 1};
+ D d(p0, p0+3);
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {0, 1, 0};
+ D d(p0, p0+3);
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {1, 0, 0};
+ D d(p0, p0+3);
+ const int N = 100;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef std::minstd_rand G;
+ G g;
+ double p0[] = {33, 0, 0, 67};
+ D d(p0, p0+3);
+ const int N = 1000000;
+ std::vector<D::result_type> u(d.max()+1);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(d.min() <= v && v <= d.max());
+ u[v]++;
+ }
+ std::vector<double> prob = d.probabilities();
+ for (int i = 0; i <= d.max(); ++i)
+ if (prob[i] != 0)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ else
+ assert(u[i] == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ typedef std::minstd_rand G;
+ G g;
+ D d;
+ double p0[] = {.3, .1, .6};
+ P p(p0, p0+3);
+ const int N = 10000000;
+ std::vector<D::result_type> u(3);
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g, p);
+ assert(0 <= v && v <= 2);
+ u[v]++;
+ }
+ std::vector<double> prob = p.probabilities();
+ for (int i = 0; i <= 2; ++i)
+ assert(std::abs((double)u[i]/N - prob[i]) / prob[i] < 0.001);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/get_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {.3, .1, .6};
+ P p(p0, p0+3);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/io.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template <class charT, class traits>
+// basic_ostream<charT, traits>&
+// operator<<(basic_ostream<charT, traits>& os,
+// const discrete_distribution& x);
+//
+// template <class charT, class traits>
+// basic_istream<charT, traits>&
+// operator>>(basic_istream<charT, traits>& is,
+// discrete_distribution& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {.3, .1, .6};
+ D d1(p0, p0+3);
+ std::ostringstream os;
+ os << d1;
+ std::istringstream is(os.str());
+ D d2;
+ is >> d2;
+ assert(d1 == d2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/max.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {.3, .1, .6};
+ D d(p0, p0+3);
+ assert(d.max() == 2);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {.3, .1, .6, .2};
+ D d(p0, p0+4);
+ assert(d.max() == 3);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/min.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ double p0[] = {.3, .1, .6};
+ D d(p0, p0+3);
+ assert(d.min() == 0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type param_type;
+ double d0[] = {.3, .1, .6};
+ param_type p0(d0, d0+3);
+ param_type p;
+ p = p0;
+ assert(p == p0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type param_type;
+ double d0[] = {.3, .1, .6};
+ param_type p0(d0, d0+3);
+ param_type p = p0;
+ assert(p == p0);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// param_type(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {1};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class UnaryOperation>
+// param_type(size_t nw, double xmin, double xmax,
+// UnaryOperation fw);
+
+#include <random>
+#include <cassert>
+
+double fw(double x)
+{
+ return x+1;
+}
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa(0, 0, 1, fw);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa(1, 0, 1, fw);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa(2, 0.5, 1.5, fw);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == .4375);
+ assert(p[1] == .5625);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa(4, 0, 2, fw);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 4);
+ assert(p[0] == .15625);
+ assert(p[1] == .21875);
+ assert(p[2] == .28125);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_init.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// param_type(initializer_list<double> wl);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {10, 30};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {30, 10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {30, 0, 10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {0, 30, 10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0.75);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ P pa = {0, 0, 10};
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0);
+ assert(p[2] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_ctor_iterator.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// template<class InputIterator>
+// param_type(InputIterator firstW, InputIterator lastW);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {1};
+ P pa(p0, p0);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {10};
+ P pa(p0, p0+1);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 1);
+ assert(p[0] == 1);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {10, 30};
+ P pa(p0, p0+2);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.25);
+ assert(p[1] == 0.75);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {30, 10};
+ P pa(p0, p0+2);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 2);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {30, 0, 10};
+ P pa(p0, p0+3);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0.75);
+ assert(p[1] == 0);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {0, 30, 10};
+ P pa(p0, p0+3);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0.75);
+ assert(p[2] == 0.25);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double p0[] = {0, 0, 10};
+ P pa(p0, p0+3);
+ std::vector<double> p = pa.probabilities();
+ assert(p.size() == 3);
+ assert(p[0] == 0);
+ assert(p[1] == 0);
+ assert(p[2] == 1);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_eq.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type param_type;
+ double p0[] = {30, 10};
+ param_type p1(p0, p0+2);
+ param_type p2(p0, p0+2);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type param_type;
+ double p0[] = {30, 10};
+ param_type p1(p0, p0+2);
+ param_type p2;
+ assert(p1 != p2);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/param_types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::discrete_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/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/set_param.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::param_type P;
+ double d0[] = {.3, .1, .6};
+ P p(d0, d0+3);
+ D d;
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.discrete/types.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class IntType = int>
+// class discrete_distribution
+// {
+// typedef bool result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::discrete_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, int>::value), "");
+ }
+ {
+ typedef std::discrete_distribution<long> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, long>::value), "");
+ }
+}
Added: libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/assign.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. 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/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/copy.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. 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/std/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/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_default.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. 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()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ 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);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
Added: libcxx/trunk/test/std/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/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. 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/std/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/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp?rev=224658&view=auto
==============================================================================
--- libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp (added)
+++ libcxx/trunk/test/std/numerics/rand/rand.dis/rand.dist.samp/rand.dist.samp.pconst/ctor_init_func.pass.cpp Fri Dec 19 19:40:03 2014
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. 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()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ 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 // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
More information about the cfe-commits
mailing list