times_valarray_valarray.pass.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // <valarray>
  10. // template<class T> class valarray;
  11. // template<class T> valarray<T> operator*(const valarray<T>& x, const valarray<T>& y);
  12. #include <valarray>
  13. #include <cassert>
  14. int main()
  15. {
  16. {
  17. typedef int T;
  18. T a1[] = {1, 2, 3, 4, 5};
  19. T a2[] = {6, 7, 8, 9, 10};
  20. T a3[] = {6, 14, 24, 36, 50};
  21. const unsigned N = sizeof(a1)/sizeof(a1[0]);
  22. std::valarray<T> v1(a1, N);
  23. std::valarray<T> v2(a2, N);
  24. std::valarray<T> v3 = v1 * v2;
  25. assert(v1.size() == v2.size());
  26. assert(v1.size() == v3.size());
  27. for (int i = 0; i < v1.size(); ++i)
  28. assert(v3[i] == a3[i]);
  29. }
  30. }