]>
Commit | Line | Data |
---|---|---|
af13a7a6 BK |
1 | // -*- C++ -*- C forwarding header. |
2 | ||
7adcbafe | 3 | // Copyright (C) 1997-2022 Free Software Foundation, Inc. |
af13a7a6 BK |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
af13a7a6 BK |
9 | // any later version. |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
af13a7a6 | 19 | |
748086b7 JJ |
20 | // You should have received a copy of the GNU General Public License and |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
af13a7a6 BK |
24 | |
25 | /** @file include/cmath | |
8e32aa11 | 26 | * This is a Standard C++ Library file. You should @c \#include this file |
2a60a9f6 | 27 | * in your programs, rather than any of the @a *.h implementation files. |
af13a7a6 BK |
28 | * |
29 | * This is the C++ version of the Standard C Library header @c math.h, | |
30 | * and its contents are (mostly) the same as that header, but are all | |
31 | * contained in the namespace @c std (except for names which are defined | |
32 | * as macros in C). | |
33 | */ | |
34 | ||
35 | // | |
36 | // ISO C++ 14882: 26.5 C library | |
37 | // | |
38 | ||
39 | #pragma GCC system_header | |
40 | ||
18f176d0 AA |
41 | #include <bits/requires_hosted.h> |
42 | ||
af13a7a6 BK |
43 | #include <bits/c++config.h> |
44 | #include <bits/cpp_type_traits.h> | |
45 | #include <ext/type_traits.h> | |
96e19ada JW |
46 | #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS |
47 | #include_next <math.h> | |
48 | #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS | |
37b204de | 49 | #include <bits/std_abs.h> |
af13a7a6 BK |
50 | |
51 | #ifndef _GLIBCXX_CMATH | |
52 | #define _GLIBCXX_CMATH 1 | |
53 | ||
54 | // Get rid of those macros defined in <math.h> in lieu of real functions. | |
af13a7a6 BK |
55 | #undef div |
56 | #undef acos | |
57 | #undef asin | |
58 | #undef atan | |
59 | #undef atan2 | |
60 | #undef ceil | |
61 | #undef cos | |
62 | #undef cosh | |
63 | #undef exp | |
64 | #undef fabs | |
65 | #undef floor | |
66 | #undef fmod | |
67 | #undef frexp | |
68 | #undef ldexp | |
69 | #undef log | |
70 | #undef log10 | |
71 | #undef modf | |
72 | #undef pow | |
73 | #undef sin | |
74 | #undef sinh | |
75 | #undef sqrt | |
76 | #undef tan | |
77 | #undef tanh | |
78 | ||
eac437bf JW |
79 | extern "C++" |
80 | { | |
12ffa228 BK |
81 | namespace std _GLIBCXX_VISIBILITY(default) |
82 | { | |
83 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
af13a7a6 | 84 | |
af13a7a6 BK |
85 | using ::acos; |
86 | ||
7888f266 | 87 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 88 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
89 | acos(float __x) |
90 | { return __builtin_acosf(__x); } | |
91 | ||
fa459900 | 92 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
93 | acos(long double __x) |
94 | { return __builtin_acosl(__x); } | |
a1998fab | 95 | #endif |
af13a7a6 BK |
96 | |
97 | template<typename _Tp> | |
fa459900 PC |
98 | inline _GLIBCXX_CONSTEXPR |
99 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
100 | double>::__type | |
af13a7a6 BK |
101 | acos(_Tp __x) |
102 | { return __builtin_acos(__x); } | |
103 | ||
104 | using ::asin; | |
105 | ||
7888f266 | 106 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 107 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
108 | asin(float __x) |
109 | { return __builtin_asinf(__x); } | |
110 | ||
fa459900 | 111 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
112 | asin(long double __x) |
113 | { return __builtin_asinl(__x); } | |
a1998fab | 114 | #endif |
af13a7a6 BK |
115 | |
116 | template<typename _Tp> | |
fa459900 PC |
117 | inline _GLIBCXX_CONSTEXPR |
118 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
119 | double>::__type | |
af13a7a6 BK |
120 | asin(_Tp __x) |
121 | { return __builtin_asin(__x); } | |
122 | ||
123 | using ::atan; | |
124 | ||
7888f266 | 125 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 126 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
127 | atan(float __x) |
128 | { return __builtin_atanf(__x); } | |
129 | ||
fa459900 | 130 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
131 | atan(long double __x) |
132 | { return __builtin_atanl(__x); } | |
a1998fab | 133 | #endif |
af13a7a6 BK |
134 | |
135 | template<typename _Tp> | |
fa459900 PC |
136 | inline _GLIBCXX_CONSTEXPR |
137 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
138 | double>::__type | |
af13a7a6 BK |
139 | atan(_Tp __x) |
140 | { return __builtin_atan(__x); } | |
141 | ||
142 | using ::atan2; | |
143 | ||
7888f266 | 144 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 145 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
146 | atan2(float __y, float __x) |
147 | { return __builtin_atan2f(__y, __x); } | |
148 | ||
fa459900 | 149 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
150 | atan2(long double __y, long double __x) |
151 | { return __builtin_atan2l(__y, __x); } | |
a1998fab | 152 | #endif |
af13a7a6 BK |
153 | |
154 | template<typename _Tp, typename _Up> | |
fa459900 | 155 | inline _GLIBCXX_CONSTEXPR |
9fb29828 | 156 | typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
af13a7a6 | 157 | atan2(_Tp __y, _Up __x) |
e133ace8 PC |
158 | { |
159 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
160 | return atan2(__type(__y), __type(__x)); | |
161 | } | |
af13a7a6 BK |
162 | |
163 | using ::ceil; | |
164 | ||
7888f266 | 165 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 166 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
167 | ceil(float __x) |
168 | { return __builtin_ceilf(__x); } | |
169 | ||
fa459900 | 170 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
171 | ceil(long double __x) |
172 | { return __builtin_ceill(__x); } | |
a1998fab | 173 | #endif |
af13a7a6 BK |
174 | |
175 | template<typename _Tp> | |
fa459900 PC |
176 | inline _GLIBCXX_CONSTEXPR |
177 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
178 | double>::__type | |
af13a7a6 BK |
179 | ceil(_Tp __x) |
180 | { return __builtin_ceil(__x); } | |
181 | ||
182 | using ::cos; | |
183 | ||
7888f266 | 184 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 185 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
186 | cos(float __x) |
187 | { return __builtin_cosf(__x); } | |
188 | ||
fa459900 | 189 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
190 | cos(long double __x) |
191 | { return __builtin_cosl(__x); } | |
a1998fab | 192 | #endif |
af13a7a6 BK |
193 | |
194 | template<typename _Tp> | |
fa459900 PC |
195 | inline _GLIBCXX_CONSTEXPR |
196 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
197 | double>::__type | |
af13a7a6 BK |
198 | cos(_Tp __x) |
199 | { return __builtin_cos(__x); } | |
200 | ||
201 | using ::cosh; | |
202 | ||
7888f266 | 203 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 204 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
205 | cosh(float __x) |
206 | { return __builtin_coshf(__x); } | |
207 | ||
fa459900 | 208 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
209 | cosh(long double __x) |
210 | { return __builtin_coshl(__x); } | |
a1998fab | 211 | #endif |
af13a7a6 BK |
212 | |
213 | template<typename _Tp> | |
fa459900 PC |
214 | inline _GLIBCXX_CONSTEXPR |
215 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
216 | double>::__type | |
af13a7a6 BK |
217 | cosh(_Tp __x) |
218 | { return __builtin_cosh(__x); } | |
219 | ||
220 | using ::exp; | |
221 | ||
7888f266 | 222 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 223 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
224 | exp(float __x) |
225 | { return __builtin_expf(__x); } | |
226 | ||
fa459900 | 227 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
228 | exp(long double __x) |
229 | { return __builtin_expl(__x); } | |
a1998fab | 230 | #endif |
af13a7a6 BK |
231 | |
232 | template<typename _Tp> | |
fa459900 PC |
233 | inline _GLIBCXX_CONSTEXPR |
234 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
235 | double>::__type | |
af13a7a6 BK |
236 | exp(_Tp __x) |
237 | { return __builtin_exp(__x); } | |
238 | ||
239 | using ::fabs; | |
240 | ||
7888f266 | 241 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 242 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
243 | fabs(float __x) |
244 | { return __builtin_fabsf(__x); } | |
245 | ||
fa459900 | 246 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
247 | fabs(long double __x) |
248 | { return __builtin_fabsl(__x); } | |
a1998fab | 249 | #endif |
af13a7a6 BK |
250 | |
251 | template<typename _Tp> | |
fa459900 PC |
252 | inline _GLIBCXX_CONSTEXPR |
253 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
254 | double>::__type | |
af13a7a6 BK |
255 | fabs(_Tp __x) |
256 | { return __builtin_fabs(__x); } | |
257 | ||
258 | using ::floor; | |
259 | ||
7888f266 | 260 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 261 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
262 | floor(float __x) |
263 | { return __builtin_floorf(__x); } | |
264 | ||
fa459900 | 265 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
266 | floor(long double __x) |
267 | { return __builtin_floorl(__x); } | |
a1998fab | 268 | #endif |
af13a7a6 BK |
269 | |
270 | template<typename _Tp> | |
fa459900 PC |
271 | inline _GLIBCXX_CONSTEXPR |
272 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
273 | double>::__type | |
af13a7a6 BK |
274 | floor(_Tp __x) |
275 | { return __builtin_floor(__x); } | |
276 | ||
277 | using ::fmod; | |
278 | ||
7888f266 | 279 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 280 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
281 | fmod(float __x, float __y) |
282 | { return __builtin_fmodf(__x, __y); } | |
283 | ||
fa459900 | 284 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
285 | fmod(long double __x, long double __y) |
286 | { return __builtin_fmodl(__x, __y); } | |
a1998fab | 287 | #endif |
af13a7a6 | 288 | |
e02d979a PC |
289 | template<typename _Tp, typename _Up> |
290 | inline _GLIBCXX_CONSTEXPR | |
9fb29828 | 291 | typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
e02d979a PC |
292 | fmod(_Tp __x, _Up __y) |
293 | { | |
294 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
295 | return fmod(__type(__x), __type(__y)); | |
296 | } | |
297 | ||
af13a7a6 BK |
298 | using ::frexp; |
299 | ||
7888f266 | 300 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
77addcb7 | 301 | inline float |
af13a7a6 BK |
302 | frexp(float __x, int* __exp) |
303 | { return __builtin_frexpf(__x, __exp); } | |
304 | ||
77addcb7 | 305 | inline long double |
af13a7a6 BK |
306 | frexp(long double __x, int* __exp) |
307 | { return __builtin_frexpl(__x, __exp); } | |
a1998fab | 308 | #endif |
af13a7a6 BK |
309 | |
310 | template<typename _Tp> | |
fa459900 PC |
311 | inline _GLIBCXX_CONSTEXPR |
312 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
313 | double>::__type | |
af13a7a6 BK |
314 | frexp(_Tp __x, int* __exp) |
315 | { return __builtin_frexp(__x, __exp); } | |
316 | ||
317 | using ::ldexp; | |
318 | ||
7888f266 | 319 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 320 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
321 | ldexp(float __x, int __exp) |
322 | { return __builtin_ldexpf(__x, __exp); } | |
323 | ||
fa459900 | 324 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
325 | ldexp(long double __x, int __exp) |
326 | { return __builtin_ldexpl(__x, __exp); } | |
a1998fab | 327 | #endif |
af13a7a6 BK |
328 | |
329 | template<typename _Tp> | |
fa459900 PC |
330 | inline _GLIBCXX_CONSTEXPR |
331 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
332 | double>::__type | |
e02d979a PC |
333 | ldexp(_Tp __x, int __exp) |
334 | { return __builtin_ldexp(__x, __exp); } | |
af13a7a6 BK |
335 | |
336 | using ::log; | |
337 | ||
7888f266 | 338 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 339 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
340 | log(float __x) |
341 | { return __builtin_logf(__x); } | |
342 | ||
fa459900 | 343 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
344 | log(long double __x) |
345 | { return __builtin_logl(__x); } | |
a1998fab | 346 | #endif |
af13a7a6 BK |
347 | |
348 | template<typename _Tp> | |
fa459900 PC |
349 | inline _GLIBCXX_CONSTEXPR |
350 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
351 | double>::__type | |
af13a7a6 BK |
352 | log(_Tp __x) |
353 | { return __builtin_log(__x); } | |
354 | ||
355 | using ::log10; | |
356 | ||
7888f266 | 357 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 358 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
359 | log10(float __x) |
360 | { return __builtin_log10f(__x); } | |
361 | ||
fa459900 | 362 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
363 | log10(long double __x) |
364 | { return __builtin_log10l(__x); } | |
a1998fab | 365 | #endif |
af13a7a6 BK |
366 | |
367 | template<typename _Tp> | |
fa459900 PC |
368 | inline _GLIBCXX_CONSTEXPR |
369 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
370 | double>::__type | |
af13a7a6 BK |
371 | log10(_Tp __x) |
372 | { return __builtin_log10(__x); } | |
373 | ||
374 | using ::modf; | |
375 | ||
7888f266 | 376 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
77addcb7 | 377 | inline float |
af13a7a6 BK |
378 | modf(float __x, float* __iptr) |
379 | { return __builtin_modff(__x, __iptr); } | |
380 | ||
77addcb7 | 381 | inline long double |
af13a7a6 BK |
382 | modf(long double __x, long double* __iptr) |
383 | { return __builtin_modfl(__x, __iptr); } | |
a1998fab | 384 | #endif |
af13a7a6 | 385 | |
af13a7a6 BK |
386 | using ::pow; |
387 | ||
7888f266 | 388 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 389 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
390 | pow(float __x, float __y) |
391 | { return __builtin_powf(__x, __y); } | |
392 | ||
fa459900 | 393 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
394 | pow(long double __x, long double __y) |
395 | { return __builtin_powl(__x, __y); } | |
396 | ||
734f5023 | 397 | #if __cplusplus < 201103L |
774c3d86 PC |
398 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
399 | // DR 550. What should the return type of pow(float,int) be? | |
af13a7a6 BK |
400 | inline double |
401 | pow(double __x, int __i) | |
402 | { return __builtin_powi(__x, __i); } | |
403 | ||
404 | inline float | |
405 | pow(float __x, int __n) | |
406 | { return __builtin_powif(__x, __n); } | |
407 | ||
408 | inline long double | |
409 | pow(long double __x, int __n) | |
410 | { return __builtin_powil(__x, __n); } | |
a1998fab | 411 | #endif |
774c3d86 | 412 | #endif |
af13a7a6 | 413 | |
e133ace8 | 414 | template<typename _Tp, typename _Up> |
fa459900 | 415 | inline _GLIBCXX_CONSTEXPR |
9fb29828 | 416 | typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
e133ace8 PC |
417 | pow(_Tp __x, _Up __y) |
418 | { | |
419 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
420 | return pow(__type(__x), __type(__y)); | |
421 | } | |
422 | ||
af13a7a6 BK |
423 | using ::sin; |
424 | ||
7888f266 | 425 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 426 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
427 | sin(float __x) |
428 | { return __builtin_sinf(__x); } | |
429 | ||
fa459900 | 430 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
431 | sin(long double __x) |
432 | { return __builtin_sinl(__x); } | |
a1998fab | 433 | #endif |
af13a7a6 BK |
434 | |
435 | template<typename _Tp> | |
fa459900 PC |
436 | inline _GLIBCXX_CONSTEXPR |
437 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
438 | double>::__type | |
af13a7a6 BK |
439 | sin(_Tp __x) |
440 | { return __builtin_sin(__x); } | |
441 | ||
442 | using ::sinh; | |
443 | ||
7888f266 | 444 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 445 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
446 | sinh(float __x) |
447 | { return __builtin_sinhf(__x); } | |
448 | ||
fa459900 | 449 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
450 | sinh(long double __x) |
451 | { return __builtin_sinhl(__x); } | |
a1998fab | 452 | #endif |
af13a7a6 BK |
453 | |
454 | template<typename _Tp> | |
fa459900 PC |
455 | inline _GLIBCXX_CONSTEXPR |
456 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
457 | double>::__type | |
af13a7a6 BK |
458 | sinh(_Tp __x) |
459 | { return __builtin_sinh(__x); } | |
460 | ||
461 | using ::sqrt; | |
462 | ||
7888f266 | 463 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 464 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
465 | sqrt(float __x) |
466 | { return __builtin_sqrtf(__x); } | |
467 | ||
fa459900 | 468 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
469 | sqrt(long double __x) |
470 | { return __builtin_sqrtl(__x); } | |
a1998fab | 471 | #endif |
af13a7a6 BK |
472 | |
473 | template<typename _Tp> | |
fa459900 PC |
474 | inline _GLIBCXX_CONSTEXPR |
475 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
476 | double>::__type | |
af13a7a6 BK |
477 | sqrt(_Tp __x) |
478 | { return __builtin_sqrt(__x); } | |
479 | ||
480 | using ::tan; | |
481 | ||
7888f266 | 482 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 483 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
484 | tan(float __x) |
485 | { return __builtin_tanf(__x); } | |
486 | ||
fa459900 | 487 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
488 | tan(long double __x) |
489 | { return __builtin_tanl(__x); } | |
a1998fab | 490 | #endif |
af13a7a6 BK |
491 | |
492 | template<typename _Tp> | |
fa459900 PC |
493 | inline _GLIBCXX_CONSTEXPR |
494 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
495 | double>::__type | |
af13a7a6 BK |
496 | tan(_Tp __x) |
497 | { return __builtin_tan(__x); } | |
498 | ||
499 | using ::tanh; | |
500 | ||
7888f266 | 501 | #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO |
fa459900 | 502 | inline _GLIBCXX_CONSTEXPR float |
af13a7a6 BK |
503 | tanh(float __x) |
504 | { return __builtin_tanhf(__x); } | |
505 | ||
fa459900 | 506 | inline _GLIBCXX_CONSTEXPR long double |
af13a7a6 BK |
507 | tanh(long double __x) |
508 | { return __builtin_tanhl(__x); } | |
a1998fab | 509 | #endif |
af13a7a6 BK |
510 | |
511 | template<typename _Tp> | |
fa459900 PC |
512 | inline _GLIBCXX_CONSTEXPR |
513 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
514 | double>::__type | |
af13a7a6 BK |
515 | tanh(_Tp __x) |
516 | { return __builtin_tanh(__x); } | |
517 | ||
af13a7a6 BK |
518 | #if _GLIBCXX_USE_C99_MATH |
519 | #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC | |
af13a7a6 | 520 | |
57317d2a | 521 | // These are possible macros imported from C99-land. |
af13a7a6 BK |
522 | #undef fpclassify |
523 | #undef isfinite | |
524 | #undef isinf | |
525 | #undef isnan | |
526 | #undef isnormal | |
527 | #undef signbit | |
528 | #undef isgreater | |
529 | #undef isgreaterequal | |
530 | #undef isless | |
531 | #undef islessequal | |
532 | #undef islessgreater | |
533 | #undef isunordered | |
534 | ||
734f5023 | 535 | #if __cplusplus >= 201103L |
ef3a7506 | 536 | |
3115f94f | 537 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 538 | constexpr int |
77fd1c1d PC |
539 | fpclassify(float __x) |
540 | { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, | |
541 | FP_SUBNORMAL, FP_ZERO, __x); } | |
542 | ||
fa459900 | 543 | constexpr int |
77fd1c1d PC |
544 | fpclassify(double __x) |
545 | { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, | |
546 | FP_SUBNORMAL, FP_ZERO, __x); } | |
547 | ||
fa459900 | 548 | constexpr int |
77fd1c1d PC |
549 | fpclassify(long double __x) |
550 | { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, | |
551 | FP_SUBNORMAL, FP_ZERO, __x); } | |
ef3a7506 | 552 | #endif |
77fd1c1d | 553 | |
3115f94f | 554 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 555 | template<typename _Tp> |
fa459900 PC |
556 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
557 | int>::__type | |
77fd1c1d PC |
558 | fpclassify(_Tp __x) |
559 | { return __x != 0 ? FP_NORMAL : FP_ZERO; } | |
3115f94f | 560 | #endif |
77fd1c1d | 561 | |
3115f94f | 562 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 563 | constexpr bool |
77fd1c1d PC |
564 | isfinite(float __x) |
565 | { return __builtin_isfinite(__x); } | |
566 | ||
fa459900 | 567 | constexpr bool |
77fd1c1d PC |
568 | isfinite(double __x) |
569 | { return __builtin_isfinite(__x); } | |
570 | ||
fa459900 | 571 | constexpr bool |
77fd1c1d PC |
572 | isfinite(long double __x) |
573 | { return __builtin_isfinite(__x); } | |
ef3a7506 | 574 | #endif |
77fd1c1d | 575 | |
3115f94f | 576 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 577 | template<typename _Tp> |
fa459900 PC |
578 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
579 | bool>::__type | |
77fd1c1d PC |
580 | isfinite(_Tp __x) |
581 | { return true; } | |
3115f94f | 582 | #endif |
77fd1c1d | 583 | |
3115f94f | 584 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 585 | constexpr bool |
77fd1c1d | 586 | isinf(float __x) |
750867b7 | 587 | { return __builtin_isinf(__x); } |
77fd1c1d | 588 | |
69b0daeb | 589 | #if _GLIBCXX_HAVE_OBSOLETE_ISINF \ |
350fe282 | 590 | && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC |
39a1d8c8 JW |
591 | using ::isinf; |
592 | #else | |
fa459900 | 593 | constexpr bool |
77fd1c1d | 594 | isinf(double __x) |
750867b7 | 595 | { return __builtin_isinf(__x); } |
39a1d8c8 | 596 | #endif |
77fd1c1d | 597 | |
fa459900 | 598 | constexpr bool |
77fd1c1d | 599 | isinf(long double __x) |
750867b7 | 600 | { return __builtin_isinf(__x); } |
ef3a7506 | 601 | #endif |
77fd1c1d | 602 | |
3115f94f | 603 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 604 | template<typename _Tp> |
fa459900 PC |
605 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
606 | bool>::__type | |
77fd1c1d PC |
607 | isinf(_Tp __x) |
608 | { return false; } | |
3115f94f | 609 | #endif |
77fd1c1d | 610 | |
3115f94f | 611 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 612 | constexpr bool |
77fd1c1d PC |
613 | isnan(float __x) |
614 | { return __builtin_isnan(__x); } | |
615 | ||
69b0daeb | 616 | #if _GLIBCXX_HAVE_OBSOLETE_ISNAN \ |
350fe282 | 617 | && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC |
39a1d8c8 JW |
618 | using ::isnan; |
619 | #else | |
fa459900 | 620 | constexpr bool |
77fd1c1d PC |
621 | isnan(double __x) |
622 | { return __builtin_isnan(__x); } | |
39a1d8c8 | 623 | #endif |
77fd1c1d | 624 | |
fa459900 | 625 | constexpr bool |
77fd1c1d PC |
626 | isnan(long double __x) |
627 | { return __builtin_isnan(__x); } | |
ef3a7506 | 628 | #endif |
77fd1c1d | 629 | |
3115f94f | 630 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 631 | template<typename _Tp> |
fa459900 PC |
632 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
633 | bool>::__type | |
77fd1c1d PC |
634 | isnan(_Tp __x) |
635 | { return false; } | |
3115f94f | 636 | #endif |
77fd1c1d | 637 | |
3115f94f | 638 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 639 | constexpr bool |
77fd1c1d PC |
640 | isnormal(float __x) |
641 | { return __builtin_isnormal(__x); } | |
642 | ||
fa459900 | 643 | constexpr bool |
77fd1c1d PC |
644 | isnormal(double __x) |
645 | { return __builtin_isnormal(__x); } | |
646 | ||
fa459900 | 647 | constexpr bool |
77fd1c1d PC |
648 | isnormal(long double __x) |
649 | { return __builtin_isnormal(__x); } | |
ef3a7506 | 650 | #endif |
77fd1c1d | 651 | |
3115f94f | 652 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 653 | template<typename _Tp> |
fa459900 PC |
654 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
655 | bool>::__type | |
77fd1c1d PC |
656 | isnormal(_Tp __x) |
657 | { return __x != 0 ? true : false; } | |
3115f94f | 658 | #endif |
77fd1c1d | 659 | |
3115f94f | 660 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
dce573c4 | 661 | // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic. |
fa459900 | 662 | constexpr bool |
77fd1c1d | 663 | signbit(float __x) |
157177af | 664 | { return __builtin_signbit(__x); } |
77fd1c1d | 665 | |
fa459900 | 666 | constexpr bool |
77fd1c1d PC |
667 | signbit(double __x) |
668 | { return __builtin_signbit(__x); } | |
669 | ||
fa459900 | 670 | constexpr bool |
77fd1c1d | 671 | signbit(long double __x) |
157177af | 672 | { return __builtin_signbit(__x); } |
ef3a7506 | 673 | #endif |
77fd1c1d | 674 | |
3115f94f | 675 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 676 | template<typename _Tp> |
fa459900 PC |
677 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
678 | bool>::__type | |
77fd1c1d PC |
679 | signbit(_Tp __x) |
680 | { return __x < 0 ? true : false; } | |
3115f94f | 681 | #endif |
77fd1c1d | 682 | |
3115f94f | 683 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 684 | constexpr bool |
77fd1c1d PC |
685 | isgreater(float __x, float __y) |
686 | { return __builtin_isgreater(__x, __y); } | |
687 | ||
fa459900 | 688 | constexpr bool |
77fd1c1d PC |
689 | isgreater(double __x, double __y) |
690 | { return __builtin_isgreater(__x, __y); } | |
691 | ||
fa459900 | 692 | constexpr bool |
77fd1c1d PC |
693 | isgreater(long double __x, long double __y) |
694 | { return __builtin_isgreater(__x, __y); } | |
ef3a7506 | 695 | #endif |
77fd1c1d | 696 | |
3115f94f | 697 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 698 | template<typename _Tp, typename _Up> |
fa459900 | 699 | constexpr typename |
77fd1c1d PC |
700 | __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value |
701 | && __is_arithmetic<_Up>::__value), bool>::__type | |
702 | isgreater(_Tp __x, _Up __y) | |
703 | { | |
704 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
705 | return __builtin_isgreater(__type(__x), __type(__y)); | |
706 | } | |
3115f94f | 707 | #endif |
77fd1c1d | 708 | |
3115f94f | 709 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 710 | constexpr bool |
77fd1c1d PC |
711 | isgreaterequal(float __x, float __y) |
712 | { return __builtin_isgreaterequal(__x, __y); } | |
713 | ||
fa459900 | 714 | constexpr bool |
77fd1c1d PC |
715 | isgreaterequal(double __x, double __y) |
716 | { return __builtin_isgreaterequal(__x, __y); } | |
717 | ||
fa459900 | 718 | constexpr bool |
77fd1c1d PC |
719 | isgreaterequal(long double __x, long double __y) |
720 | { return __builtin_isgreaterequal(__x, __y); } | |
ef3a7506 | 721 | #endif |
77fd1c1d | 722 | |
3115f94f | 723 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 724 | template<typename _Tp, typename _Up> |
fa459900 | 725 | constexpr typename |
77fd1c1d PC |
726 | __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value |
727 | && __is_arithmetic<_Up>::__value), bool>::__type | |
728 | isgreaterequal(_Tp __x, _Up __y) | |
729 | { | |
730 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
731 | return __builtin_isgreaterequal(__type(__x), __type(__y)); | |
732 | } | |
3115f94f | 733 | #endif |
77fd1c1d | 734 | |
3115f94f | 735 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 736 | constexpr bool |
77fd1c1d PC |
737 | isless(float __x, float __y) |
738 | { return __builtin_isless(__x, __y); } | |
739 | ||
fa459900 | 740 | constexpr bool |
77fd1c1d PC |
741 | isless(double __x, double __y) |
742 | { return __builtin_isless(__x, __y); } | |
743 | ||
fa459900 | 744 | constexpr bool |
77fd1c1d PC |
745 | isless(long double __x, long double __y) |
746 | { return __builtin_isless(__x, __y); } | |
ef3a7506 | 747 | #endif |
77fd1c1d | 748 | |
3115f94f | 749 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 750 | template<typename _Tp, typename _Up> |
fa459900 | 751 | constexpr typename |
77fd1c1d PC |
752 | __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value |
753 | && __is_arithmetic<_Up>::__value), bool>::__type | |
754 | isless(_Tp __x, _Up __y) | |
755 | { | |
756 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
757 | return __builtin_isless(__type(__x), __type(__y)); | |
758 | } | |
3115f94f | 759 | #endif |
77fd1c1d | 760 | |
3115f94f | 761 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 762 | constexpr bool |
77fd1c1d PC |
763 | islessequal(float __x, float __y) |
764 | { return __builtin_islessequal(__x, __y); } | |
765 | ||
fa459900 | 766 | constexpr bool |
77fd1c1d PC |
767 | islessequal(double __x, double __y) |
768 | { return __builtin_islessequal(__x, __y); } | |
769 | ||
fa459900 | 770 | constexpr bool |
77fd1c1d PC |
771 | islessequal(long double __x, long double __y) |
772 | { return __builtin_islessequal(__x, __y); } | |
ef3a7506 | 773 | #endif |
77fd1c1d | 774 | |
3115f94f | 775 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 776 | template<typename _Tp, typename _Up> |
fa459900 | 777 | constexpr typename |
77fd1c1d PC |
778 | __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value |
779 | && __is_arithmetic<_Up>::__value), bool>::__type | |
780 | islessequal(_Tp __x, _Up __y) | |
781 | { | |
782 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
783 | return __builtin_islessequal(__type(__x), __type(__y)); | |
784 | } | |
3115f94f | 785 | #endif |
77fd1c1d | 786 | |
3115f94f | 787 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 788 | constexpr bool |
77fd1c1d PC |
789 | islessgreater(float __x, float __y) |
790 | { return __builtin_islessgreater(__x, __y); } | |
791 | ||
fa459900 | 792 | constexpr bool |
77fd1c1d PC |
793 | islessgreater(double __x, double __y) |
794 | { return __builtin_islessgreater(__x, __y); } | |
795 | ||
fa459900 | 796 | constexpr bool |
77fd1c1d PC |
797 | islessgreater(long double __x, long double __y) |
798 | { return __builtin_islessgreater(__x, __y); } | |
ef3a7506 | 799 | #endif |
77fd1c1d | 800 | |
3115f94f | 801 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 802 | template<typename _Tp, typename _Up> |
fa459900 | 803 | constexpr typename |
77fd1c1d PC |
804 | __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value |
805 | && __is_arithmetic<_Up>::__value), bool>::__type | |
806 | islessgreater(_Tp __x, _Up __y) | |
807 | { | |
808 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
809 | return __builtin_islessgreater(__type(__x), __type(__y)); | |
810 | } | |
3115f94f | 811 | #endif |
77fd1c1d | 812 | |
3115f94f | 813 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 814 | constexpr bool |
77fd1c1d PC |
815 | isunordered(float __x, float __y) |
816 | { return __builtin_isunordered(__x, __y); } | |
817 | ||
fa459900 | 818 | constexpr bool |
77fd1c1d PC |
819 | isunordered(double __x, double __y) |
820 | { return __builtin_isunordered(__x, __y); } | |
821 | ||
fa459900 | 822 | constexpr bool |
77fd1c1d PC |
823 | isunordered(long double __x, long double __y) |
824 | { return __builtin_isunordered(__x, __y); } | |
ef3a7506 | 825 | #endif |
77fd1c1d | 826 | |
3115f94f | 827 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
77fd1c1d | 828 | template<typename _Tp, typename _Up> |
fa459900 | 829 | constexpr typename |
77fd1c1d PC |
830 | __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value |
831 | && __is_arithmetic<_Up>::__value), bool>::__type | |
832 | isunordered(_Tp __x, _Up __y) | |
833 | { | |
834 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
835 | return __builtin_isunordered(__type(__x), __type(__y)); | |
836 | } | |
3115f94f | 837 | #endif |
77fd1c1d PC |
838 | |
839 | #else | |
840 | ||
af13a7a6 | 841 | template<typename _Tp> |
0e7edcd5 PC |
842 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
843 | int>::__type | |
844 | fpclassify(_Tp __f) | |
845 | { | |
846 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
ebd15f80 PC |
847 | return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, |
848 | FP_SUBNORMAL, FP_ZERO, __type(__f)); | |
0e7edcd5 | 849 | } |
af13a7a6 BK |
850 | |
851 | template<typename _Tp> | |
0e7edcd5 PC |
852 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
853 | int>::__type | |
854 | isfinite(_Tp __f) | |
855 | { | |
856 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
857 | return __builtin_isfinite(__type(__f)); | |
858 | } | |
af13a7a6 BK |
859 | |
860 | template<typename _Tp> | |
0e7edcd5 PC |
861 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
862 | int>::__type | |
863 | isinf(_Tp __f) | |
864 | { | |
865 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
866 | return __builtin_isinf(__type(__f)); | |
867 | } | |
af13a7a6 BK |
868 | |
869 | template<typename _Tp> | |
0e7edcd5 PC |
870 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
871 | int>::__type | |
872 | isnan(_Tp __f) | |
873 | { | |
874 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
875 | return __builtin_isnan(__type(__f)); | |
876 | } | |
af13a7a6 BK |
877 | |
878 | template<typename _Tp> | |
0e7edcd5 PC |
879 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
880 | int>::__type | |
881 | isnormal(_Tp __f) | |
882 | { | |
883 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
884 | return __builtin_isnormal(__type(__f)); | |
885 | } | |
af13a7a6 BK |
886 | |
887 | template<typename _Tp> | |
0e7edcd5 PC |
888 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
889 | int>::__type | |
890 | signbit(_Tp __f) | |
891 | { | |
892 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
893 | return __builtin_signbit(__type(__f)); | |
894 | } | |
af13a7a6 BK |
895 | |
896 | template<typename _Tp> | |
0e7edcd5 PC |
897 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
898 | int>::__type | |
af13a7a6 | 899 | isgreater(_Tp __f1, _Tp __f2) |
0e7edcd5 PC |
900 | { |
901 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
902 | return __builtin_isgreater(__type(__f1), __type(__f2)); | |
903 | } | |
af13a7a6 BK |
904 | |
905 | template<typename _Tp> | |
0e7edcd5 PC |
906 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
907 | int>::__type | |
af13a7a6 | 908 | isgreaterequal(_Tp __f1, _Tp __f2) |
0e7edcd5 PC |
909 | { |
910 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
911 | return __builtin_isgreaterequal(__type(__f1), __type(__f2)); | |
912 | } | |
af13a7a6 BK |
913 | |
914 | template<typename _Tp> | |
0e7edcd5 PC |
915 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
916 | int>::__type | |
af13a7a6 | 917 | isless(_Tp __f1, _Tp __f2) |
0e7edcd5 PC |
918 | { |
919 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
920 | return __builtin_isless(__type(__f1), __type(__f2)); | |
921 | } | |
af13a7a6 BK |
922 | |
923 | template<typename _Tp> | |
0e7edcd5 PC |
924 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
925 | int>::__type | |
af13a7a6 | 926 | islessequal(_Tp __f1, _Tp __f2) |
0e7edcd5 PC |
927 | { |
928 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
929 | return __builtin_islessequal(__type(__f1), __type(__f2)); | |
930 | } | |
af13a7a6 BK |
931 | |
932 | template<typename _Tp> | |
0e7edcd5 PC |
933 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
934 | int>::__type | |
af13a7a6 | 935 | islessgreater(_Tp __f1, _Tp __f2) |
0e7edcd5 PC |
936 | { |
937 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
938 | return __builtin_islessgreater(__type(__f1), __type(__f2)); | |
939 | } | |
af13a7a6 BK |
940 | |
941 | template<typename _Tp> | |
0e7edcd5 PC |
942 | inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, |
943 | int>::__type | |
af13a7a6 | 944 | isunordered(_Tp __f1, _Tp __f2) |
0e7edcd5 PC |
945 | { |
946 | typedef typename __gnu_cxx::__promote<_Tp>::__type __type; | |
947 | return __builtin_isunordered(__type(__f1), __type(__f2)); | |
948 | } | |
af13a7a6 | 949 | |
4a15d842 | 950 | #endif // C++11 |
af13a7a6 | 951 | #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */ |
4a15d842 | 952 | #endif /* _GLIBCXX_USE_C99_MATH */ |
af13a7a6 | 953 | |
734f5023 | 954 | #if __cplusplus >= 201103L |
53dc5044 PC |
955 | |
956 | #ifdef _GLIBCXX_USE_C99_MATH_TR1 | |
957 | ||
958 | #undef acosh | |
959 | #undef acoshf | |
960 | #undef acoshl | |
961 | #undef asinh | |
962 | #undef asinhf | |
963 | #undef asinhl | |
964 | #undef atanh | |
965 | #undef atanhf | |
966 | #undef atanhl | |
967 | #undef cbrt | |
968 | #undef cbrtf | |
969 | #undef cbrtl | |
970 | #undef copysign | |
971 | #undef copysignf | |
972 | #undef copysignl | |
973 | #undef erf | |
974 | #undef erff | |
975 | #undef erfl | |
976 | #undef erfc | |
977 | #undef erfcf | |
978 | #undef erfcl | |
979 | #undef exp2 | |
980 | #undef exp2f | |
981 | #undef exp2l | |
982 | #undef expm1 | |
983 | #undef expm1f | |
984 | #undef expm1l | |
985 | #undef fdim | |
986 | #undef fdimf | |
987 | #undef fdiml | |
988 | #undef fma | |
989 | #undef fmaf | |
990 | #undef fmal | |
991 | #undef fmax | |
992 | #undef fmaxf | |
993 | #undef fmaxl | |
994 | #undef fmin | |
995 | #undef fminf | |
996 | #undef fminl | |
997 | #undef hypot | |
998 | #undef hypotf | |
999 | #undef hypotl | |
1000 | #undef ilogb | |
1001 | #undef ilogbf | |
1002 | #undef ilogbl | |
1003 | #undef lgamma | |
1004 | #undef lgammaf | |
1005 | #undef lgammal | |
a7765de8 | 1006 | #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS |
53dc5044 PC |
1007 | #undef llrint |
1008 | #undef llrintf | |
1009 | #undef llrintl | |
1010 | #undef llround | |
1011 | #undef llroundf | |
1012 | #undef llroundl | |
a7765de8 | 1013 | #endif |
53dc5044 PC |
1014 | #undef log1p |
1015 | #undef log1pf | |
1016 | #undef log1pl | |
1017 | #undef log2 | |
1018 | #undef log2f | |
1019 | #undef log2l | |
1020 | #undef logb | |
1021 | #undef logbf | |
1022 | #undef logbl | |
1023 | #undef lrint | |
1024 | #undef lrintf | |
1025 | #undef lrintl | |
1026 | #undef lround | |
1027 | #undef lroundf | |
1028 | #undef lroundl | |
1029 | #undef nan | |
1030 | #undef nanf | |
1031 | #undef nanl | |
1032 | #undef nearbyint | |
1033 | #undef nearbyintf | |
1034 | #undef nearbyintl | |
1035 | #undef nextafter | |
1036 | #undef nextafterf | |
1037 | #undef nextafterl | |
1038 | #undef nexttoward | |
1039 | #undef nexttowardf | |
1040 | #undef nexttowardl | |
1041 | #undef remainder | |
1042 | #undef remainderf | |
1043 | #undef remainderl | |
1044 | #undef remquo | |
1045 | #undef remquof | |
1046 | #undef remquol | |
1047 | #undef rint | |
1048 | #undef rintf | |
1049 | #undef rintl | |
1050 | #undef round | |
1051 | #undef roundf | |
1052 | #undef roundl | |
1053 | #undef scalbln | |
1054 | #undef scalblnf | |
1055 | #undef scalblnl | |
1056 | #undef scalbn | |
1057 | #undef scalbnf | |
1058 | #undef scalbnl | |
1059 | #undef tgamma | |
1060 | #undef tgammaf | |
1061 | #undef tgammal | |
1062 | #undef trunc | |
1063 | #undef truncf | |
1064 | #undef truncl | |
1065 | ||
53dc5044 PC |
1066 | // types |
1067 | using ::double_t; | |
1068 | using ::float_t; | |
1069 | ||
1070 | // functions | |
1071 | using ::acosh; | |
1072 | using ::acoshf; | |
1073 | using ::acoshl; | |
1074 | ||
1075 | using ::asinh; | |
1076 | using ::asinhf; | |
1077 | using ::asinhl; | |
1078 | ||
1079 | using ::atanh; | |
1080 | using ::atanhf; | |
1081 | using ::atanhl; | |
1082 | ||
1083 | using ::cbrt; | |
1084 | using ::cbrtf; | |
1085 | using ::cbrtl; | |
1086 | ||
1087 | using ::copysign; | |
1088 | using ::copysignf; | |
1089 | using ::copysignl; | |
1090 | ||
1091 | using ::erf; | |
1092 | using ::erff; | |
1093 | using ::erfl; | |
1094 | ||
1095 | using ::erfc; | |
1096 | using ::erfcf; | |
1097 | using ::erfcl; | |
1098 | ||
1099 | using ::exp2; | |
1100 | using ::exp2f; | |
1101 | using ::exp2l; | |
1102 | ||
1103 | using ::expm1; | |
1104 | using ::expm1f; | |
1105 | using ::expm1l; | |
1106 | ||
1107 | using ::fdim; | |
1108 | using ::fdimf; | |
1109 | using ::fdiml; | |
1110 | ||
1111 | using ::fma; | |
1112 | using ::fmaf; | |
1113 | using ::fmal; | |
1114 | ||
1115 | using ::fmax; | |
1116 | using ::fmaxf; | |
1117 | using ::fmaxl; | |
1118 | ||
1119 | using ::fmin; | |
1120 | using ::fminf; | |
1121 | using ::fminl; | |
1122 | ||
1123 | using ::hypot; | |
1124 | using ::hypotf; | |
1125 | using ::hypotl; | |
1126 | ||
1127 | using ::ilogb; | |
1128 | using ::ilogbf; | |
1129 | using ::ilogbl; | |
1130 | ||
1131 | using ::lgamma; | |
1132 | using ::lgammaf; | |
1133 | using ::lgammal; | |
1134 | ||
a7765de8 | 1135 | #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS |
53dc5044 PC |
1136 | using ::llrint; |
1137 | using ::llrintf; | |
1138 | using ::llrintl; | |
1139 | ||
1140 | using ::llround; | |
1141 | using ::llroundf; | |
1142 | using ::llroundl; | |
a7765de8 | 1143 | #endif |
53dc5044 PC |
1144 | |
1145 | using ::log1p; | |
1146 | using ::log1pf; | |
1147 | using ::log1pl; | |
1148 | ||
1149 | using ::log2; | |
1150 | using ::log2f; | |
1151 | using ::log2l; | |
1152 | ||
1153 | using ::logb; | |
1154 | using ::logbf; | |
1155 | using ::logbl; | |
1156 | ||
1157 | using ::lrint; | |
1158 | using ::lrintf; | |
1159 | using ::lrintl; | |
1160 | ||
1161 | using ::lround; | |
1162 | using ::lroundf; | |
1163 | using ::lroundl; | |
1164 | ||
1165 | using ::nan; | |
1166 | using ::nanf; | |
1167 | using ::nanl; | |
1168 | ||
1169 | using ::nearbyint; | |
1170 | using ::nearbyintf; | |
1171 | using ::nearbyintl; | |
1172 | ||
1173 | using ::nextafter; | |
1174 | using ::nextafterf; | |
1175 | using ::nextafterl; | |
1176 | ||
1177 | using ::nexttoward; | |
1178 | using ::nexttowardf; | |
1179 | using ::nexttowardl; | |
1180 | ||
1181 | using ::remainder; | |
1182 | using ::remainderf; | |
1183 | using ::remainderl; | |
1184 | ||
1185 | using ::remquo; | |
1186 | using ::remquof; | |
1187 | using ::remquol; | |
1188 | ||
1189 | using ::rint; | |
1190 | using ::rintf; | |
1191 | using ::rintl; | |
1192 | ||
1193 | using ::round; | |
1194 | using ::roundf; | |
1195 | using ::roundl; | |
1196 | ||
1197 | using ::scalbln; | |
1198 | using ::scalblnf; | |
1199 | using ::scalblnl; | |
1200 | ||
1201 | using ::scalbn; | |
1202 | using ::scalbnf; | |
1203 | using ::scalbnl; | |
1204 | ||
1205 | using ::tgamma; | |
1206 | using ::tgammaf; | |
1207 | using ::tgammal; | |
1208 | ||
1209 | using ::trunc; | |
1210 | using ::truncf; | |
1211 | using ::truncl; | |
1212 | ||
298cee01 | 1213 | /// Additional overloads. |
3115f94f | 1214 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1215 | constexpr float |
53dc5044 PC |
1216 | acosh(float __x) |
1217 | { return __builtin_acoshf(__x); } | |
1218 | ||
fa459900 | 1219 | constexpr long double |
53dc5044 PC |
1220 | acosh(long double __x) |
1221 | { return __builtin_acoshl(__x); } | |
ef3a7506 | 1222 | #endif |
53dc5044 | 1223 | |
3115f94f | 1224 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1225 | template<typename _Tp> |
fa459900 PC |
1226 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1227 | double>::__type | |
53dc5044 | 1228 | acosh(_Tp __x) |
b04fa738 | 1229 | { return __builtin_acosh(__x); } |
3115f94f | 1230 | #endif |
53dc5044 | 1231 | |
3115f94f | 1232 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1233 | constexpr float |
53dc5044 PC |
1234 | asinh(float __x) |
1235 | { return __builtin_asinhf(__x); } | |
1236 | ||
fa459900 | 1237 | constexpr long double |
53dc5044 PC |
1238 | asinh(long double __x) |
1239 | { return __builtin_asinhl(__x); } | |
ef3a7506 | 1240 | #endif |
53dc5044 | 1241 | |
3115f94f | 1242 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1243 | template<typename _Tp> |
fa459900 PC |
1244 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1245 | double>::__type | |
53dc5044 | 1246 | asinh(_Tp __x) |
b04fa738 | 1247 | { return __builtin_asinh(__x); } |
3115f94f | 1248 | #endif |
53dc5044 | 1249 | |
3115f94f | 1250 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1251 | constexpr float |
53dc5044 PC |
1252 | atanh(float __x) |
1253 | { return __builtin_atanhf(__x); } | |
1254 | ||
fa459900 | 1255 | constexpr long double |
53dc5044 PC |
1256 | atanh(long double __x) |
1257 | { return __builtin_atanhl(__x); } | |
ef3a7506 | 1258 | #endif |
53dc5044 | 1259 | |
3115f94f | 1260 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1261 | template<typename _Tp> |
fa459900 PC |
1262 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1263 | double>::__type | |
53dc5044 | 1264 | atanh(_Tp __x) |
b04fa738 | 1265 | { return __builtin_atanh(__x); } |
3115f94f | 1266 | #endif |
53dc5044 | 1267 | |
3115f94f | 1268 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1269 | constexpr float |
53dc5044 PC |
1270 | cbrt(float __x) |
1271 | { return __builtin_cbrtf(__x); } | |
1272 | ||
fa459900 | 1273 | constexpr long double |
53dc5044 PC |
1274 | cbrt(long double __x) |
1275 | { return __builtin_cbrtl(__x); } | |
ef3a7506 | 1276 | #endif |
53dc5044 | 1277 | |
3115f94f | 1278 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1279 | template<typename _Tp> |
fa459900 PC |
1280 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1281 | double>::__type | |
53dc5044 | 1282 | cbrt(_Tp __x) |
b04fa738 | 1283 | { return __builtin_cbrt(__x); } |
3115f94f | 1284 | #endif |
53dc5044 | 1285 | |
3115f94f | 1286 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1287 | constexpr float |
53dc5044 PC |
1288 | copysign(float __x, float __y) |
1289 | { return __builtin_copysignf(__x, __y); } | |
1290 | ||
fa459900 | 1291 | constexpr long double |
53dc5044 PC |
1292 | copysign(long double __x, long double __y) |
1293 | { return __builtin_copysignl(__x, __y); } | |
ef3a7506 | 1294 | #endif |
53dc5044 | 1295 | |
3115f94f | 1296 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1297 | template<typename _Tp, typename _Up> |
9fb29828 | 1298 | constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
53dc5044 PC |
1299 | copysign(_Tp __x, _Up __y) |
1300 | { | |
1301 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
1302 | return copysign(__type(__x), __type(__y)); | |
1303 | } | |
3115f94f | 1304 | #endif |
53dc5044 | 1305 | |
3115f94f | 1306 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1307 | constexpr float |
53dc5044 PC |
1308 | erf(float __x) |
1309 | { return __builtin_erff(__x); } | |
1310 | ||
fa459900 | 1311 | constexpr long double |
53dc5044 PC |
1312 | erf(long double __x) |
1313 | { return __builtin_erfl(__x); } | |
ef3a7506 | 1314 | #endif |
53dc5044 | 1315 | |
3115f94f | 1316 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1317 | template<typename _Tp> |
fa459900 PC |
1318 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1319 | double>::__type | |
53dc5044 | 1320 | erf(_Tp __x) |
b04fa738 | 1321 | { return __builtin_erf(__x); } |
3115f94f | 1322 | #endif |
53dc5044 | 1323 | |
3115f94f | 1324 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1325 | constexpr float |
53dc5044 PC |
1326 | erfc(float __x) |
1327 | { return __builtin_erfcf(__x); } | |
1328 | ||
fa459900 | 1329 | constexpr long double |
53dc5044 PC |
1330 | erfc(long double __x) |
1331 | { return __builtin_erfcl(__x); } | |
ef3a7506 | 1332 | #endif |
53dc5044 | 1333 | |
3115f94f | 1334 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1335 | template<typename _Tp> |
fa459900 PC |
1336 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1337 | double>::__type | |
53dc5044 | 1338 | erfc(_Tp __x) |
b04fa738 | 1339 | { return __builtin_erfc(__x); } |
3115f94f | 1340 | #endif |
53dc5044 | 1341 | |
3115f94f | 1342 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1343 | constexpr float |
53dc5044 PC |
1344 | exp2(float __x) |
1345 | { return __builtin_exp2f(__x); } | |
1346 | ||
fa459900 | 1347 | constexpr long double |
53dc5044 PC |
1348 | exp2(long double __x) |
1349 | { return __builtin_exp2l(__x); } | |
ef3a7506 | 1350 | #endif |
53dc5044 | 1351 | |
3115f94f | 1352 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1353 | template<typename _Tp> |
fa459900 PC |
1354 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1355 | double>::__type | |
53dc5044 | 1356 | exp2(_Tp __x) |
b04fa738 | 1357 | { return __builtin_exp2(__x); } |
3115f94f | 1358 | #endif |
53dc5044 | 1359 | |
3115f94f | 1360 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1361 | constexpr float |
53dc5044 PC |
1362 | expm1(float __x) |
1363 | { return __builtin_expm1f(__x); } | |
1364 | ||
fa459900 | 1365 | constexpr long double |
53dc5044 PC |
1366 | expm1(long double __x) |
1367 | { return __builtin_expm1l(__x); } | |
ef3a7506 | 1368 | #endif |
53dc5044 | 1369 | |
3115f94f | 1370 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1371 | template<typename _Tp> |
fa459900 PC |
1372 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1373 | double>::__type | |
53dc5044 | 1374 | expm1(_Tp __x) |
b04fa738 | 1375 | { return __builtin_expm1(__x); } |
3115f94f | 1376 | #endif |
53dc5044 | 1377 | |
3115f94f | 1378 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1379 | constexpr float |
53dc5044 PC |
1380 | fdim(float __x, float __y) |
1381 | { return __builtin_fdimf(__x, __y); } | |
1382 | ||
fa459900 | 1383 | constexpr long double |
53dc5044 PC |
1384 | fdim(long double __x, long double __y) |
1385 | { return __builtin_fdiml(__x, __y); } | |
ef3a7506 | 1386 | #endif |
53dc5044 | 1387 | |
3115f94f | 1388 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1389 | template<typename _Tp, typename _Up> |
9fb29828 | 1390 | constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
53dc5044 PC |
1391 | fdim(_Tp __x, _Up __y) |
1392 | { | |
1393 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
1394 | return fdim(__type(__x), __type(__y)); | |
1395 | } | |
3115f94f | 1396 | #endif |
53dc5044 | 1397 | |
3115f94f | 1398 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1399 | constexpr float |
53dc5044 PC |
1400 | fma(float __x, float __y, float __z) |
1401 | { return __builtin_fmaf(__x, __y, __z); } | |
1402 | ||
fa459900 | 1403 | constexpr long double |
53dc5044 PC |
1404 | fma(long double __x, long double __y, long double __z) |
1405 | { return __builtin_fmal(__x, __y, __z); } | |
ef3a7506 | 1406 | #endif |
53dc5044 | 1407 | |
3115f94f | 1408 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1409 | template<typename _Tp, typename _Up, typename _Vp> |
9fb29828 | 1410 | constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type |
53dc5044 PC |
1411 | fma(_Tp __x, _Up __y, _Vp __z) |
1412 | { | |
1413 | typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; | |
1414 | return fma(__type(__x), __type(__y), __type(__z)); | |
1415 | } | |
3115f94f | 1416 | #endif |
53dc5044 | 1417 | |
3115f94f | 1418 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1419 | constexpr float |
53dc5044 PC |
1420 | fmax(float __x, float __y) |
1421 | { return __builtin_fmaxf(__x, __y); } | |
1422 | ||
fa459900 | 1423 | constexpr long double |
53dc5044 PC |
1424 | fmax(long double __x, long double __y) |
1425 | { return __builtin_fmaxl(__x, __y); } | |
ef3a7506 | 1426 | #endif |
53dc5044 | 1427 | |
3115f94f | 1428 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1429 | template<typename _Tp, typename _Up> |
9fb29828 | 1430 | constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
53dc5044 PC |
1431 | fmax(_Tp __x, _Up __y) |
1432 | { | |
1433 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
1434 | return fmax(__type(__x), __type(__y)); | |
1435 | } | |
3115f94f | 1436 | #endif |
53dc5044 | 1437 | |
3115f94f | 1438 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1439 | constexpr float |
53dc5044 PC |
1440 | fmin(float __x, float __y) |
1441 | { return __builtin_fminf(__x, __y); } | |
1442 | ||
fa459900 | 1443 | constexpr long double |
53dc5044 PC |
1444 | fmin(long double __x, long double __y) |
1445 | { return __builtin_fminl(__x, __y); } | |
ef3a7506 | 1446 | #endif |
53dc5044 | 1447 | |
3115f94f | 1448 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1449 | template<typename _Tp, typename _Up> |
9fb29828 | 1450 | constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
53dc5044 PC |
1451 | fmin(_Tp __x, _Up __y) |
1452 | { | |
1453 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
1454 | return fmin(__type(__x), __type(__y)); | |
1455 | } | |
3115f94f | 1456 | #endif |
53dc5044 | 1457 | |
3115f94f | 1458 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1459 | constexpr float |
53dc5044 PC |
1460 | hypot(float __x, float __y) |
1461 | { return __builtin_hypotf(__x, __y); } | |
1462 | ||
fa459900 | 1463 | constexpr long double |
53dc5044 PC |
1464 | hypot(long double __x, long double __y) |
1465 | { return __builtin_hypotl(__x, __y); } | |
ef3a7506 | 1466 | #endif |
53dc5044 | 1467 | |
3115f94f | 1468 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1469 | template<typename _Tp, typename _Up> |
9fb29828 PC |
1470 | constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
1471 | hypot(_Tp __x, _Up __y) | |
53dc5044 PC |
1472 | { |
1473 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
1474 | return hypot(__type(__x), __type(__y)); | |
1475 | } | |
3115f94f | 1476 | #endif |
53dc5044 | 1477 | |
3115f94f | 1478 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1479 | constexpr int |
53dc5044 PC |
1480 | ilogb(float __x) |
1481 | { return __builtin_ilogbf(__x); } | |
1482 | ||
fa459900 | 1483 | constexpr int |
53dc5044 PC |
1484 | ilogb(long double __x) |
1485 | { return __builtin_ilogbl(__x); } | |
ef3a7506 | 1486 | #endif |
53dc5044 | 1487 | |
3115f94f | 1488 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1489 | template<typename _Tp> |
fa459900 PC |
1490 | constexpr |
1491 | typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, | |
1492 | int>::__type | |
53dc5044 | 1493 | ilogb(_Tp __x) |
b04fa738 | 1494 | { return __builtin_ilogb(__x); } |
3115f94f | 1495 | #endif |
53dc5044 | 1496 | |
3115f94f | 1497 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1498 | constexpr float |
53dc5044 PC |
1499 | lgamma(float __x) |
1500 | { return __builtin_lgammaf(__x); } | |
1501 | ||
fa459900 | 1502 | constexpr long double |
53dc5044 PC |
1503 | lgamma(long double __x) |
1504 | { return __builtin_lgammal(__x); } | |
ef3a7506 | 1505 | #endif |
53dc5044 | 1506 | |
3115f94f | 1507 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1508 | template<typename _Tp> |
fa459900 PC |
1509 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1510 | double>::__type | |
53dc5044 | 1511 | lgamma(_Tp __x) |
b04fa738 | 1512 | { return __builtin_lgamma(__x); } |
3115f94f | 1513 | #endif |
53dc5044 | 1514 | |
3115f94f | 1515 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1516 | constexpr long long |
53dc5044 PC |
1517 | llrint(float __x) |
1518 | { return __builtin_llrintf(__x); } | |
1519 | ||
fa459900 | 1520 | constexpr long long |
53dc5044 PC |
1521 | llrint(long double __x) |
1522 | { return __builtin_llrintl(__x); } | |
ef3a7506 | 1523 | #endif |
53dc5044 | 1524 | |
3115f94f | 1525 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1526 | template<typename _Tp> |
fa459900 PC |
1527 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1528 | long long>::__type | |
53dc5044 | 1529 | llrint(_Tp __x) |
b04fa738 | 1530 | { return __builtin_llrint(__x); } |
3115f94f | 1531 | #endif |
53dc5044 | 1532 | |
3115f94f | 1533 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1534 | constexpr long long |
53dc5044 PC |
1535 | llround(float __x) |
1536 | { return __builtin_llroundf(__x); } | |
1537 | ||
fa459900 | 1538 | constexpr long long |
53dc5044 PC |
1539 | llround(long double __x) |
1540 | { return __builtin_llroundl(__x); } | |
ef3a7506 | 1541 | #endif |
53dc5044 | 1542 | |
3115f94f | 1543 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1544 | template<typename _Tp> |
fa459900 PC |
1545 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1546 | long long>::__type | |
53dc5044 | 1547 | llround(_Tp __x) |
b04fa738 | 1548 | { return __builtin_llround(__x); } |
3115f94f | 1549 | #endif |
53dc5044 | 1550 | |
3115f94f | 1551 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1552 | constexpr float |
53dc5044 PC |
1553 | log1p(float __x) |
1554 | { return __builtin_log1pf(__x); } | |
1555 | ||
fa459900 | 1556 | constexpr long double |
53dc5044 PC |
1557 | log1p(long double __x) |
1558 | { return __builtin_log1pl(__x); } | |
ef3a7506 | 1559 | #endif |
53dc5044 | 1560 | |
3115f94f | 1561 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1562 | template<typename _Tp> |
fa459900 PC |
1563 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1564 | double>::__type | |
53dc5044 | 1565 | log1p(_Tp __x) |
b04fa738 | 1566 | { return __builtin_log1p(__x); } |
3115f94f | 1567 | #endif |
53dc5044 | 1568 | |
3115f94f | 1569 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
53dc5044 | 1570 | // DR 568. |
fa459900 | 1571 | constexpr float |
53dc5044 PC |
1572 | log2(float __x) |
1573 | { return __builtin_log2f(__x); } | |
1574 | ||
fa459900 | 1575 | constexpr long double |
53dc5044 PC |
1576 | log2(long double __x) |
1577 | { return __builtin_log2l(__x); } | |
ef3a7506 | 1578 | #endif |
53dc5044 | 1579 | |
3115f94f | 1580 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1581 | template<typename _Tp> |
fa459900 PC |
1582 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1583 | double>::__type | |
53dc5044 | 1584 | log2(_Tp __x) |
b04fa738 | 1585 | { return __builtin_log2(__x); } |
3115f94f | 1586 | #endif |
53dc5044 | 1587 | |
3115f94f | 1588 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1589 | constexpr float |
53dc5044 PC |
1590 | logb(float __x) |
1591 | { return __builtin_logbf(__x); } | |
1592 | ||
fa459900 | 1593 | constexpr long double |
53dc5044 PC |
1594 | logb(long double __x) |
1595 | { return __builtin_logbl(__x); } | |
ef3a7506 | 1596 | #endif |
53dc5044 | 1597 | |
3115f94f | 1598 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1599 | template<typename _Tp> |
fa459900 PC |
1600 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1601 | double>::__type | |
53dc5044 | 1602 | logb(_Tp __x) |
b04fa738 | 1603 | { return __builtin_logb(__x); } |
3115f94f | 1604 | #endif |
53dc5044 | 1605 | |
3115f94f | 1606 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1607 | constexpr long |
53dc5044 PC |
1608 | lrint(float __x) |
1609 | { return __builtin_lrintf(__x); } | |
1610 | ||
fa459900 | 1611 | constexpr long |
53dc5044 PC |
1612 | lrint(long double __x) |
1613 | { return __builtin_lrintl(__x); } | |
ef3a7506 | 1614 | #endif |
53dc5044 | 1615 | |
3115f94f | 1616 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1617 | template<typename _Tp> |
fa459900 PC |
1618 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1619 | long>::__type | |
53dc5044 | 1620 | lrint(_Tp __x) |
b04fa738 | 1621 | { return __builtin_lrint(__x); } |
3115f94f | 1622 | #endif |
53dc5044 | 1623 | |
3115f94f | 1624 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1625 | constexpr long |
53dc5044 PC |
1626 | lround(float __x) |
1627 | { return __builtin_lroundf(__x); } | |
1628 | ||
fa459900 | 1629 | constexpr long |
53dc5044 PC |
1630 | lround(long double __x) |
1631 | { return __builtin_lroundl(__x); } | |
ef3a7506 | 1632 | #endif |
53dc5044 | 1633 | |
3115f94f | 1634 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1635 | template<typename _Tp> |
fa459900 PC |
1636 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1637 | long>::__type | |
53dc5044 | 1638 | lround(_Tp __x) |
b04fa738 | 1639 | { return __builtin_lround(__x); } |
3115f94f | 1640 | #endif |
53dc5044 | 1641 | |
3115f94f | 1642 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1643 | constexpr float |
53dc5044 PC |
1644 | nearbyint(float __x) |
1645 | { return __builtin_nearbyintf(__x); } | |
1646 | ||
fa459900 | 1647 | constexpr long double |
53dc5044 PC |
1648 | nearbyint(long double __x) |
1649 | { return __builtin_nearbyintl(__x); } | |
ef3a7506 | 1650 | #endif |
53dc5044 | 1651 | |
3115f94f | 1652 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1653 | template<typename _Tp> |
fa459900 PC |
1654 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1655 | double>::__type | |
53dc5044 | 1656 | nearbyint(_Tp __x) |
b04fa738 | 1657 | { return __builtin_nearbyint(__x); } |
3115f94f | 1658 | #endif |
53dc5044 | 1659 | |
3115f94f | 1660 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1661 | constexpr float |
53dc5044 PC |
1662 | nextafter(float __x, float __y) |
1663 | { return __builtin_nextafterf(__x, __y); } | |
1664 | ||
fa459900 | 1665 | constexpr long double |
53dc5044 PC |
1666 | nextafter(long double __x, long double __y) |
1667 | { return __builtin_nextafterl(__x, __y); } | |
ef3a7506 | 1668 | #endif |
53dc5044 | 1669 | |
3115f94f | 1670 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1671 | template<typename _Tp, typename _Up> |
9fb29828 | 1672 | constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
53dc5044 PC |
1673 | nextafter(_Tp __x, _Up __y) |
1674 | { | |
1675 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
1676 | return nextafter(__type(__x), __type(__y)); | |
1677 | } | |
3115f94f | 1678 | #endif |
53dc5044 | 1679 | |
3115f94f | 1680 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1681 | constexpr float |
53dc5044 PC |
1682 | nexttoward(float __x, long double __y) |
1683 | { return __builtin_nexttowardf(__x, __y); } | |
1684 | ||
fa459900 | 1685 | constexpr long double |
53dc5044 PC |
1686 | nexttoward(long double __x, long double __y) |
1687 | { return __builtin_nexttowardl(__x, __y); } | |
ef3a7506 | 1688 | #endif |
53dc5044 | 1689 | |
3115f94f | 1690 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1691 | template<typename _Tp> |
fa459900 PC |
1692 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1693 | double>::__type | |
53dc5044 | 1694 | nexttoward(_Tp __x, long double __y) |
b04fa738 | 1695 | { return __builtin_nexttoward(__x, __y); } |
3115f94f | 1696 | #endif |
53dc5044 | 1697 | |
3115f94f | 1698 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1699 | constexpr float |
53dc5044 PC |
1700 | remainder(float __x, float __y) |
1701 | { return __builtin_remainderf(__x, __y); } | |
1702 | ||
fa459900 | 1703 | constexpr long double |
53dc5044 PC |
1704 | remainder(long double __x, long double __y) |
1705 | { return __builtin_remainderl(__x, __y); } | |
ef3a7506 | 1706 | #endif |
53dc5044 | 1707 | |
3115f94f | 1708 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1709 | template<typename _Tp, typename _Up> |
9fb29828 | 1710 | constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
53dc5044 PC |
1711 | remainder(_Tp __x, _Up __y) |
1712 | { | |
1713 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
1714 | return remainder(__type(__x), __type(__y)); | |
1715 | } | |
3115f94f | 1716 | #endif |
53dc5044 | 1717 | |
3115f94f | 1718 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
77addcb7 | 1719 | inline float |
53dc5044 PC |
1720 | remquo(float __x, float __y, int* __pquo) |
1721 | { return __builtin_remquof(__x, __y, __pquo); } | |
1722 | ||
77addcb7 | 1723 | inline long double |
53dc5044 PC |
1724 | remquo(long double __x, long double __y, int* __pquo) |
1725 | { return __builtin_remquol(__x, __y, __pquo); } | |
ef3a7506 | 1726 | #endif |
53dc5044 | 1727 | |
3115f94f | 1728 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1729 | template<typename _Tp, typename _Up> |
77addcb7 | 1730 | inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type |
53dc5044 PC |
1731 | remquo(_Tp __x, _Up __y, int* __pquo) |
1732 | { | |
1733 | typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; | |
1734 | return remquo(__type(__x), __type(__y), __pquo); | |
1735 | } | |
3115f94f | 1736 | #endif |
53dc5044 | 1737 | |
3115f94f | 1738 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1739 | constexpr float |
53dc5044 PC |
1740 | rint(float __x) |
1741 | { return __builtin_rintf(__x); } | |
1742 | ||
fa459900 | 1743 | constexpr long double |
53dc5044 PC |
1744 | rint(long double __x) |
1745 | { return __builtin_rintl(__x); } | |
ef3a7506 | 1746 | #endif |
53dc5044 | 1747 | |
3115f94f | 1748 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1749 | template<typename _Tp> |
fa459900 PC |
1750 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1751 | double>::__type | |
53dc5044 | 1752 | rint(_Tp __x) |
b04fa738 | 1753 | { return __builtin_rint(__x); } |
3115f94f | 1754 | #endif |
53dc5044 | 1755 | |
3115f94f | 1756 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1757 | constexpr float |
53dc5044 PC |
1758 | round(float __x) |
1759 | { return __builtin_roundf(__x); } | |
1760 | ||
fa459900 | 1761 | constexpr long double |
53dc5044 PC |
1762 | round(long double __x) |
1763 | { return __builtin_roundl(__x); } | |
ef3a7506 | 1764 | #endif |
53dc5044 | 1765 | |
3115f94f | 1766 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1767 | template<typename _Tp> |
fa459900 PC |
1768 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1769 | double>::__type | |
53dc5044 | 1770 | round(_Tp __x) |
b04fa738 | 1771 | { return __builtin_round(__x); } |
3115f94f | 1772 | #endif |
53dc5044 | 1773 | |
3115f94f | 1774 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1775 | constexpr float |
53dc5044 PC |
1776 | scalbln(float __x, long __ex) |
1777 | { return __builtin_scalblnf(__x, __ex); } | |
1778 | ||
fa459900 | 1779 | constexpr long double |
53dc5044 PC |
1780 | scalbln(long double __x, long __ex) |
1781 | { return __builtin_scalblnl(__x, __ex); } | |
ef3a7506 | 1782 | #endif |
53dc5044 | 1783 | |
3115f94f | 1784 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1785 | template<typename _Tp> |
fa459900 PC |
1786 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1787 | double>::__type | |
53dc5044 | 1788 | scalbln(_Tp __x, long __ex) |
b04fa738 | 1789 | { return __builtin_scalbln(__x, __ex); } |
3115f94f | 1790 | #endif |
53dc5044 | 1791 | |
3115f94f | 1792 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1793 | constexpr float |
53dc5044 PC |
1794 | scalbn(float __x, int __ex) |
1795 | { return __builtin_scalbnf(__x, __ex); } | |
1796 | ||
fa459900 | 1797 | constexpr long double |
53dc5044 PC |
1798 | scalbn(long double __x, int __ex) |
1799 | { return __builtin_scalbnl(__x, __ex); } | |
ef3a7506 | 1800 | #endif |
53dc5044 | 1801 | |
3115f94f | 1802 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1803 | template<typename _Tp> |
fa459900 PC |
1804 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1805 | double>::__type | |
53dc5044 | 1806 | scalbn(_Tp __x, int __ex) |
b04fa738 | 1807 | { return __builtin_scalbn(__x, __ex); } |
3115f94f | 1808 | #endif |
53dc5044 | 1809 | |
3115f94f | 1810 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1811 | constexpr float |
53dc5044 PC |
1812 | tgamma(float __x) |
1813 | { return __builtin_tgammaf(__x); } | |
1814 | ||
fa459900 | 1815 | constexpr long double |
53dc5044 PC |
1816 | tgamma(long double __x) |
1817 | { return __builtin_tgammal(__x); } | |
ef3a7506 | 1818 | #endif |
53dc5044 | 1819 | |
3115f94f | 1820 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1821 | template<typename _Tp> |
fa459900 PC |
1822 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1823 | double>::__type | |
53dc5044 | 1824 | tgamma(_Tp __x) |
b04fa738 | 1825 | { return __builtin_tgamma(__x); } |
3115f94f | 1826 | #endif |
53dc5044 | 1827 | |
3115f94f | 1828 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP |
fa459900 | 1829 | constexpr float |
53dc5044 PC |
1830 | trunc(float __x) |
1831 | { return __builtin_truncf(__x); } | |
1832 | ||
fa459900 | 1833 | constexpr long double |
53dc5044 PC |
1834 | trunc(long double __x) |
1835 | { return __builtin_truncl(__x); } | |
ef3a7506 | 1836 | #endif |
53dc5044 | 1837 | |
3115f94f | 1838 | #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT |
53dc5044 | 1839 | template<typename _Tp> |
fa459900 PC |
1840 | constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, |
1841 | double>::__type | |
53dc5044 | 1842 | trunc(_Tp __x) |
b04fa738 | 1843 | { return __builtin_trunc(__x); } |
3115f94f | 1844 | #endif |
53dc5044 | 1845 | |
53dc5044 | 1846 | #endif // _GLIBCXX_USE_C99_MATH_TR1 |
734f5023 | 1847 | #endif // C++11 |
53dc5044 | 1848 | |
9017326e | 1849 | #if __cplusplus >= 201703L |
998e01a6 JW |
1850 | |
1851 | // [c.math.hypot3], three-dimensional hypotenuse | |
b8806796 | 1852 | #define __cpp_lib_hypot 201603L |
998e01a6 JW |
1853 | |
1854 | template<typename _Tp> | |
1855 | inline _Tp | |
1856 | __hypot3(_Tp __x, _Tp __y, _Tp __z) | |
1857 | { | |
1858 | __x = std::abs(__x); | |
1859 | __y = std::abs(__y); | |
1860 | __z = std::abs(__z); | |
1861 | if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x) | |
1862 | return __a * std::sqrt((__x / __a) * (__x / __a) | |
1863 | + (__y / __a) * (__y / __a) | |
1864 | + (__z / __a) * (__z / __a)); | |
1865 | else | |
1866 | return {}; | |
1867 | } | |
1868 | ||
1869 | inline float | |
1870 | hypot(float __x, float __y, float __z) | |
1871 | { return std::__hypot3<float>(__x, __y, __z); } | |
1872 | ||
1873 | inline double | |
1874 | hypot(double __x, double __y, double __z) | |
1875 | { return std::__hypot3<double>(__x, __y, __z); } | |
1876 | ||
1877 | inline long double | |
1878 | hypot(long double __x, long double __y, long double __z) | |
1879 | { return std::__hypot3<long double>(__x, __y, __z); } | |
1880 | ||
1881 | template<typename _Tp, typename _Up, typename _Vp> | |
9017326e | 1882 | __gnu_cxx::__promoted_t<_Tp, _Up, _Vp> |
998e01a6 JW |
1883 | hypot(_Tp __x, _Up __y, _Vp __z) |
1884 | { | |
9017326e | 1885 | using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>; |
998e01a6 JW |
1886 | return std::__hypot3<__type>(__x, __y, __z); |
1887 | } | |
998e01a6 JW |
1888 | #endif // C++17 |
1889 | ||
9017326e | 1890 | #if __cplusplus >= 202002L |
24387442 JW |
1891 | // linear interpolation |
1892 | # define __cpp_lib_interpolate 201902L | |
1893 | ||
1894 | template<typename _Fp> | |
1895 | constexpr _Fp | |
360a758e | 1896 | __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept |
24387442 | 1897 | { |
ef8b4335 | 1898 | if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0)) |
24387442 JW |
1899 | return __t * __b + (1 - __t) * __a; |
1900 | ||
1901 | if (__t == 1) | |
1902 | return __b; // exact | |
1903 | ||
1904 | // Exact at __t=0, monotonic except near __t=1, | |
1905 | // bounded, determinate, and consistent: | |
1906 | const _Fp __x = __a + __t * (__b - __a); | |
ef8b4335 | 1907 | return (__t > 1) == (__b > __a) |
24387442 JW |
1908 | ? (__b < __x ? __x : __b) |
1909 | : (__b > __x ? __x : __b); // monotonic near __t=1 | |
1910 | } | |
1911 | ||
1912 | constexpr float | |
360a758e | 1913 | lerp(float __a, float __b, float __t) noexcept |
24387442 JW |
1914 | { return std::__lerp(__a, __b, __t); } |
1915 | ||
1916 | constexpr double | |
360a758e | 1917 | lerp(double __a, double __b, double __t) noexcept |
24387442 JW |
1918 | { return std::__lerp(__a, __b, __t); } |
1919 | ||
1920 | constexpr long double | |
360a758e | 1921 | lerp(long double __a, long double __b, long double __t) noexcept |
24387442 | 1922 | { return std::__lerp(__a, __b, __t); } |
9017326e JW |
1923 | |
1924 | template<typename _Tp, typename _Up, typename _Vp> | |
1925 | constexpr __gnu_cxx::__promoted_t<_Tp, _Up, _Vp> | |
1926 | lerp(_Tp __x, _Up __y, _Vp __z) noexcept | |
1927 | { | |
1928 | using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>; | |
1929 | return std::__lerp<__type>(__x, __y, __z); | |
1930 | } | |
24387442 JW |
1931 | #endif // C++20 |
1932 | ||
4a15d842 FD |
1933 | _GLIBCXX_END_NAMESPACE_VERSION |
1934 | } // namespace | |
998e01a6 | 1935 | |
f8571e51 | 1936 | #if _GLIBCXX_USE_STD_SPEC_FUNCS |
2be75957 ESR |
1937 | # include <bits/specfun.h> |
1938 | #endif | |
1939 | ||
eac437bf JW |
1940 | } // extern "C++" |
1941 | ||
af13a7a6 | 1942 | #endif |