15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <valarray>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // template<class T> class valarray;
125a83710eSEric Fiselier 
135a83710eSEric Fiselier // template<class T>
145a83710eSEric Fiselier //   valarray<T>
155a83710eSEric Fiselier //   abs(const valarray<T>& x);
165a83710eSEric Fiselier 
175a83710eSEric Fiselier #include <valarray>
185a83710eSEric Fiselier #include <cassert>
19e898b484SStephan T. Lavavej #include <cstddef>
205a83710eSEric Fiselier 
21*7fc6a556SMarshall Clow #include "test_macros.h"
22*7fc6a556SMarshall Clow 
main(int,char **)232df59c50SJF Bastien int main(int, char**)
245a83710eSEric Fiselier {
255a83710eSEric Fiselier     {
265a83710eSEric Fiselier         typedef double T;
275a83710eSEric Fiselier         T a1[] = {1.5,  -2.5,  3.4,  -4.5,  -5.0};
285a83710eSEric Fiselier         T a3[] = {1.5,   2.5,  3.4,   4.5,   5.0};
295a83710eSEric Fiselier         const unsigned N = sizeof(a1)/sizeof(a1[0]);
305a83710eSEric Fiselier         std::valarray<T> v1(a1, N);
315a83710eSEric Fiselier         std::valarray<T> v3 = abs(v1);
325a83710eSEric Fiselier         assert(v3.size() == v1.size());
33e898b484SStephan T. Lavavej         for (std::size_t i = 0; i < v3.size(); ++i)
345a83710eSEric Fiselier             assert(v3[i] == a3[i]);
355a83710eSEric Fiselier     }
362df59c50SJF Bastien 
372df59c50SJF Bastien   return 0;
385a83710eSEric Fiselier }
39