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