]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/experimental/simd/tests/math_2arg.cc
Fix earlier commit missing patch review changes
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / simd / tests / math_2arg.cc
CommitLineData
02e32295 1// test only floattypes
a054608c 2// Copyright (C) 2020-2021 Free Software Foundation, Inc.
02e32295
MK
3//
4// This file is part of the GNU ISO C++ Library. This library is free
5// software; you can redistribute it and/or modify it under the
6// terms of the GNU General Public License as published by the
7// Free Software Foundation; either version 3, or (at your option)
8// any later version.
9//
10// This library is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License along
16// with this library; see the file COPYING3. If not see
17// <http://www.gnu.org/licenses/>.
18
19#include "bits/verify.h"
20#include "bits/metahelpers.h"
21#include "bits/test_values.h"
22
23template <typename V>
24 void
25 test()
26 {
27 using T = typename V::value_type;
28
29 vir::test::setFuzzyness<float>(1);
30 vir::test::setFuzzyness<double>(1);
31 vir::test::setFuzzyness<long double>(1);
32 test_values_2arg<V>(
33 {
34#ifdef __STDC_IEC_559__
35 std::__quiet_NaN_v<T>, std::__infinity_v<T>, -std::__infinity_v<T>, -0.,
36 std::__denorm_min_v<T>, std::__norm_min_v<T> / 3,
37#endif
38 +0., std::__norm_min_v<T>, 1., 2., std::__finite_max_v<T> / 5,
39 std::__finite_max_v<T> / 3, std::__finite_max_v<T> / 2,
40#ifdef __FAST_MATH__
41 // fast-math hypot is imprecise for the max exponent
42 },
43 {100000, std::__finite_max_v<T> / 2},
44#else
45 std::__finite_max_v<T>},
46 {100000},
47#endif
48 MAKE_TESTER(hypot));
49#if !__FINITE_MATH_ONLY__
50 COMPARE(hypot(V(std::__finite_max_v<T>), V(std::__finite_max_v<T>)),
51 V(std::__infinity_v<T>));
52#endif
53 COMPARE(hypot(V(std::__norm_min_v<T>), V(std::__norm_min_v<T>)),
54 V(std::__norm_min_v<T> * std::sqrt(T(2))));
55 VERIFY((sfinae_is_callable<V, V>(
56 [](auto a, auto b) -> decltype(hypot(a, b)) { return {}; })));
57 VERIFY((sfinae_is_callable<typename V::value_type, V>(
58 [](auto a, auto b) -> decltype(hypot(a, b)) { return {}; })));
59 VERIFY((sfinae_is_callable<V, typename V::value_type>(
60 [](auto a, auto b) -> decltype(hypot(a, b)) { return {}; })));
61
62 vir::test::setFuzzyness<float>(0);
63 vir::test::setFuzzyness<double>(0);
64 vir::test::setFuzzyness<long double>(0);
65 test_values_2arg<V>(
66 {
67#ifdef __STDC_IEC_559__
68 std::__quiet_NaN_v<T>, std::__infinity_v<T>, -std::__infinity_v<T>,
69 std::__denorm_min_v<T>, std::__norm_min_v<T> / 3, -0.,
70#endif
71 +0., std::__norm_min_v<T>, std::__finite_max_v<T>},
72 {10000}, MAKE_TESTER(pow), MAKE_TESTER(fmod), MAKE_TESTER(remainder),
73 MAKE_TESTER_NOFPEXCEPT(copysign),
74 MAKE_TESTER(nextafter), // MAKE_TESTER(nexttoward),
75 MAKE_TESTER(fdim), MAKE_TESTER(fmax), MAKE_TESTER(fmin),
76 MAKE_TESTER_NOFPEXCEPT(isgreater), MAKE_TESTER_NOFPEXCEPT(isgreaterequal),
77 MAKE_TESTER_NOFPEXCEPT(isless), MAKE_TESTER_NOFPEXCEPT(islessequal),
78 MAKE_TESTER_NOFPEXCEPT(islessgreater), MAKE_TESTER_NOFPEXCEPT(isunordered));
79 }