1 // -*- C++ -*- C forwarding header.
3 // Copyright (C) 1997-2013 Free Software Foundation, Inc.
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)
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.
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.
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/>.
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.
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
36 // ISO C++ 14882: 26.5 C library
39 #pragma GCC system_header
41 #include <bits/c++config.h>
42 #include <bits/cpp_type_traits.h>
43 #include <ext/type_traits.h>
46 #ifndef _GLIBCXX_CMATH
47 #define _GLIBCXX_CMATH 1
49 // Get rid of those macros defined in <math.h> in lieu of real functions.
75 namespace std _GLIBCXX_VISIBILITY(default)
77 _GLIBCXX_BEGIN_NAMESPACE_VERSION
79 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
80 inline _GLIBCXX_CONSTEXPR double
82 { return __builtin_fabs(__x); }
85 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
86 inline _GLIBCXX_CONSTEXPR float
88 { return __builtin_fabsf(__x); }
90 inline _GLIBCXX_CONSTEXPR long double
92 { return __builtin_fabsl(__x); }
95 template<typename _Tp>
96 inline _GLIBCXX_CONSTEXPR
97 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
100 { return __builtin_fabs(__x); }
104 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
105 inline _GLIBCXX_CONSTEXPR float
107 { return __builtin_acosf(__x); }
109 inline _GLIBCXX_CONSTEXPR long double
110 acos(long double __x)
111 { return __builtin_acosl(__x); }
114 template<typename _Tp>
115 inline _GLIBCXX_CONSTEXPR
116 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
119 { return __builtin_acos(__x); }
123 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
124 inline _GLIBCXX_CONSTEXPR float
126 { return __builtin_asinf(__x); }
128 inline _GLIBCXX_CONSTEXPR long double
129 asin(long double __x)
130 { return __builtin_asinl(__x); }
133 template<typename _Tp>
134 inline _GLIBCXX_CONSTEXPR
135 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
138 { return __builtin_asin(__x); }
142 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
143 inline _GLIBCXX_CONSTEXPR float
145 { return __builtin_atanf(__x); }
147 inline _GLIBCXX_CONSTEXPR long double
148 atan(long double __x)
149 { return __builtin_atanl(__x); }
152 template<typename _Tp>
153 inline _GLIBCXX_CONSTEXPR
154 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
157 { return __builtin_atan(__x); }
161 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
162 inline _GLIBCXX_CONSTEXPR float
163 atan2(float __y, float __x)
164 { return __builtin_atan2f(__y, __x); }
166 inline _GLIBCXX_CONSTEXPR long double
167 atan2(long double __y, long double __x)
168 { return __builtin_atan2l(__y, __x); }
171 template<typename _Tp, typename _Up>
172 inline _GLIBCXX_CONSTEXPR
173 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
174 atan2(_Tp __y, _Up __x)
176 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
177 return atan2(__type(__y), __type(__x));
182 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
183 inline _GLIBCXX_CONSTEXPR float
185 { return __builtin_ceilf(__x); }
187 inline _GLIBCXX_CONSTEXPR long double
188 ceil(long double __x)
189 { return __builtin_ceill(__x); }
192 template<typename _Tp>
193 inline _GLIBCXX_CONSTEXPR
194 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
197 { return __builtin_ceil(__x); }
201 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
202 inline _GLIBCXX_CONSTEXPR float
204 { return __builtin_cosf(__x); }
206 inline _GLIBCXX_CONSTEXPR long double
208 { return __builtin_cosl(__x); }
211 template<typename _Tp>
212 inline _GLIBCXX_CONSTEXPR
213 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
216 { return __builtin_cos(__x); }
220 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
221 inline _GLIBCXX_CONSTEXPR float
223 { return __builtin_coshf(__x); }
225 inline _GLIBCXX_CONSTEXPR long double
226 cosh(long double __x)
227 { return __builtin_coshl(__x); }
230 template<typename _Tp>
231 inline _GLIBCXX_CONSTEXPR
232 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
235 { return __builtin_cosh(__x); }
239 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
240 inline _GLIBCXX_CONSTEXPR float
242 { return __builtin_expf(__x); }
244 inline _GLIBCXX_CONSTEXPR long double
246 { return __builtin_expl(__x); }
249 template<typename _Tp>
250 inline _GLIBCXX_CONSTEXPR
251 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
254 { return __builtin_exp(__x); }
258 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
259 inline _GLIBCXX_CONSTEXPR float
261 { return __builtin_fabsf(__x); }
263 inline _GLIBCXX_CONSTEXPR long double
264 fabs(long double __x)
265 { return __builtin_fabsl(__x); }
268 template<typename _Tp>
269 inline _GLIBCXX_CONSTEXPR
270 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
273 { return __builtin_fabs(__x); }
277 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
278 inline _GLIBCXX_CONSTEXPR float
280 { return __builtin_floorf(__x); }
282 inline _GLIBCXX_CONSTEXPR long double
283 floor(long double __x)
284 { return __builtin_floorl(__x); }
287 template<typename _Tp>
288 inline _GLIBCXX_CONSTEXPR
289 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
292 { return __builtin_floor(__x); }
296 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
297 inline _GLIBCXX_CONSTEXPR float
298 fmod(float __x, float __y)
299 { return __builtin_fmodf(__x, __y); }
301 inline _GLIBCXX_CONSTEXPR long double
302 fmod(long double __x, long double __y)
303 { return __builtin_fmodl(__x, __y); }
306 template<typename _Tp, typename _Up>
307 inline _GLIBCXX_CONSTEXPR
308 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
309 fmod(_Tp __x, _Up __y)
311 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
312 return fmod(__type(__x), __type(__y));
317 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
319 frexp(float __x, int* __exp)
320 { return __builtin_frexpf(__x, __exp); }
323 frexp(long double __x, int* __exp)
324 { return __builtin_frexpl(__x, __exp); }
327 template<typename _Tp>
328 inline _GLIBCXX_CONSTEXPR
329 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
331 frexp(_Tp __x, int* __exp)
332 { return __builtin_frexp(__x, __exp); }
336 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
337 inline _GLIBCXX_CONSTEXPR float
338 ldexp(float __x, int __exp)
339 { return __builtin_ldexpf(__x, __exp); }
341 inline _GLIBCXX_CONSTEXPR long double
342 ldexp(long double __x, int __exp)
343 { return __builtin_ldexpl(__x, __exp); }
346 template<typename _Tp>
347 inline _GLIBCXX_CONSTEXPR
348 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
350 ldexp(_Tp __x, int __exp)
351 { return __builtin_ldexp(__x, __exp); }
355 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
356 inline _GLIBCXX_CONSTEXPR float
358 { return __builtin_logf(__x); }
360 inline _GLIBCXX_CONSTEXPR long double
362 { return __builtin_logl(__x); }
365 template<typename _Tp>
366 inline _GLIBCXX_CONSTEXPR
367 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
370 { return __builtin_log(__x); }
374 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
375 inline _GLIBCXX_CONSTEXPR float
377 { return __builtin_log10f(__x); }
379 inline _GLIBCXX_CONSTEXPR long double
380 log10(long double __x)
381 { return __builtin_log10l(__x); }
384 template<typename _Tp>
385 inline _GLIBCXX_CONSTEXPR
386 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
389 { return __builtin_log10(__x); }
393 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
395 modf(float __x, float* __iptr)
396 { return __builtin_modff(__x, __iptr); }
399 modf(long double __x, long double* __iptr)
400 { return __builtin_modfl(__x, __iptr); }
405 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
406 inline _GLIBCXX_CONSTEXPR float
407 pow(float __x, float __y)
408 { return __builtin_powf(__x, __y); }
410 inline _GLIBCXX_CONSTEXPR long double
411 pow(long double __x, long double __y)
412 { return __builtin_powl(__x, __y); }
414 #if __cplusplus < 201103L
415 // _GLIBCXX_RESOLVE_LIB_DEFECTS
416 // DR 550. What should the return type of pow(float,int) be?
418 pow(double __x, int __i)
419 { return __builtin_powi(__x, __i); }
422 pow(float __x, int __n)
423 { return __builtin_powif(__x, __n); }
426 pow(long double __x, int __n)
427 { return __builtin_powil(__x, __n); }
431 template<typename _Tp, typename _Up>
432 inline _GLIBCXX_CONSTEXPR
433 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
434 pow(_Tp __x, _Up __y)
436 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
437 return pow(__type(__x), __type(__y));
442 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
443 inline _GLIBCXX_CONSTEXPR float
445 { return __builtin_sinf(__x); }
447 inline _GLIBCXX_CONSTEXPR long double
449 { return __builtin_sinl(__x); }
452 template<typename _Tp>
453 inline _GLIBCXX_CONSTEXPR
454 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
457 { return __builtin_sin(__x); }
461 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
462 inline _GLIBCXX_CONSTEXPR float
464 { return __builtin_sinhf(__x); }
466 inline _GLIBCXX_CONSTEXPR long double
467 sinh(long double __x)
468 { return __builtin_sinhl(__x); }
471 template<typename _Tp>
472 inline _GLIBCXX_CONSTEXPR
473 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
476 { return __builtin_sinh(__x); }
480 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
481 inline _GLIBCXX_CONSTEXPR float
483 { return __builtin_sqrtf(__x); }
485 inline _GLIBCXX_CONSTEXPR long double
486 sqrt(long double __x)
487 { return __builtin_sqrtl(__x); }
490 template<typename _Tp>
491 inline _GLIBCXX_CONSTEXPR
492 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
495 { return __builtin_sqrt(__x); }
499 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
500 inline _GLIBCXX_CONSTEXPR float
502 { return __builtin_tanf(__x); }
504 inline _GLIBCXX_CONSTEXPR long double
506 { return __builtin_tanl(__x); }
509 template<typename _Tp>
510 inline _GLIBCXX_CONSTEXPR
511 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
514 { return __builtin_tan(__x); }
518 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
519 inline _GLIBCXX_CONSTEXPR float
521 { return __builtin_tanhf(__x); }
523 inline _GLIBCXX_CONSTEXPR long double
524 tanh(long double __x)
525 { return __builtin_tanhl(__x); }
528 template<typename _Tp>
529 inline _GLIBCXX_CONSTEXPR
530 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
533 { return __builtin_tanh(__x); }
535 _GLIBCXX_END_NAMESPACE_VERSION
538 #if _GLIBCXX_USE_C99_MATH
539 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
541 // These are possible macros imported from C99-land.
549 #undef isgreaterequal
555 namespace std _GLIBCXX_VISIBILITY(default)
557 _GLIBCXX_BEGIN_NAMESPACE_VERSION
559 #if __cplusplus >= 201103L
561 fpclassify(float __x)
562 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
563 FP_SUBNORMAL, FP_ZERO, __x); }
566 fpclassify(double __x)
567 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
568 FP_SUBNORMAL, FP_ZERO, __x); }
571 fpclassify(long double __x)
572 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
573 FP_SUBNORMAL, FP_ZERO, __x); }
575 template<typename _Tp>
576 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
579 { return __x != 0 ? FP_NORMAL : FP_ZERO; }
583 { return __builtin_isfinite(__x); }
587 { return __builtin_isfinite(__x); }
590 isfinite(long double __x)
591 { return __builtin_isfinite(__x); }
593 template<typename _Tp>
594 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
601 { return __builtin_isinf(__x); }
605 { return __builtin_isinf(__x); }
608 isinf(long double __x)
609 { return __builtin_isinf(__x); }
611 template<typename _Tp>
612 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
619 { return __builtin_isnan(__x); }
623 { return __builtin_isnan(__x); }
626 isnan(long double __x)
627 { return __builtin_isnan(__x); }
629 template<typename _Tp>
630 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
637 { return __builtin_isnormal(__x); }
641 { return __builtin_isnormal(__x); }
644 isnormal(long double __x)
645 { return __builtin_isnormal(__x); }
647 template<typename _Tp>
648 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
651 { return __x != 0 ? true : false; }
655 { return __builtin_signbit(__x); }
659 { return __builtin_signbit(__x); }
662 signbit(long double __x)
663 { return __builtin_signbit(__x); }
665 template<typename _Tp>
666 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
669 { return __x < 0 ? true : false; }
672 isgreater(float __x, float __y)
673 { return __builtin_isgreater(__x, __y); }
676 isgreater(double __x, double __y)
677 { return __builtin_isgreater(__x, __y); }
680 isgreater(long double __x, long double __y)
681 { return __builtin_isgreater(__x, __y); }
683 template<typename _Tp, typename _Up>
685 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
686 && __is_arithmetic<_Up>::__value), bool>::__type
687 isgreater(_Tp __x, _Up __y)
689 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
690 return __builtin_isgreater(__type(__x), __type(__y));
694 isgreaterequal(float __x, float __y)
695 { return __builtin_isgreaterequal(__x, __y); }
698 isgreaterequal(double __x, double __y)
699 { return __builtin_isgreaterequal(__x, __y); }
702 isgreaterequal(long double __x, long double __y)
703 { return __builtin_isgreaterequal(__x, __y); }
705 template<typename _Tp, typename _Up>
707 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
708 && __is_arithmetic<_Up>::__value), bool>::__type
709 isgreaterequal(_Tp __x, _Up __y)
711 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
712 return __builtin_isgreaterequal(__type(__x), __type(__y));
716 isless(float __x, float __y)
717 { return __builtin_isless(__x, __y); }
720 isless(double __x, double __y)
721 { return __builtin_isless(__x, __y); }
724 isless(long double __x, long double __y)
725 { return __builtin_isless(__x, __y); }
727 template<typename _Tp, typename _Up>
729 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
730 && __is_arithmetic<_Up>::__value), bool>::__type
731 isless(_Tp __x, _Up __y)
733 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
734 return __builtin_isless(__type(__x), __type(__y));
738 islessequal(float __x, float __y)
739 { return __builtin_islessequal(__x, __y); }
742 islessequal(double __x, double __y)
743 { return __builtin_islessequal(__x, __y); }
746 islessequal(long double __x, long double __y)
747 { return __builtin_islessequal(__x, __y); }
749 template<typename _Tp, typename _Up>
751 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
752 && __is_arithmetic<_Up>::__value), bool>::__type
753 islessequal(_Tp __x, _Up __y)
755 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
756 return __builtin_islessequal(__type(__x), __type(__y));
760 islessgreater(float __x, float __y)
761 { return __builtin_islessgreater(__x, __y); }
764 islessgreater(double __x, double __y)
765 { return __builtin_islessgreater(__x, __y); }
768 islessgreater(long double __x, long double __y)
769 { return __builtin_islessgreater(__x, __y); }
771 template<typename _Tp, typename _Up>
773 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
774 && __is_arithmetic<_Up>::__value), bool>::__type
775 islessgreater(_Tp __x, _Up __y)
777 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
778 return __builtin_islessgreater(__type(__x), __type(__y));
782 isunordered(float __x, float __y)
783 { return __builtin_isunordered(__x, __y); }
786 isunordered(double __x, double __y)
787 { return __builtin_isunordered(__x, __y); }
790 isunordered(long double __x, long double __y)
791 { return __builtin_isunordered(__x, __y); }
793 template<typename _Tp, typename _Up>
795 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
796 && __is_arithmetic<_Up>::__value), bool>::__type
797 isunordered(_Tp __x, _Up __y)
799 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
800 return __builtin_isunordered(__type(__x), __type(__y));
805 template<typename _Tp>
806 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
810 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
811 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
812 FP_SUBNORMAL, FP_ZERO, __type(__f));
815 template<typename _Tp>
816 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
820 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
821 return __builtin_isfinite(__type(__f));
824 template<typename _Tp>
825 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
829 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
830 return __builtin_isinf(__type(__f));
833 template<typename _Tp>
834 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
838 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
839 return __builtin_isnan(__type(__f));
842 template<typename _Tp>
843 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
847 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
848 return __builtin_isnormal(__type(__f));
851 template<typename _Tp>
852 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
856 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
857 return __builtin_signbit(__type(__f));
860 template<typename _Tp>
861 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
863 isgreater(_Tp __f1, _Tp __f2)
865 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
866 return __builtin_isgreater(__type(__f1), __type(__f2));
869 template<typename _Tp>
870 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
872 isgreaterequal(_Tp __f1, _Tp __f2)
874 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
875 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
878 template<typename _Tp>
879 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
881 isless(_Tp __f1, _Tp __f2)
883 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
884 return __builtin_isless(__type(__f1), __type(__f2));
887 template<typename _Tp>
888 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
890 islessequal(_Tp __f1, _Tp __f2)
892 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
893 return __builtin_islessequal(__type(__f1), __type(__f2));
896 template<typename _Tp>
897 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
899 islessgreater(_Tp __f1, _Tp __f2)
901 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
902 return __builtin_islessgreater(__type(__f1), __type(__f2));
905 template<typename _Tp>
906 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
908 isunordered(_Tp __f1, _Tp __f2)
910 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
911 return __builtin_isunordered(__type(__f1), __type(__f2));
916 _GLIBCXX_END_NAMESPACE_VERSION
919 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
922 #if __cplusplus >= 201103L
924 #ifdef _GLIBCXX_USE_C99_MATH_TR1
1032 namespace std _GLIBCXX_VISIBILITY(default)
1034 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1146 using ::nexttowardf;
1147 using ::nexttowardl;
1181 /// Additional overloads.
1184 { return __builtin_acoshf(__x); }
1186 constexpr long double
1187 acosh(long double __x)
1188 { return __builtin_acoshl(__x); }
1190 template<typename _Tp>
1191 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1194 { return __builtin_acosh(__x); }
1198 { return __builtin_asinhf(__x); }
1200 constexpr long double
1201 asinh(long double __x)
1202 { return __builtin_asinhl(__x); }
1204 template<typename _Tp>
1205 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1208 { return __builtin_asinh(__x); }
1212 { return __builtin_atanhf(__x); }
1214 constexpr long double
1215 atanh(long double __x)
1216 { return __builtin_atanhl(__x); }
1218 template<typename _Tp>
1219 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1222 { return __builtin_atanh(__x); }
1226 { return __builtin_cbrtf(__x); }
1228 constexpr long double
1229 cbrt(long double __x)
1230 { return __builtin_cbrtl(__x); }
1232 template<typename _Tp>
1233 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1236 { return __builtin_cbrt(__x); }
1239 copysign(float __x, float __y)
1240 { return __builtin_copysignf(__x, __y); }
1242 constexpr long double
1243 copysign(long double __x, long double __y)
1244 { return __builtin_copysignl(__x, __y); }
1246 template<typename _Tp, typename _Up>
1247 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1248 copysign(_Tp __x, _Up __y)
1250 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1251 return copysign(__type(__x), __type(__y));
1256 { return __builtin_erff(__x); }
1258 constexpr long double
1259 erf(long double __x)
1260 { return __builtin_erfl(__x); }
1262 template<typename _Tp>
1263 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1266 { return __builtin_erf(__x); }
1270 { return __builtin_erfcf(__x); }
1272 constexpr long double
1273 erfc(long double __x)
1274 { return __builtin_erfcl(__x); }
1276 template<typename _Tp>
1277 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1280 { return __builtin_erfc(__x); }
1284 { return __builtin_exp2f(__x); }
1286 constexpr long double
1287 exp2(long double __x)
1288 { return __builtin_exp2l(__x); }
1290 template<typename _Tp>
1291 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1294 { return __builtin_exp2(__x); }
1298 { return __builtin_expm1f(__x); }
1300 constexpr long double
1301 expm1(long double __x)
1302 { return __builtin_expm1l(__x); }
1304 template<typename _Tp>
1305 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1308 { return __builtin_expm1(__x); }
1311 fdim(float __x, float __y)
1312 { return __builtin_fdimf(__x, __y); }
1314 constexpr long double
1315 fdim(long double __x, long double __y)
1316 { return __builtin_fdiml(__x, __y); }
1318 template<typename _Tp, typename _Up>
1319 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1320 fdim(_Tp __x, _Up __y)
1322 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1323 return fdim(__type(__x), __type(__y));
1327 fma(float __x, float __y, float __z)
1328 { return __builtin_fmaf(__x, __y, __z); }
1330 constexpr long double
1331 fma(long double __x, long double __y, long double __z)
1332 { return __builtin_fmal(__x, __y, __z); }
1334 template<typename _Tp, typename _Up, typename _Vp>
1335 constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
1336 fma(_Tp __x, _Up __y, _Vp __z)
1338 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
1339 return fma(__type(__x), __type(__y), __type(__z));
1343 fmax(float __x, float __y)
1344 { return __builtin_fmaxf(__x, __y); }
1346 constexpr long double
1347 fmax(long double __x, long double __y)
1348 { return __builtin_fmaxl(__x, __y); }
1350 template<typename _Tp, typename _Up>
1351 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1352 fmax(_Tp __x, _Up __y)
1354 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1355 return fmax(__type(__x), __type(__y));
1359 fmin(float __x, float __y)
1360 { return __builtin_fminf(__x, __y); }
1362 constexpr long double
1363 fmin(long double __x, long double __y)
1364 { return __builtin_fminl(__x, __y); }
1366 template<typename _Tp, typename _Up>
1367 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1368 fmin(_Tp __x, _Up __y)
1370 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1371 return fmin(__type(__x), __type(__y));
1375 hypot(float __x, float __y)
1376 { return __builtin_hypotf(__x, __y); }
1378 constexpr long double
1379 hypot(long double __x, long double __y)
1380 { return __builtin_hypotl(__x, __y); }
1382 template<typename _Tp, typename _Up>
1383 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1384 hypot(_Tp __x, _Up __y)
1386 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1387 return hypot(__type(__x), __type(__y));
1392 { return __builtin_ilogbf(__x); }
1395 ilogb(long double __x)
1396 { return __builtin_ilogbl(__x); }
1398 template<typename _Tp>
1400 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1403 { return __builtin_ilogb(__x); }
1407 { return __builtin_lgammaf(__x); }
1409 constexpr long double
1410 lgamma(long double __x)
1411 { return __builtin_lgammal(__x); }
1413 template<typename _Tp>
1414 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1417 { return __builtin_lgamma(__x); }
1421 { return __builtin_llrintf(__x); }
1424 llrint(long double __x)
1425 { return __builtin_llrintl(__x); }
1427 template<typename _Tp>
1428 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1431 { return __builtin_llrint(__x); }
1435 { return __builtin_llroundf(__x); }
1438 llround(long double __x)
1439 { return __builtin_llroundl(__x); }
1441 template<typename _Tp>
1442 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1445 { return __builtin_llround(__x); }
1449 { return __builtin_log1pf(__x); }
1451 constexpr long double
1452 log1p(long double __x)
1453 { return __builtin_log1pl(__x); }
1455 template<typename _Tp>
1456 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1459 { return __builtin_log1p(__x); }
1464 { return __builtin_log2f(__x); }
1466 constexpr long double
1467 log2(long double __x)
1468 { return __builtin_log2l(__x); }
1470 template<typename _Tp>
1471 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1474 { return __builtin_log2(__x); }
1478 { return __builtin_logbf(__x); }
1480 constexpr long double
1481 logb(long double __x)
1482 { return __builtin_logbl(__x); }
1484 template<typename _Tp>
1485 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1488 { return __builtin_logb(__x); }
1492 { return __builtin_lrintf(__x); }
1495 lrint(long double __x)
1496 { return __builtin_lrintl(__x); }
1498 template<typename _Tp>
1499 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1502 { return __builtin_lrint(__x); }
1506 { return __builtin_lroundf(__x); }
1509 lround(long double __x)
1510 { return __builtin_lroundl(__x); }
1512 template<typename _Tp>
1513 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1516 { return __builtin_lround(__x); }
1519 nearbyint(float __x)
1520 { return __builtin_nearbyintf(__x); }
1522 constexpr long double
1523 nearbyint(long double __x)
1524 { return __builtin_nearbyintl(__x); }
1526 template<typename _Tp>
1527 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1530 { return __builtin_nearbyint(__x); }
1533 nextafter(float __x, float __y)
1534 { return __builtin_nextafterf(__x, __y); }
1536 constexpr long double
1537 nextafter(long double __x, long double __y)
1538 { return __builtin_nextafterl(__x, __y); }
1540 template<typename _Tp, typename _Up>
1541 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1542 nextafter(_Tp __x, _Up __y)
1544 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1545 return nextafter(__type(__x), __type(__y));
1549 nexttoward(float __x, long double __y)
1550 { return __builtin_nexttowardf(__x, __y); }
1552 constexpr long double
1553 nexttoward(long double __x, long double __y)
1554 { return __builtin_nexttowardl(__x, __y); }
1556 template<typename _Tp>
1557 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1559 nexttoward(_Tp __x, long double __y)
1560 { return __builtin_nexttoward(__x, __y); }
1563 remainder(float __x, float __y)
1564 { return __builtin_remainderf(__x, __y); }
1566 constexpr long double
1567 remainder(long double __x, long double __y)
1568 { return __builtin_remainderl(__x, __y); }
1570 template<typename _Tp, typename _Up>
1571 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1572 remainder(_Tp __x, _Up __y)
1574 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1575 return remainder(__type(__x), __type(__y));
1579 remquo(float __x, float __y, int* __pquo)
1580 { return __builtin_remquof(__x, __y, __pquo); }
1583 remquo(long double __x, long double __y, int* __pquo)
1584 { return __builtin_remquol(__x, __y, __pquo); }
1586 template<typename _Tp, typename _Up>
1587 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1588 remquo(_Tp __x, _Up __y, int* __pquo)
1590 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1591 return remquo(__type(__x), __type(__y), __pquo);
1596 { return __builtin_rintf(__x); }
1598 constexpr long double
1599 rint(long double __x)
1600 { return __builtin_rintl(__x); }
1602 template<typename _Tp>
1603 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1606 { return __builtin_rint(__x); }
1610 { return __builtin_roundf(__x); }
1612 constexpr long double
1613 round(long double __x)
1614 { return __builtin_roundl(__x); }
1616 template<typename _Tp>
1617 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1620 { return __builtin_round(__x); }
1623 scalbln(float __x, long __ex)
1624 { return __builtin_scalblnf(__x, __ex); }
1626 constexpr long double
1627 scalbln(long double __x, long __ex)
1628 { return __builtin_scalblnl(__x, __ex); }
1630 template<typename _Tp>
1631 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1633 scalbln(_Tp __x, long __ex)
1634 { return __builtin_scalbln(__x, __ex); }
1637 scalbn(float __x, int __ex)
1638 { return __builtin_scalbnf(__x, __ex); }
1640 constexpr long double
1641 scalbn(long double __x, int __ex)
1642 { return __builtin_scalbnl(__x, __ex); }
1644 template<typename _Tp>
1645 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1647 scalbn(_Tp __x, int __ex)
1648 { return __builtin_scalbn(__x, __ex); }
1652 { return __builtin_tgammaf(__x); }
1654 constexpr long double
1655 tgamma(long double __x)
1656 { return __builtin_tgammal(__x); }
1658 template<typename _Tp>
1659 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1662 { return __builtin_tgamma(__x); }
1666 { return __builtin_truncf(__x); }
1668 constexpr long double
1669 trunc(long double __x)
1670 { return __builtin_truncl(__x); }
1672 template<typename _Tp>
1673 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1676 { return __builtin_trunc(__x); }
1678 _GLIBCXX_END_NAMESPACE_VERSION
1681 #endif // _GLIBCXX_USE_C99_MATH_TR1