diff options
Diffstat (limited to 'test/std/numerics/numarray/valarray.nonmembers/valarray.binary')
30 files changed, 990 insertions, 0 deletions
diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..9214e61fb4da --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp new file mode 100644 index 000000000000..0976a88dcb81 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp new file mode 100644 index 000000000000..e3dd180b2181 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/and_value_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..ff250afd2a1a --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp new file mode 100644 index 000000000000..ffbebab1e1ae --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp new file mode 100644 index 000000000000..1a7f2f07c83a --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/divide_value_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..1f0354e8ac63 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp new file mode 100644 index 000000000000..382cab8eae6e --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp new file mode 100644 index 000000000000..7f00aba84884 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/minus_value_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..0a9cf3884c08 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp new file mode 100644 index 000000000000..12c4c2453702 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp new file mode 100644 index 000000000000..1d73887217e1 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/modulo_value_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..a23ea4f58b8c --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp new file mode 100644 index 000000000000..f617c27ae7fc --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp new file mode 100644 index 000000000000..8903f438aaf1 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/or_value_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..1167772aff6a --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp new file mode 100644 index 000000000000..b1b4e6931c0c --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp new file mode 100644 index 000000000000..df22853488e9 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/plus_value_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..42a7c419a3a3 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp new file mode 100644 index 000000000000..753ba38f357f --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp new file mode 100644 index 000000000000..640ce1a47b32 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_left_value_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..8e6358d62060 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp new file mode 100644 index 000000000000..0c0ba54463e1 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp new file mode 100644 index 000000000000..ad5418af0267 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/shift_right_value_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..69a3bffc3e77 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp new file mode 100644 index 000000000000..c4fb410de768 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp new file mode 100644 index 000000000000..f5d877783ded --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/times_value_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp new file mode 100644 index 000000000000..71b505b0cbe8 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_valarray.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp new file mode 100644 index 000000000000..8dbe6843cd24 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_valarray_value.pass.cpp @@ -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]); + } +} diff --git a/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp new file mode 100644 index 000000000000..face0635dfb4 --- /dev/null +++ b/test/std/numerics/numarray/valarray.nonmembers/valarray.binary/xor_value_valarray.pass.cpp @@ -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]); + } +} |
