1 // -*- C++ -*- C forwarding header.
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007, 2008, 2009, 2010, 2011
5 // Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // Under Section 7 of GPL version 3, you are granted additional
19 // permissions described in the GCC Runtime Library Exception, version
20 // 3.1, as published by the Free Software Foundation.
22 // You should have received a copy of the GNU General Public License and
23 // a copy of the GCC Runtime Library Exception along with this program;
24 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 // <http://www.gnu.org/licenses/>.
27 /** @file include/cmath
28 * This is a Standard C++ Library file. You should @c \#include this file
29 * in your programs, rather than any of the @a *.h implementation files.
31 * This is the C++ version of the Standard C Library header @c math.h,
32 * and its contents are (mostly) the same as that header, but are all
33 * contained in the namespace @c std (except for names which are defined
38 // ISO C++ 14882: 26.5 C library
41 #pragma GCC system_header
43 #include <bits/c++config.h>
44 #include <bits/cpp_type_traits.h>
45 #include <ext/type_traits.h>
48 #ifndef _GLIBCXX_CMATH
49 #define _GLIBCXX_CMATH 1
51 // Get rid of those macros defined in <math.h> in lieu of real functions.
77 namespace std _GLIBCXX_VISIBILITY(default)
79 _GLIBCXX_BEGIN_NAMESPACE_VERSION
81 #if !defined(__CORRECT_ISO_CPP_MATH_H_PROTO1) \
82 && !defined(__CORRECT_ISO_CPP_MATH_H_PROTO2)
83 inline _GLIBCXX_CONSTEXPR double
85 { return __builtin_fabs(__x); }
88 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
89 inline _GLIBCXX_CONSTEXPR float
91 { return __builtin_fabsf(__x); }
93 inline _GLIBCXX_CONSTEXPR long double
95 { return __builtin_fabsl(__x); }
98 template<typename _Tp>
99 inline _GLIBCXX_CONSTEXPR
100 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
103 { return __builtin_fabs(__x); }
107 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
108 inline _GLIBCXX_CONSTEXPR float
110 { return __builtin_acosf(__x); }
112 inline _GLIBCXX_CONSTEXPR long double
113 acos(long double __x)
114 { return __builtin_acosl(__x); }
117 template<typename _Tp>
118 inline _GLIBCXX_CONSTEXPR
119 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
122 { return __builtin_acos(__x); }
126 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
127 inline _GLIBCXX_CONSTEXPR float
129 { return __builtin_asinf(__x); }
131 inline _GLIBCXX_CONSTEXPR long double
132 asin(long double __x)
133 { return __builtin_asinl(__x); }
136 template<typename _Tp>
137 inline _GLIBCXX_CONSTEXPR
138 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
141 { return __builtin_asin(__x); }
145 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
146 inline _GLIBCXX_CONSTEXPR float
148 { return __builtin_atanf(__x); }
150 inline _GLIBCXX_CONSTEXPR long double
151 atan(long double __x)
152 { return __builtin_atanl(__x); }
155 template<typename _Tp>
156 inline _GLIBCXX_CONSTEXPR
157 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
160 { return __builtin_atan(__x); }
164 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
165 inline _GLIBCXX_CONSTEXPR float
166 atan2(float __y, float __x)
167 { return __builtin_atan2f(__y, __x); }
169 inline _GLIBCXX_CONSTEXPR long double
170 atan2(long double __y, long double __x)
171 { return __builtin_atan2l(__y, __x); }
174 template<typename _Tp, typename _Up>
175 inline _GLIBCXX_CONSTEXPR
176 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
177 atan2(_Tp __y, _Up __x)
179 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
180 return atan2(__type(__y), __type(__x));
185 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
186 inline _GLIBCXX_CONSTEXPR float
188 { return __builtin_ceilf(__x); }
190 inline _GLIBCXX_CONSTEXPR long double
191 ceil(long double __x)
192 { return __builtin_ceill(__x); }
195 template<typename _Tp>
196 inline _GLIBCXX_CONSTEXPR
197 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
200 { return __builtin_ceil(__x); }
204 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
205 inline _GLIBCXX_CONSTEXPR float
207 { return __builtin_cosf(__x); }
209 inline _GLIBCXX_CONSTEXPR long double
211 { return __builtin_cosl(__x); }
214 template<typename _Tp>
215 inline _GLIBCXX_CONSTEXPR
216 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
219 { return __builtin_cos(__x); }
223 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
224 inline _GLIBCXX_CONSTEXPR float
226 { return __builtin_coshf(__x); }
228 inline _GLIBCXX_CONSTEXPR long double
229 cosh(long double __x)
230 { return __builtin_coshl(__x); }
233 template<typename _Tp>
234 inline _GLIBCXX_CONSTEXPR
235 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
238 { return __builtin_cosh(__x); }
242 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
243 inline _GLIBCXX_CONSTEXPR float
245 { return __builtin_expf(__x); }
247 inline _GLIBCXX_CONSTEXPR long double
249 { return __builtin_expl(__x); }
252 template<typename _Tp>
253 inline _GLIBCXX_CONSTEXPR
254 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
257 { return __builtin_exp(__x); }
261 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
262 inline _GLIBCXX_CONSTEXPR float
264 { return __builtin_fabsf(__x); }
266 inline _GLIBCXX_CONSTEXPR long double
267 fabs(long double __x)
268 { return __builtin_fabsl(__x); }
271 template<typename _Tp>
272 inline _GLIBCXX_CONSTEXPR
273 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
276 { return __builtin_fabs(__x); }
280 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
281 inline _GLIBCXX_CONSTEXPR float
283 { return __builtin_floorf(__x); }
285 inline _GLIBCXX_CONSTEXPR long double
286 floor(long double __x)
287 { return __builtin_floorl(__x); }
290 template<typename _Tp>
291 inline _GLIBCXX_CONSTEXPR
292 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
295 { return __builtin_floor(__x); }
299 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
300 inline _GLIBCXX_CONSTEXPR float
301 fmod(float __x, float __y)
302 { return __builtin_fmodf(__x, __y); }
304 inline _GLIBCXX_CONSTEXPR long double
305 fmod(long double __x, long double __y)
306 { return __builtin_fmodl(__x, __y); }
309 template<typename _Tp, typename _Up>
310 inline _GLIBCXX_CONSTEXPR
311 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
312 fmod(_Tp __x, _Up __y)
314 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
315 return fmod(__type(__x), __type(__y));
320 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
322 frexp(float __x, int* __exp)
323 { return __builtin_frexpf(__x, __exp); }
326 frexp(long double __x, int* __exp)
327 { return __builtin_frexpl(__x, __exp); }
330 template<typename _Tp>
331 inline _GLIBCXX_CONSTEXPR
332 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
334 frexp(_Tp __x, int* __exp)
335 { return __builtin_frexp(__x, __exp); }
339 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
340 inline _GLIBCXX_CONSTEXPR float
341 ldexp(float __x, int __exp)
342 { return __builtin_ldexpf(__x, __exp); }
344 inline _GLIBCXX_CONSTEXPR long double
345 ldexp(long double __x, int __exp)
346 { return __builtin_ldexpl(__x, __exp); }
349 template<typename _Tp>
350 inline _GLIBCXX_CONSTEXPR
351 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
353 ldexp(_Tp __x, int __exp)
354 { return __builtin_ldexp(__x, __exp); }
358 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
359 inline _GLIBCXX_CONSTEXPR float
361 { return __builtin_logf(__x); }
363 inline _GLIBCXX_CONSTEXPR long double
365 { return __builtin_logl(__x); }
368 template<typename _Tp>
369 inline _GLIBCXX_CONSTEXPR
370 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
373 { return __builtin_log(__x); }
377 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
378 inline _GLIBCXX_CONSTEXPR float
380 { return __builtin_log10f(__x); }
382 inline _GLIBCXX_CONSTEXPR long double
383 log10(long double __x)
384 { return __builtin_log10l(__x); }
387 template<typename _Tp>
388 inline _GLIBCXX_CONSTEXPR
389 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
392 { return __builtin_log10(__x); }
396 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
398 modf(float __x, float* __iptr)
399 { return __builtin_modff(__x, __iptr); }
402 modf(long double __x, long double* __iptr)
403 { return __builtin_modfl(__x, __iptr); }
408 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
409 inline _GLIBCXX_CONSTEXPR float
410 pow(float __x, float __y)
411 { return __builtin_powf(__x, __y); }
413 inline _GLIBCXX_CONSTEXPR long double
414 pow(long double __x, long double __y)
415 { return __builtin_powl(__x, __y); }
417 #ifndef __GXX_EXPERIMENTAL_CXX0X__
418 // _GLIBCXX_RESOLVE_LIB_DEFECTS
419 // DR 550. What should the return type of pow(float,int) be?
421 pow(double __x, int __i)
422 { return __builtin_powi(__x, __i); }
425 pow(float __x, int __n)
426 { return __builtin_powif(__x, __n); }
429 pow(long double __x, int __n)
430 { return __builtin_powil(__x, __n); }
434 template<typename _Tp, typename _Up>
435 inline _GLIBCXX_CONSTEXPR
436 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
437 pow(_Tp __x, _Up __y)
439 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
440 return pow(__type(__x), __type(__y));
445 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
446 inline _GLIBCXX_CONSTEXPR float
448 { return __builtin_sinf(__x); }
450 inline _GLIBCXX_CONSTEXPR long double
452 { return __builtin_sinl(__x); }
455 template<typename _Tp>
456 inline _GLIBCXX_CONSTEXPR
457 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
460 { return __builtin_sin(__x); }
464 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
465 inline _GLIBCXX_CONSTEXPR float
467 { return __builtin_sinhf(__x); }
469 inline _GLIBCXX_CONSTEXPR long double
470 sinh(long double __x)
471 { return __builtin_sinhl(__x); }
474 template<typename _Tp>
475 inline _GLIBCXX_CONSTEXPR
476 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
479 { return __builtin_sinh(__x); }
483 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
484 inline _GLIBCXX_CONSTEXPR float
486 { return __builtin_sqrtf(__x); }
488 inline _GLIBCXX_CONSTEXPR long double
489 sqrt(long double __x)
490 { return __builtin_sqrtl(__x); }
493 template<typename _Tp>
494 inline _GLIBCXX_CONSTEXPR
495 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
498 { return __builtin_sqrt(__x); }
502 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
503 inline _GLIBCXX_CONSTEXPR float
505 { return __builtin_tanf(__x); }
507 inline _GLIBCXX_CONSTEXPR long double
509 { return __builtin_tanl(__x); }
512 template<typename _Tp>
513 inline _GLIBCXX_CONSTEXPR
514 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
517 { return __builtin_tan(__x); }
521 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
522 inline _GLIBCXX_CONSTEXPR float
524 { return __builtin_tanhf(__x); }
526 inline _GLIBCXX_CONSTEXPR long double
527 tanh(long double __x)
528 { return __builtin_tanhl(__x); }
531 template<typename _Tp>
532 inline _GLIBCXX_CONSTEXPR
533 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
536 { return __builtin_tanh(__x); }
538 _GLIBCXX_END_NAMESPACE_VERSION
541 #if _GLIBCXX_USE_C99_MATH
542 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
544 // These are possible macros imported from C99-land.
552 #undef isgreaterequal
558 namespace std _GLIBCXX_VISIBILITY(default)
560 _GLIBCXX_BEGIN_NAMESPACE_VERSION
562 #ifdef __GXX_EXPERIMENTAL_CXX0X__
564 fpclassify(float __x)
565 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
566 FP_SUBNORMAL, FP_ZERO, __x); }
569 fpclassify(double __x)
570 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
571 FP_SUBNORMAL, FP_ZERO, __x); }
574 fpclassify(long double __x)
575 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
576 FP_SUBNORMAL, FP_ZERO, __x); }
578 template<typename _Tp>
579 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
582 { return __x != 0 ? FP_NORMAL : FP_ZERO; }
586 { return __builtin_isfinite(__x); }
590 { return __builtin_isfinite(__x); }
593 isfinite(long double __x)
594 { return __builtin_isfinite(__x); }
596 template<typename _Tp>
597 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
604 { return __builtin_isinf(__x); }
608 { return __builtin_isinf(__x); }
611 isinf(long double __x)
612 { return __builtin_isinf(__x); }
614 template<typename _Tp>
615 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
622 { return __builtin_isnan(__x); }
626 { return __builtin_isnan(__x); }
629 isnan(long double __x)
630 { return __builtin_isnan(__x); }
632 template<typename _Tp>
633 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
640 { return __builtin_isnormal(__x); }
644 { return __builtin_isnormal(__x); }
647 isnormal(long double __x)
648 { return __builtin_isnormal(__x); }
650 template<typename _Tp>
651 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
654 { return __x != 0 ? true : false; }
658 { return __builtin_signbit(__x); }
662 { return __builtin_signbit(__x); }
665 signbit(long double __x)
666 { return __builtin_signbit(__x); }
668 template<typename _Tp>
669 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
672 { return __x < 0 ? true : false; }
675 isgreater(float __x, float __y)
676 { return __builtin_isgreater(__x, __y); }
679 isgreater(double __x, double __y)
680 { return __builtin_isgreater(__x, __y); }
683 isgreater(long double __x, long double __y)
684 { return __builtin_isgreater(__x, __y); }
686 template<typename _Tp, typename _Up>
688 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
689 && __is_arithmetic<_Up>::__value), bool>::__type
690 isgreater(_Tp __x, _Up __y)
692 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
693 return __builtin_isgreater(__type(__x), __type(__y));
697 isgreaterequal(float __x, float __y)
698 { return __builtin_isgreaterequal(__x, __y); }
701 isgreaterequal(double __x, double __y)
702 { return __builtin_isgreaterequal(__x, __y); }
705 isgreaterequal(long double __x, long double __y)
706 { return __builtin_isgreaterequal(__x, __y); }
708 template<typename _Tp, typename _Up>
710 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
711 && __is_arithmetic<_Up>::__value), bool>::__type
712 isgreaterequal(_Tp __x, _Up __y)
714 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
715 return __builtin_isgreaterequal(__type(__x), __type(__y));
719 isless(float __x, float __y)
720 { return __builtin_isless(__x, __y); }
723 isless(double __x, double __y)
724 { return __builtin_isless(__x, __y); }
727 isless(long double __x, long double __y)
728 { return __builtin_isless(__x, __y); }
730 template<typename _Tp, typename _Up>
732 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
733 && __is_arithmetic<_Up>::__value), bool>::__type
734 isless(_Tp __x, _Up __y)
736 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
737 return __builtin_isless(__type(__x), __type(__y));
741 islessequal(float __x, float __y)
742 { return __builtin_islessequal(__x, __y); }
745 islessequal(double __x, double __y)
746 { return __builtin_islessequal(__x, __y); }
749 islessequal(long double __x, long double __y)
750 { return __builtin_islessequal(__x, __y); }
752 template<typename _Tp, typename _Up>
754 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
755 && __is_arithmetic<_Up>::__value), bool>::__type
756 islessequal(_Tp __x, _Up __y)
758 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
759 return __builtin_islessequal(__type(__x), __type(__y));
763 islessgreater(float __x, float __y)
764 { return __builtin_islessgreater(__x, __y); }
767 islessgreater(double __x, double __y)
768 { return __builtin_islessgreater(__x, __y); }
771 islessgreater(long double __x, long double __y)
772 { return __builtin_islessgreater(__x, __y); }
774 template<typename _Tp, typename _Up>
776 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
777 && __is_arithmetic<_Up>::__value), bool>::__type
778 islessgreater(_Tp __x, _Up __y)
780 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
781 return __builtin_islessgreater(__type(__x), __type(__y));
785 isunordered(float __x, float __y)
786 { return __builtin_isunordered(__x, __y); }
789 isunordered(double __x, double __y)
790 { return __builtin_isunordered(__x, __y); }
793 isunordered(long double __x, long double __y)
794 { return __builtin_isunordered(__x, __y); }
796 template<typename _Tp, typename _Up>
798 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
799 && __is_arithmetic<_Up>::__value), bool>::__type
800 isunordered(_Tp __x, _Up __y)
802 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
803 return __builtin_isunordered(__type(__x), __type(__y));
808 template<typename _Tp>
809 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
813 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
814 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
815 FP_SUBNORMAL, FP_ZERO, __type(__f));
818 template<typename _Tp>
819 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
823 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
824 return __builtin_isfinite(__type(__f));
827 template<typename _Tp>
828 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
832 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
833 return __builtin_isinf(__type(__f));
836 template<typename _Tp>
837 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
841 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
842 return __builtin_isnan(__type(__f));
845 template<typename _Tp>
846 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
850 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
851 return __builtin_isnormal(__type(__f));
854 template<typename _Tp>
855 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
859 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
860 return __builtin_signbit(__type(__f));
863 template<typename _Tp>
864 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
866 isgreater(_Tp __f1, _Tp __f2)
868 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
869 return __builtin_isgreater(__type(__f1), __type(__f2));
872 template<typename _Tp>
873 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
875 isgreaterequal(_Tp __f1, _Tp __f2)
877 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
878 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
881 template<typename _Tp>
882 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
884 isless(_Tp __f1, _Tp __f2)
886 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
887 return __builtin_isless(__type(__f1), __type(__f2));
890 template<typename _Tp>
891 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
893 islessequal(_Tp __f1, _Tp __f2)
895 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
896 return __builtin_islessequal(__type(__f1), __type(__f2));
899 template<typename _Tp>
900 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
902 islessgreater(_Tp __f1, _Tp __f2)
904 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
905 return __builtin_islessgreater(__type(__f1), __type(__f2));
908 template<typename _Tp>
909 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
911 isunordered(_Tp __f1, _Tp __f2)
913 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
914 return __builtin_isunordered(__type(__f1), __type(__f2));
919 _GLIBCXX_END_NAMESPACE_VERSION
922 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
925 #ifdef __GXX_EXPERIMENTAL_CXX0X__
927 #ifdef _GLIBCXX_USE_C99_MATH_TR1
1035 namespace std _GLIBCXX_VISIBILITY(default)
1037 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1149 using ::nexttowardf;
1150 using ::nexttowardl;
1184 /// Additional overloads.
1187 { return __builtin_acoshf(__x); }
1189 constexpr long double
1190 acosh(long double __x)
1191 { return __builtin_acoshl(__x); }
1193 template<typename _Tp>
1194 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1197 { return __builtin_acosh(__x); }
1201 { return __builtin_asinhf(__x); }
1203 constexpr long double
1204 asinh(long double __x)
1205 { return __builtin_asinhl(__x); }
1207 template<typename _Tp>
1208 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1211 { return __builtin_asinh(__x); }
1215 { return __builtin_atanhf(__x); }
1217 constexpr long double
1218 atanh(long double __x)
1219 { return __builtin_atanhl(__x); }
1221 template<typename _Tp>
1222 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1225 { return __builtin_atanh(__x); }
1229 { return __builtin_cbrtf(__x); }
1231 constexpr long double
1232 cbrt(long double __x)
1233 { return __builtin_cbrtl(__x); }
1235 template<typename _Tp>
1236 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1239 { return __builtin_cbrt(__x); }
1242 copysign(float __x, float __y)
1243 { return __builtin_copysignf(__x, __y); }
1245 constexpr long double
1246 copysign(long double __x, long double __y)
1247 { return __builtin_copysignl(__x, __y); }
1249 template<typename _Tp, typename _Up>
1250 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1251 copysign(_Tp __x, _Up __y)
1253 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1254 return copysign(__type(__x), __type(__y));
1259 { return __builtin_erff(__x); }
1261 constexpr long double
1262 erf(long double __x)
1263 { return __builtin_erfl(__x); }
1265 template<typename _Tp>
1266 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1269 { return __builtin_erf(__x); }
1273 { return __builtin_erfcf(__x); }
1275 constexpr long double
1276 erfc(long double __x)
1277 { return __builtin_erfcl(__x); }
1279 template<typename _Tp>
1280 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1283 { return __builtin_erfc(__x); }
1287 { return __builtin_exp2f(__x); }
1289 constexpr long double
1290 exp2(long double __x)
1291 { return __builtin_exp2l(__x); }
1293 template<typename _Tp>
1294 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1297 { return __builtin_exp2(__x); }
1301 { return __builtin_expm1f(__x); }
1303 constexpr long double
1304 expm1(long double __x)
1305 { return __builtin_expm1l(__x); }
1307 template<typename _Tp>
1308 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1311 { return __builtin_expm1(__x); }
1314 fdim(float __x, float __y)
1315 { return __builtin_fdimf(__x, __y); }
1317 constexpr long double
1318 fdim(long double __x, long double __y)
1319 { return __builtin_fdiml(__x, __y); }
1321 template<typename _Tp, typename _Up>
1322 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1323 fdim(_Tp __x, _Up __y)
1325 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1326 return fdim(__type(__x), __type(__y));
1330 fma(float __x, float __y, float __z)
1331 { return __builtin_fmaf(__x, __y, __z); }
1333 constexpr long double
1334 fma(long double __x, long double __y, long double __z)
1335 { return __builtin_fmal(__x, __y, __z); }
1337 template<typename _Tp, typename _Up, typename _Vp>
1338 constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
1339 fma(_Tp __x, _Up __y, _Vp __z)
1341 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
1342 return fma(__type(__x), __type(__y), __type(__z));
1346 fmax(float __x, float __y)
1347 { return __builtin_fmaxf(__x, __y); }
1349 constexpr long double
1350 fmax(long double __x, long double __y)
1351 { return __builtin_fmaxl(__x, __y); }
1353 template<typename _Tp, typename _Up>
1354 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1355 fmax(_Tp __x, _Up __y)
1357 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1358 return fmax(__type(__x), __type(__y));
1362 fmin(float __x, float __y)
1363 { return __builtin_fminf(__x, __y); }
1365 constexpr long double
1366 fmin(long double __x, long double __y)
1367 { return __builtin_fminl(__x, __y); }
1369 template<typename _Tp, typename _Up>
1370 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1371 fmin(_Tp __x, _Up __y)
1373 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1374 return fmin(__type(__x), __type(__y));
1378 hypot(float __x, float __y)
1379 { return __builtin_hypotf(__x, __y); }
1381 constexpr long double
1382 hypot(long double __x, long double __y)
1383 { return __builtin_hypotl(__x, __y); }
1385 template<typename _Tp, typename _Up>
1386 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1387 hypot(_Tp __x, _Up __y)
1389 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1390 return hypot(__type(__x), __type(__y));
1395 { return __builtin_ilogbf(__x); }
1398 ilogb(long double __x)
1399 { return __builtin_ilogbl(__x); }
1401 template<typename _Tp>
1403 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1406 { return __builtin_ilogb(__x); }
1410 { return __builtin_lgammaf(__x); }
1412 constexpr long double
1413 lgamma(long double __x)
1414 { return __builtin_lgammal(__x); }
1416 template<typename _Tp>
1417 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1420 { return __builtin_lgamma(__x); }
1424 { return __builtin_llrintf(__x); }
1427 llrint(long double __x)
1428 { return __builtin_llrintl(__x); }
1430 template<typename _Tp>
1431 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1434 { return __builtin_llrint(__x); }
1438 { return __builtin_llroundf(__x); }
1441 llround(long double __x)
1442 { return __builtin_llroundl(__x); }
1444 template<typename _Tp>
1445 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1448 { return __builtin_llround(__x); }
1452 { return __builtin_log1pf(__x); }
1454 constexpr long double
1455 log1p(long double __x)
1456 { return __builtin_log1pl(__x); }
1458 template<typename _Tp>
1459 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1462 { return __builtin_log1p(__x); }
1467 { return __builtin_log2f(__x); }
1469 constexpr long double
1470 log2(long double __x)
1471 { return __builtin_log2l(__x); }
1473 template<typename _Tp>
1474 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1477 { return __builtin_log2(__x); }
1481 { return __builtin_logbf(__x); }
1483 constexpr long double
1484 logb(long double __x)
1485 { return __builtin_logbl(__x); }
1487 template<typename _Tp>
1488 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1491 { return __builtin_logb(__x); }
1495 { return __builtin_lrintf(__x); }
1498 lrint(long double __x)
1499 { return __builtin_lrintl(__x); }
1501 template<typename _Tp>
1502 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1505 { return __builtin_lrint(__x); }
1509 { return __builtin_lroundf(__x); }
1512 lround(long double __x)
1513 { return __builtin_lroundl(__x); }
1515 template<typename _Tp>
1516 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1519 { return __builtin_lround(__x); }
1522 nearbyint(float __x)
1523 { return __builtin_nearbyintf(__x); }
1525 constexpr long double
1526 nearbyint(long double __x)
1527 { return __builtin_nearbyintl(__x); }
1529 template<typename _Tp>
1530 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1533 { return __builtin_nearbyint(__x); }
1536 nextafter(float __x, float __y)
1537 { return __builtin_nextafterf(__x, __y); }
1539 constexpr long double
1540 nextafter(long double __x, long double __y)
1541 { return __builtin_nextafterl(__x, __y); }
1543 template<typename _Tp, typename _Up>
1544 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1545 nextafter(_Tp __x, _Up __y)
1547 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1548 return nextafter(__type(__x), __type(__y));
1552 nexttoward(float __x, long double __y)
1553 { return __builtin_nexttowardf(__x, __y); }
1555 constexpr long double
1556 nexttoward(long double __x, long double __y)
1557 { return __builtin_nexttowardl(__x, __y); }
1559 template<typename _Tp>
1560 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1562 nexttoward(_Tp __x, long double __y)
1563 { return __builtin_nexttoward(__x, __y); }
1566 remainder(float __x, float __y)
1567 { return __builtin_remainderf(__x, __y); }
1569 constexpr long double
1570 remainder(long double __x, long double __y)
1571 { return __builtin_remainderl(__x, __y); }
1573 template<typename _Tp, typename _Up>
1574 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1575 remainder(_Tp __x, _Up __y)
1577 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1578 return remainder(__type(__x), __type(__y));
1582 remquo(float __x, float __y, int* __pquo)
1583 { return __builtin_remquof(__x, __y, __pquo); }
1586 remquo(long double __x, long double __y, int* __pquo)
1587 { return __builtin_remquol(__x, __y, __pquo); }
1589 template<typename _Tp, typename _Up>
1590 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1591 remquo(_Tp __x, _Up __y, int* __pquo)
1593 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1594 return remquo(__type(__x), __type(__y), __pquo);
1599 { return __builtin_rintf(__x); }
1601 constexpr long double
1602 rint(long double __x)
1603 { return __builtin_rintl(__x); }
1605 template<typename _Tp>
1606 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1609 { return __builtin_rint(__x); }
1613 { return __builtin_roundf(__x); }
1615 constexpr long double
1616 round(long double __x)
1617 { return __builtin_roundl(__x); }
1619 template<typename _Tp>
1620 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1623 { return __builtin_round(__x); }
1626 scalbln(float __x, long __ex)
1627 { return __builtin_scalblnf(__x, __ex); }
1629 constexpr long double
1630 scalbln(long double __x, long __ex)
1631 { return __builtin_scalblnl(__x, __ex); }
1633 template<typename _Tp>
1634 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1636 scalbln(_Tp __x, long __ex)
1637 { return __builtin_scalbln(__x, __ex); }
1640 scalbn(float __x, int __ex)
1641 { return __builtin_scalbnf(__x, __ex); }
1643 constexpr long double
1644 scalbn(long double __x, int __ex)
1645 { return __builtin_scalbnl(__x, __ex); }
1647 template<typename _Tp>
1648 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1650 scalbn(_Tp __x, int __ex)
1651 { return __builtin_scalbn(__x, __ex); }
1655 { return __builtin_tgammaf(__x); }
1657 constexpr long double
1658 tgamma(long double __x)
1659 { return __builtin_tgammal(__x); }
1661 template<typename _Tp>
1662 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1665 { return __builtin_tgamma(__x); }
1669 { return __builtin_truncf(__x); }
1671 constexpr long double
1672 trunc(long double __x)
1673 { return __builtin_truncl(__x); }
1675 template<typename _Tp>
1676 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1679 { return __builtin_trunc(__x); }
1681 _GLIBCXX_END_NAMESPACE_VERSION
1684 #endif // _GLIBCXX_USE_C99_MATH_TR1
1686 #endif // __GXX_EXPERIMENTAL_CXX0X__