[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / numerics / complex.number / complex.ops / complex_divide_complex.pass.cpp
blob7119710a9555754a11f959b9a04e6d733dd8c7d5
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <complex>
11 // template<class T>
12 // complex<T>
13 // operator/(const complex<T>& lhs, const complex<T>& rhs); // constexpr in C++20
15 // ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=5000000
17 #include <complex>
18 #include <cassert>
20 #include "test_macros.h"
21 #include "../cases.h"
23 template <class T>
24 TEST_CONSTEXPR_CXX20
25 bool
26 test()
28 const std::complex<T> lhs(-4.0, 7.5);
29 const std::complex<T> rhs(1.5, 2.5);
30 assert(lhs / rhs == std::complex<T>(1.5, 2.5));
31 return true;
34 TEST_CONSTEXPR_CXX20
35 bool
36 test_edges()
38 const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
39 int classification[N];
40 for (unsigned i=0; i < N; ++i)
41 classification[i] = classify(testcases[i]);
43 for (unsigned i = 0; i < N; ++i) {
44 for (unsigned j = 0; j < N; ++j) {
45 std::complex<double> r = testcases[i] / testcases[j];
46 switch (classification[i]) {
47 case zero:
48 switch (classification[j]) {
49 case zero:
50 assert(classify(r) == NaN);
51 break;
52 case non_zero:
53 assert(classify(r) == zero);
54 break;
55 case inf:
56 assert(classify(r) == zero);
57 break;
58 case NaN:
59 assert(classify(r) == NaN);
60 break;
61 case non_zero_nan:
62 assert(classify(r) == NaN);
63 break;
65 break;
66 case non_zero:
67 switch (classification[j]) {
68 case zero:
69 assert(classify(r) == inf);
70 break;
71 case non_zero:
72 assert(classify(r) == non_zero);
73 break;
74 case inf:
75 assert(classify(r) == zero);
76 break;
77 case NaN:
78 assert(classify(r) == NaN);
79 break;
80 case non_zero_nan:
81 assert(classify(r) == NaN);
82 break;
84 break;
85 case inf:
86 switch (classification[j]) {
87 case zero:
88 assert(classify(r) == inf);
89 break;
90 case non_zero:
91 assert(classify(r) == inf);
92 break;
93 case inf:
94 assert(classify(r) == NaN);
95 break;
96 case NaN:
97 assert(classify(r) == NaN);
98 break;
99 case non_zero_nan:
100 assert(classify(r) == NaN);
101 break;
103 break;
104 case NaN:
105 switch (classification[j]) {
106 case zero:
107 assert(classify(r) == NaN);
108 break;
109 case non_zero:
110 assert(classify(r) == NaN);
111 break;
112 case inf:
113 assert(classify(r) == NaN);
114 break;
115 case NaN:
116 assert(classify(r) == NaN);
117 break;
118 case non_zero_nan:
119 assert(classify(r) == NaN);
120 break;
122 break;
123 case non_zero_nan:
124 switch (classification[j]) {
125 case zero:
126 assert(classify(r) == inf);
127 break;
128 case non_zero:
129 assert(classify(r) == NaN);
130 break;
131 case inf:
132 assert(classify(r) == NaN);
133 break;
134 case NaN:
135 assert(classify(r) == NaN);
136 break;
137 case non_zero_nan:
138 assert(classify(r) == NaN);
139 break;
141 break;
145 return true;
148 int main(int, char**)
150 test<float>();
151 test<double>();
152 test<long double>();
153 test_edges();
155 #if TEST_STD_VER > 17
156 static_assert(test<float>());
157 static_assert(test<double>());
158 static_assert(test<long double>());
159 static_assert(test_edges());
160 #endif
162 return 0;