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<
177 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
178 && __is_arithmetic<_Up>::__value,
179 _Tp>::__type, _Up>::__type
180 atan2(_Tp __y, _Up __x)
182 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
183 return atan2(__type(__y), __type(__x));
188 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
189 inline _GLIBCXX_CONSTEXPR float
191 { return __builtin_ceilf(__x); }
193 inline _GLIBCXX_CONSTEXPR long double
194 ceil(long double __x)
195 { return __builtin_ceill(__x); }
198 template<typename _Tp>
199 inline _GLIBCXX_CONSTEXPR
200 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
203 { return __builtin_ceil(__x); }
207 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
208 inline _GLIBCXX_CONSTEXPR float
210 { return __builtin_cosf(__x); }
212 inline _GLIBCXX_CONSTEXPR long double
214 { return __builtin_cosl(__x); }
217 template<typename _Tp>
218 inline _GLIBCXX_CONSTEXPR
219 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
222 { return __builtin_cos(__x); }
226 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
227 inline _GLIBCXX_CONSTEXPR float
229 { return __builtin_coshf(__x); }
231 inline _GLIBCXX_CONSTEXPR long double
232 cosh(long double __x)
233 { return __builtin_coshl(__x); }
236 template<typename _Tp>
237 inline _GLIBCXX_CONSTEXPR
238 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
241 { return __builtin_cosh(__x); }
245 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
246 inline _GLIBCXX_CONSTEXPR float
248 { return __builtin_expf(__x); }
250 inline _GLIBCXX_CONSTEXPR long double
252 { return __builtin_expl(__x); }
255 template<typename _Tp>
256 inline _GLIBCXX_CONSTEXPR
257 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
260 { return __builtin_exp(__x); }
264 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
265 inline _GLIBCXX_CONSTEXPR float
267 { return __builtin_fabsf(__x); }
269 inline _GLIBCXX_CONSTEXPR long double
270 fabs(long double __x)
271 { return __builtin_fabsl(__x); }
274 template<typename _Tp>
275 inline _GLIBCXX_CONSTEXPR
276 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
279 { return __builtin_fabs(__x); }
283 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
284 inline _GLIBCXX_CONSTEXPR float
286 { return __builtin_floorf(__x); }
288 inline _GLIBCXX_CONSTEXPR long double
289 floor(long double __x)
290 { return __builtin_floorl(__x); }
293 template<typename _Tp>
294 inline _GLIBCXX_CONSTEXPR
295 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
298 { return __builtin_floor(__x); }
302 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
303 inline _GLIBCXX_CONSTEXPR float
304 fmod(float __x, float __y)
305 { return __builtin_fmodf(__x, __y); }
307 inline _GLIBCXX_CONSTEXPR long double
308 fmod(long double __x, long double __y)
309 { return __builtin_fmodl(__x, __y); }
312 template<typename _Tp, typename _Up>
313 inline _GLIBCXX_CONSTEXPR
314 typename __gnu_cxx::__promote_2<
315 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
316 && __is_arithmetic<_Up>::__value,
317 _Tp>::__type, _Up>::__type
318 fmod(_Tp __x, _Up __y)
320 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
321 return fmod(__type(__x), __type(__y));
326 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
327 inline _GLIBCXX_CONSTEXPR float
328 frexp(float __x, int* __exp)
329 { return __builtin_frexpf(__x, __exp); }
331 inline _GLIBCXX_CONSTEXPR long double
332 frexp(long double __x, int* __exp)
333 { return __builtin_frexpl(__x, __exp); }
336 template<typename _Tp>
337 inline _GLIBCXX_CONSTEXPR
338 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
340 frexp(_Tp __x, int* __exp)
341 { return __builtin_frexp(__x, __exp); }
345 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
346 inline _GLIBCXX_CONSTEXPR float
347 ldexp(float __x, int __exp)
348 { return __builtin_ldexpf(__x, __exp); }
350 inline _GLIBCXX_CONSTEXPR long double
351 ldexp(long double __x, int __exp)
352 { return __builtin_ldexpl(__x, __exp); }
355 template<typename _Tp>
356 inline _GLIBCXX_CONSTEXPR
357 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
359 ldexp(_Tp __x, int __exp)
360 { return __builtin_ldexp(__x, __exp); }
364 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
365 inline _GLIBCXX_CONSTEXPR float
367 { return __builtin_logf(__x); }
369 inline _GLIBCXX_CONSTEXPR long double
371 { return __builtin_logl(__x); }
374 template<typename _Tp>
375 inline _GLIBCXX_CONSTEXPR
376 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
379 { return __builtin_log(__x); }
383 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
384 inline _GLIBCXX_CONSTEXPR float
386 { return __builtin_log10f(__x); }
388 inline _GLIBCXX_CONSTEXPR long double
389 log10(long double __x)
390 { return __builtin_log10l(__x); }
393 template<typename _Tp>
394 inline _GLIBCXX_CONSTEXPR
395 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
398 { return __builtin_log10(__x); }
402 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
403 inline _GLIBCXX_CONSTEXPR float
404 modf(float __x, float* __iptr)
405 { return __builtin_modff(__x, __iptr); }
407 inline _GLIBCXX_CONSTEXPR long double
408 modf(long double __x, long double* __iptr)
409 { return __builtin_modfl(__x, __iptr); }
414 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
415 inline _GLIBCXX_CONSTEXPR float
416 pow(float __x, float __y)
417 { return __builtin_powf(__x, __y); }
419 inline _GLIBCXX_CONSTEXPR long double
420 pow(long double __x, long double __y)
421 { return __builtin_powl(__x, __y); }
423 #ifndef __GXX_EXPERIMENTAL_CXX0X__
424 // _GLIBCXX_RESOLVE_LIB_DEFECTS
425 // DR 550. What should the return type of pow(float,int) be?
427 pow(double __x, int __i)
428 { return __builtin_powi(__x, __i); }
431 pow(float __x, int __n)
432 { return __builtin_powif(__x, __n); }
435 pow(long double __x, int __n)
436 { return __builtin_powil(__x, __n); }
440 template<typename _Tp, typename _Up>
441 inline _GLIBCXX_CONSTEXPR
442 typename __gnu_cxx::__promote_2<
443 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
444 && __is_arithmetic<_Up>::__value,
445 _Tp>::__type, _Up>::__type
446 pow(_Tp __x, _Up __y)
448 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
449 return pow(__type(__x), __type(__y));
454 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
455 inline _GLIBCXX_CONSTEXPR float
457 { return __builtin_sinf(__x); }
459 inline _GLIBCXX_CONSTEXPR long double
461 { return __builtin_sinl(__x); }
464 template<typename _Tp>
465 inline _GLIBCXX_CONSTEXPR
466 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
469 { return __builtin_sin(__x); }
473 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
474 inline _GLIBCXX_CONSTEXPR float
476 { return __builtin_sinhf(__x); }
478 inline _GLIBCXX_CONSTEXPR long double
479 sinh(long double __x)
480 { return __builtin_sinhl(__x); }
483 template<typename _Tp>
484 inline _GLIBCXX_CONSTEXPR
485 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
488 { return __builtin_sinh(__x); }
492 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
493 inline _GLIBCXX_CONSTEXPR float
495 { return __builtin_sqrtf(__x); }
497 inline _GLIBCXX_CONSTEXPR long double
498 sqrt(long double __x)
499 { return __builtin_sqrtl(__x); }
502 template<typename _Tp>
503 inline _GLIBCXX_CONSTEXPR
504 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
507 { return __builtin_sqrt(__x); }
511 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
512 inline _GLIBCXX_CONSTEXPR float
514 { return __builtin_tanf(__x); }
516 inline _GLIBCXX_CONSTEXPR long double
518 { return __builtin_tanl(__x); }
521 template<typename _Tp>
522 inline _GLIBCXX_CONSTEXPR
523 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
526 { return __builtin_tan(__x); }
530 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO1
531 inline _GLIBCXX_CONSTEXPR float
533 { return __builtin_tanhf(__x); }
535 inline _GLIBCXX_CONSTEXPR long double
536 tanh(long double __x)
537 { return __builtin_tanhl(__x); }
540 template<typename _Tp>
541 inline _GLIBCXX_CONSTEXPR
542 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
545 { return __builtin_tanh(__x); }
547 _GLIBCXX_END_NAMESPACE_VERSION
550 #if _GLIBCXX_USE_C99_MATH
551 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
553 // These are possible macros imported from C99-land.
561 #undef isgreaterequal
567 namespace std _GLIBCXX_VISIBILITY(default)
569 _GLIBCXX_BEGIN_NAMESPACE_VERSION
571 #ifdef __GXX_EXPERIMENTAL_CXX0X__
573 fpclassify(float __x)
574 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
575 FP_SUBNORMAL, FP_ZERO, __x); }
578 fpclassify(double __x)
579 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
580 FP_SUBNORMAL, FP_ZERO, __x); }
583 fpclassify(long double __x)
584 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
585 FP_SUBNORMAL, FP_ZERO, __x); }
587 template<typename _Tp>
588 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
591 { return __x != 0 ? FP_NORMAL : FP_ZERO; }
595 { return __builtin_isfinite(__x); }
599 { return __builtin_isfinite(__x); }
602 isfinite(long double __x)
603 { return __builtin_isfinite(__x); }
605 template<typename _Tp>
606 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
613 { return __builtin_isinf(__x); }
617 { return __builtin_isinf(__x); }
620 isinf(long double __x)
621 { return __builtin_isinf(__x); }
623 template<typename _Tp>
624 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
631 { return __builtin_isnan(__x); }
635 { return __builtin_isnan(__x); }
638 isnan(long double __x)
639 { return __builtin_isnan(__x); }
641 template<typename _Tp>
642 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
649 { return __builtin_isnormal(__x); }
653 { return __builtin_isnormal(__x); }
656 isnormal(long double __x)
657 { return __builtin_isnormal(__x); }
659 template<typename _Tp>
660 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
663 { return __x != 0 ? true : false; }
667 { return __builtin_signbit(__x); }
671 { return __builtin_signbit(__x); }
674 signbit(long double __x)
675 { return __builtin_signbit(__x); }
677 template<typename _Tp>
678 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
681 { return __x < 0 ? true : false; }
684 isgreater(float __x, float __y)
685 { return __builtin_isgreater(__x, __y); }
688 isgreater(double __x, double __y)
689 { return __builtin_isgreater(__x, __y); }
692 isgreater(long double __x, long double __y)
693 { return __builtin_isgreater(__x, __y); }
695 template<typename _Tp, typename _Up>
697 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
698 && __is_arithmetic<_Up>::__value), bool>::__type
699 isgreater(_Tp __x, _Up __y)
701 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
702 return __builtin_isgreater(__type(__x), __type(__y));
706 isgreaterequal(float __x, float __y)
707 { return __builtin_isgreaterequal(__x, __y); }
710 isgreaterequal(double __x, double __y)
711 { return __builtin_isgreaterequal(__x, __y); }
714 isgreaterequal(long double __x, long double __y)
715 { return __builtin_isgreaterequal(__x, __y); }
717 template<typename _Tp, typename _Up>
719 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
720 && __is_arithmetic<_Up>::__value), bool>::__type
721 isgreaterequal(_Tp __x, _Up __y)
723 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
724 return __builtin_isgreaterequal(__type(__x), __type(__y));
728 isless(float __x, float __y)
729 { return __builtin_isless(__x, __y); }
732 isless(double __x, double __y)
733 { return __builtin_isless(__x, __y); }
736 isless(long double __x, long double __y)
737 { return __builtin_isless(__x, __y); }
739 template<typename _Tp, typename _Up>
741 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
742 && __is_arithmetic<_Up>::__value), bool>::__type
743 isless(_Tp __x, _Up __y)
745 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
746 return __builtin_isless(__type(__x), __type(__y));
750 islessequal(float __x, float __y)
751 { return __builtin_islessequal(__x, __y); }
754 islessequal(double __x, double __y)
755 { return __builtin_islessequal(__x, __y); }
758 islessequal(long double __x, long double __y)
759 { return __builtin_islessequal(__x, __y); }
761 template<typename _Tp, typename _Up>
763 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
764 && __is_arithmetic<_Up>::__value), bool>::__type
765 islessequal(_Tp __x, _Up __y)
767 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
768 return __builtin_islessequal(__type(__x), __type(__y));
772 islessgreater(float __x, float __y)
773 { return __builtin_islessgreater(__x, __y); }
776 islessgreater(double __x, double __y)
777 { return __builtin_islessgreater(__x, __y); }
780 islessgreater(long double __x, long double __y)
781 { return __builtin_islessgreater(__x, __y); }
783 template<typename _Tp, typename _Up>
785 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
786 && __is_arithmetic<_Up>::__value), bool>::__type
787 islessgreater(_Tp __x, _Up __y)
789 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
790 return __builtin_islessgreater(__type(__x), __type(__y));
794 isunordered(float __x, float __y)
795 { return __builtin_isunordered(__x, __y); }
798 isunordered(double __x, double __y)
799 { return __builtin_isunordered(__x, __y); }
802 isunordered(long double __x, long double __y)
803 { return __builtin_isunordered(__x, __y); }
805 template<typename _Tp, typename _Up>
807 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
808 && __is_arithmetic<_Up>::__value), bool>::__type
809 isunordered(_Tp __x, _Up __y)
811 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
812 return __builtin_isunordered(__type(__x), __type(__y));
817 template<typename _Tp>
818 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
822 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
823 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
824 FP_SUBNORMAL, FP_ZERO, __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_isfinite(__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_isinf(__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_isnan(__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_isnormal(__type(__f));
863 template<typename _Tp>
864 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
868 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
869 return __builtin_signbit(__type(__f));
872 template<typename _Tp>
873 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
875 isgreater(_Tp __f1, _Tp __f2)
877 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
878 return __builtin_isgreater(__type(__f1), __type(__f2));
881 template<typename _Tp>
882 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
884 isgreaterequal(_Tp __f1, _Tp __f2)
886 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
887 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
890 template<typename _Tp>
891 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
893 isless(_Tp __f1, _Tp __f2)
895 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
896 return __builtin_isless(__type(__f1), __type(__f2));
899 template<typename _Tp>
900 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
902 islessequal(_Tp __f1, _Tp __f2)
904 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
905 return __builtin_islessequal(__type(__f1), __type(__f2));
908 template<typename _Tp>
909 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
911 islessgreater(_Tp __f1, _Tp __f2)
913 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
914 return __builtin_islessgreater(__type(__f1), __type(__f2));
917 template<typename _Tp>
918 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
920 isunordered(_Tp __f1, _Tp __f2)
922 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
923 return __builtin_isunordered(__type(__f1), __type(__f2));
928 _GLIBCXX_END_NAMESPACE_VERSION
931 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
934 #ifdef __GXX_EXPERIMENTAL_CXX0X__
936 #ifdef _GLIBCXX_USE_C99_MATH_TR1
1044 namespace std _GLIBCXX_VISIBILITY(default)
1046 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1158 using ::nexttowardf;
1159 using ::nexttowardl;
1193 /// Additional overloads.
1196 { return __builtin_acoshf(__x); }
1198 constexpr long double
1199 acosh(long double __x)
1200 { return __builtin_acoshl(__x); }
1202 template<typename _Tp>
1203 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1206 { return __builtin_acosh(__x); }
1210 { return __builtin_asinhf(__x); }
1212 constexpr long double
1213 asinh(long double __x)
1214 { return __builtin_asinhl(__x); }
1216 template<typename _Tp>
1217 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1220 { return __builtin_asinh(__x); }
1224 { return __builtin_atanhf(__x); }
1226 constexpr long double
1227 atanh(long double __x)
1228 { return __builtin_atanhl(__x); }
1230 template<typename _Tp>
1231 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1234 { return __builtin_atanh(__x); }
1238 { return __builtin_cbrtf(__x); }
1240 constexpr long double
1241 cbrt(long double __x)
1242 { return __builtin_cbrtl(__x); }
1244 template<typename _Tp>
1245 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1248 { return __builtin_cbrt(__x); }
1251 copysign(float __x, float __y)
1252 { return __builtin_copysignf(__x, __y); }
1254 constexpr long double
1255 copysign(long double __x, long double __y)
1256 { return __builtin_copysignl(__x, __y); }
1258 template<typename _Tp, typename _Up>
1260 typename __gnu_cxx::__promote_2<
1261 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1262 && __is_arithmetic<_Up>::__value,
1263 _Tp>::__type, _Up>::__type
1264 copysign(_Tp __x, _Up __y)
1266 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1267 return copysign(__type(__x), __type(__y));
1272 { return __builtin_erff(__x); }
1274 constexpr long double
1275 erf(long double __x)
1276 { return __builtin_erfl(__x); }
1278 template<typename _Tp>
1279 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1282 { return __builtin_erf(__x); }
1286 { return __builtin_erfcf(__x); }
1288 constexpr long double
1289 erfc(long double __x)
1290 { return __builtin_erfcl(__x); }
1292 template<typename _Tp>
1293 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1296 { return __builtin_erfc(__x); }
1300 { return __builtin_exp2f(__x); }
1302 constexpr long double
1303 exp2(long double __x)
1304 { return __builtin_exp2l(__x); }
1306 template<typename _Tp>
1307 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1310 { return __builtin_exp2(__x); }
1314 { return __builtin_expm1f(__x); }
1316 constexpr long double
1317 expm1(long double __x)
1318 { return __builtin_expm1l(__x); }
1320 template<typename _Tp>
1321 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1324 { return __builtin_expm1(__x); }
1327 fdim(float __x, float __y)
1328 { return __builtin_fdimf(__x, __y); }
1330 constexpr long double
1331 fdim(long double __x, long double __y)
1332 { return __builtin_fdiml(__x, __y); }
1334 template<typename _Tp, typename _Up>
1336 typename __gnu_cxx::__promote_2<
1337 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1338 && __is_arithmetic<_Up>::__value,
1339 _Tp>::__type, _Up>::__type
1340 fdim(_Tp __x, _Up __y)
1342 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1343 return fdim(__type(__x), __type(__y));
1347 fma(float __x, float __y, float __z)
1348 { return __builtin_fmaf(__x, __y, __z); }
1350 constexpr long double
1351 fma(long double __x, long double __y, long double __z)
1352 { return __builtin_fmal(__x, __y, __z); }
1354 template<typename _Tp, typename _Up, typename _Vp>
1356 typename __gnu_cxx::__promote_3<
1357 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1358 && __is_arithmetic<_Up>::__value
1359 && __is_arithmetic<_Vp>::__value,
1360 _Tp>::__type, _Up, _Vp>::__type
1361 fma(_Tp __x, _Up __y, _Vp __z)
1363 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
1364 return fma(__type(__x), __type(__y), __type(__z));
1368 fmax(float __x, float __y)
1369 { return __builtin_fmaxf(__x, __y); }
1371 constexpr long double
1372 fmax(long double __x, long double __y)
1373 { return __builtin_fmaxl(__x, __y); }
1375 template<typename _Tp, typename _Up>
1377 typename __gnu_cxx::__promote_2<
1378 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1379 && __is_arithmetic<_Up>::__value,
1380 _Tp>::__type, _Up>::__type
1381 fmax(_Tp __x, _Up __y)
1383 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1384 return fmax(__type(__x), __type(__y));
1388 fmin(float __x, float __y)
1389 { return __builtin_fminf(__x, __y); }
1391 constexpr long double
1392 fmin(long double __x, long double __y)
1393 { return __builtin_fminl(__x, __y); }
1395 template<typename _Tp, typename _Up>
1397 typename __gnu_cxx::__promote_2<
1398 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1399 && __is_arithmetic<_Up>::__value,
1400 _Tp>::__type, _Up>::__type
1401 fmin(_Tp __x, _Up __y)
1403 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1404 return fmin(__type(__x), __type(__y));
1408 hypot(float __x, float __y)
1409 { return __builtin_hypotf(__x, __y); }
1411 constexpr long double
1412 hypot(long double __x, long double __y)
1413 { return __builtin_hypotl(__x, __y); }
1415 template<typename _Tp, typename _Up>
1417 typename __gnu_cxx::__promote_2<
1418 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1419 && __is_arithmetic<_Up>::__value,
1420 _Tp>::__type, _Up>::__type
1421 hypot(_Tp __x, _Up __y)
1423 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1424 return hypot(__type(__x), __type(__y));
1429 { return __builtin_ilogbf(__x); }
1432 ilogb(long double __x)
1433 { return __builtin_ilogbl(__x); }
1435 template<typename _Tp>
1437 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1440 { return __builtin_ilogb(__x); }
1444 { return __builtin_lgammaf(__x); }
1446 constexpr long double
1447 lgamma(long double __x)
1448 { return __builtin_lgammal(__x); }
1450 template<typename _Tp>
1451 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1454 { return __builtin_lgamma(__x); }
1458 { return __builtin_llrintf(__x); }
1461 llrint(long double __x)
1462 { return __builtin_llrintl(__x); }
1464 template<typename _Tp>
1465 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1468 { return __builtin_llrint(__x); }
1472 { return __builtin_llroundf(__x); }
1475 llround(long double __x)
1476 { return __builtin_llroundl(__x); }
1478 template<typename _Tp>
1479 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1482 { return __builtin_llround(__x); }
1486 { return __builtin_log1pf(__x); }
1488 constexpr long double
1489 log1p(long double __x)
1490 { return __builtin_log1pl(__x); }
1492 template<typename _Tp>
1493 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1496 { return __builtin_log1p(__x); }
1501 { return __builtin_log2f(__x); }
1503 constexpr long double
1504 log2(long double __x)
1505 { return __builtin_log2l(__x); }
1507 template<typename _Tp>
1508 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1511 { return __builtin_log2(__x); }
1515 { return __builtin_logbf(__x); }
1517 constexpr long double
1518 logb(long double __x)
1519 { return __builtin_logbl(__x); }
1521 template<typename _Tp>
1522 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1525 { return __builtin_logb(__x); }
1529 { return __builtin_lrintf(__x); }
1532 lrint(long double __x)
1533 { return __builtin_lrintl(__x); }
1535 template<typename _Tp>
1536 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1539 { return __builtin_lrint(__x); }
1543 { return __builtin_lroundf(__x); }
1546 lround(long double __x)
1547 { return __builtin_lroundl(__x); }
1549 template<typename _Tp>
1550 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1553 { return __builtin_lround(__x); }
1556 nearbyint(float __x)
1557 { return __builtin_nearbyintf(__x); }
1559 constexpr long double
1560 nearbyint(long double __x)
1561 { return __builtin_nearbyintl(__x); }
1563 template<typename _Tp>
1564 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1567 { return __builtin_nearbyint(__x); }
1570 nextafter(float __x, float __y)
1571 { return __builtin_nextafterf(__x, __y); }
1573 constexpr long double
1574 nextafter(long double __x, long double __y)
1575 { return __builtin_nextafterl(__x, __y); }
1577 template<typename _Tp, typename _Up>
1579 typename __gnu_cxx::__promote_2<
1580 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1581 && __is_arithmetic<_Up>::__value,
1582 _Tp>::__type, _Up>::__type
1583 nextafter(_Tp __x, _Up __y)
1585 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1586 return nextafter(__type(__x), __type(__y));
1590 nexttoward(float __x, long double __y)
1591 { return __builtin_nexttowardf(__x, __y); }
1593 constexpr long double
1594 nexttoward(long double __x, long double __y)
1595 { return __builtin_nexttowardl(__x, __y); }
1597 template<typename _Tp>
1598 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1600 nexttoward(_Tp __x, long double __y)
1601 { return __builtin_nexttoward(__x, __y); }
1604 remainder(float __x, float __y)
1605 { return __builtin_remainderf(__x, __y); }
1607 constexpr long double
1608 remainder(long double __x, long double __y)
1609 { return __builtin_remainderl(__x, __y); }
1611 template<typename _Tp, typename _Up>
1613 typename __gnu_cxx::__promote_2<
1614 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1615 && __is_arithmetic<_Up>::__value,
1616 _Tp>::__type, _Up>::__type
1617 remainder(_Tp __x, _Up __y)
1619 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1620 return remainder(__type(__x), __type(__y));
1624 remquo(float __x, float __y, int* __pquo)
1625 { return __builtin_remquof(__x, __y, __pquo); }
1627 constexpr long double
1628 remquo(long double __x, long double __y, int* __pquo)
1629 { return __builtin_remquol(__x, __y, __pquo); }
1631 template<typename _Tp, typename _Up>
1633 typename __gnu_cxx::__promote_2<
1634 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1635 && __is_arithmetic<_Up>::__value,
1636 _Tp>::__type, _Up>::__type
1637 remquo(_Tp __x, _Up __y, int* __pquo)
1639 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1640 return remquo(__type(__x), __type(__y), __pquo);
1645 { return __builtin_rintf(__x); }
1647 constexpr long double
1648 rint(long double __x)
1649 { return __builtin_rintl(__x); }
1651 template<typename _Tp>
1652 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1655 { return __builtin_rint(__x); }
1659 { return __builtin_roundf(__x); }
1661 constexpr long double
1662 round(long double __x)
1663 { return __builtin_roundl(__x); }
1665 template<typename _Tp>
1666 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1669 { return __builtin_round(__x); }
1672 scalbln(float __x, long __ex)
1673 { return __builtin_scalblnf(__x, __ex); }
1675 constexpr long double
1676 scalbln(long double __x, long __ex)
1677 { return __builtin_scalblnl(__x, __ex); }
1679 template<typename _Tp>
1680 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1682 scalbln(_Tp __x, long __ex)
1683 { return __builtin_scalbln(__x, __ex); }
1686 scalbn(float __x, int __ex)
1687 { return __builtin_scalbnf(__x, __ex); }
1689 constexpr long double
1690 scalbn(long double __x, int __ex)
1691 { return __builtin_scalbnl(__x, __ex); }
1693 template<typename _Tp>
1694 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1696 scalbn(_Tp __x, int __ex)
1697 { return __builtin_scalbn(__x, __ex); }
1701 { return __builtin_tgammaf(__x); }
1703 constexpr long double
1704 tgamma(long double __x)
1705 { return __builtin_tgammal(__x); }
1707 template<typename _Tp>
1708 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1711 { return __builtin_tgamma(__x); }
1715 { return __builtin_truncf(__x); }
1717 constexpr long double
1718 trunc(long double __x)
1719 { return __builtin_truncl(__x); }
1721 template<typename _Tp>
1722 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1725 { return __builtin_trunc(__x); }
1727 _GLIBCXX_END_NAMESPACE_VERSION
1730 #endif // _GLIBCXX_USE_C99_MATH_TR1
1732 #endif // __GXX_EXPERIMENTAL_CXX0X__