1 // -*- C++ -*- C forwarding header.
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007, 2008, 2009, 2010, 2011, 2012
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 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
82 inline _GLIBCXX_CONSTEXPR double
84 { return __builtin_fabs(__x); }
87 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
88 inline _GLIBCXX_CONSTEXPR float
90 { return __builtin_fabsf(__x); }
92 inline _GLIBCXX_CONSTEXPR long double
94 { return __builtin_fabsl(__x); }
97 template<typename _Tp>
98 inline _GLIBCXX_CONSTEXPR
99 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
102 { return __builtin_fabs(__x); }
106 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
107 inline _GLIBCXX_CONSTEXPR float
109 { return __builtin_acosf(__x); }
111 inline _GLIBCXX_CONSTEXPR long double
112 acos(long double __x)
113 { return __builtin_acosl(__x); }
116 template<typename _Tp>
117 inline _GLIBCXX_CONSTEXPR
118 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
121 { return __builtin_acos(__x); }
125 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
126 inline _GLIBCXX_CONSTEXPR float
128 { return __builtin_asinf(__x); }
130 inline _GLIBCXX_CONSTEXPR long double
131 asin(long double __x)
132 { return __builtin_asinl(__x); }
135 template<typename _Tp>
136 inline _GLIBCXX_CONSTEXPR
137 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
140 { return __builtin_asin(__x); }
144 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
145 inline _GLIBCXX_CONSTEXPR float
147 { return __builtin_atanf(__x); }
149 inline _GLIBCXX_CONSTEXPR long double
150 atan(long double __x)
151 { return __builtin_atanl(__x); }
154 template<typename _Tp>
155 inline _GLIBCXX_CONSTEXPR
156 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
159 { return __builtin_atan(__x); }
163 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
164 inline _GLIBCXX_CONSTEXPR float
165 atan2(float __y, float __x)
166 { return __builtin_atan2f(__y, __x); }
168 inline _GLIBCXX_CONSTEXPR long double
169 atan2(long double __y, long double __x)
170 { return __builtin_atan2l(__y, __x); }
173 template<typename _Tp, typename _Up>
174 inline _GLIBCXX_CONSTEXPR
175 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
176 atan2(_Tp __y, _Up __x)
178 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
179 return atan2(__type(__y), __type(__x));
184 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
185 inline _GLIBCXX_CONSTEXPR float
187 { return __builtin_ceilf(__x); }
189 inline _GLIBCXX_CONSTEXPR long double
190 ceil(long double __x)
191 { return __builtin_ceill(__x); }
194 template<typename _Tp>
195 inline _GLIBCXX_CONSTEXPR
196 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
199 { return __builtin_ceil(__x); }
203 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
204 inline _GLIBCXX_CONSTEXPR float
206 { return __builtin_cosf(__x); }
208 inline _GLIBCXX_CONSTEXPR long double
210 { return __builtin_cosl(__x); }
213 template<typename _Tp>
214 inline _GLIBCXX_CONSTEXPR
215 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
218 { return __builtin_cos(__x); }
222 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
223 inline _GLIBCXX_CONSTEXPR float
225 { return __builtin_coshf(__x); }
227 inline _GLIBCXX_CONSTEXPR long double
228 cosh(long double __x)
229 { return __builtin_coshl(__x); }
232 template<typename _Tp>
233 inline _GLIBCXX_CONSTEXPR
234 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
237 { return __builtin_cosh(__x); }
241 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
242 inline _GLIBCXX_CONSTEXPR float
244 { return __builtin_expf(__x); }
246 inline _GLIBCXX_CONSTEXPR long double
248 { return __builtin_expl(__x); }
251 template<typename _Tp>
252 inline _GLIBCXX_CONSTEXPR
253 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
256 { return __builtin_exp(__x); }
260 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
261 inline _GLIBCXX_CONSTEXPR float
263 { return __builtin_fabsf(__x); }
265 inline _GLIBCXX_CONSTEXPR long double
266 fabs(long double __x)
267 { return __builtin_fabsl(__x); }
270 template<typename _Tp>
271 inline _GLIBCXX_CONSTEXPR
272 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
275 { return __builtin_fabs(__x); }
279 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
280 inline _GLIBCXX_CONSTEXPR float
282 { return __builtin_floorf(__x); }
284 inline _GLIBCXX_CONSTEXPR long double
285 floor(long double __x)
286 { return __builtin_floorl(__x); }
289 template<typename _Tp>
290 inline _GLIBCXX_CONSTEXPR
291 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
294 { return __builtin_floor(__x); }
298 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
299 inline _GLIBCXX_CONSTEXPR float
300 fmod(float __x, float __y)
301 { return __builtin_fmodf(__x, __y); }
303 inline _GLIBCXX_CONSTEXPR long double
304 fmod(long double __x, long double __y)
305 { return __builtin_fmodl(__x, __y); }
308 template<typename _Tp, typename _Up>
309 inline _GLIBCXX_CONSTEXPR
310 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
311 fmod(_Tp __x, _Up __y)
313 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
314 return fmod(__type(__x), __type(__y));
319 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
321 frexp(float __x, int* __exp)
322 { return __builtin_frexpf(__x, __exp); }
325 frexp(long double __x, int* __exp)
326 { return __builtin_frexpl(__x, __exp); }
329 template<typename _Tp>
330 inline _GLIBCXX_CONSTEXPR
331 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
333 frexp(_Tp __x, int* __exp)
334 { return __builtin_frexp(__x, __exp); }
338 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
339 inline _GLIBCXX_CONSTEXPR float
340 ldexp(float __x, int __exp)
341 { return __builtin_ldexpf(__x, __exp); }
343 inline _GLIBCXX_CONSTEXPR long double
344 ldexp(long double __x, int __exp)
345 { return __builtin_ldexpl(__x, __exp); }
348 template<typename _Tp>
349 inline _GLIBCXX_CONSTEXPR
350 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
352 ldexp(_Tp __x, int __exp)
353 { return __builtin_ldexp(__x, __exp); }
357 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
358 inline _GLIBCXX_CONSTEXPR float
360 { return __builtin_logf(__x); }
362 inline _GLIBCXX_CONSTEXPR long double
364 { return __builtin_logl(__x); }
367 template<typename _Tp>
368 inline _GLIBCXX_CONSTEXPR
369 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
372 { return __builtin_log(__x); }
376 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
377 inline _GLIBCXX_CONSTEXPR float
379 { return __builtin_log10f(__x); }
381 inline _GLIBCXX_CONSTEXPR long double
382 log10(long double __x)
383 { return __builtin_log10l(__x); }
386 template<typename _Tp>
387 inline _GLIBCXX_CONSTEXPR
388 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
391 { return __builtin_log10(__x); }
395 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
397 modf(float __x, float* __iptr)
398 { return __builtin_modff(__x, __iptr); }
401 modf(long double __x, long double* __iptr)
402 { return __builtin_modfl(__x, __iptr); }
407 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
408 inline _GLIBCXX_CONSTEXPR float
409 pow(float __x, float __y)
410 { return __builtin_powf(__x, __y); }
412 inline _GLIBCXX_CONSTEXPR long double
413 pow(long double __x, long double __y)
414 { return __builtin_powl(__x, __y); }
416 #ifndef __GXX_EXPERIMENTAL_CXX0X__
417 // _GLIBCXX_RESOLVE_LIB_DEFECTS
418 // DR 550. What should the return type of pow(float,int) be?
420 pow(double __x, int __i)
421 { return __builtin_powi(__x, __i); }
424 pow(float __x, int __n)
425 { return __builtin_powif(__x, __n); }
428 pow(long double __x, int __n)
429 { return __builtin_powil(__x, __n); }
433 template<typename _Tp, typename _Up>
434 inline _GLIBCXX_CONSTEXPR
435 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
436 pow(_Tp __x, _Up __y)
438 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
439 return pow(__type(__x), __type(__y));
444 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
445 inline _GLIBCXX_CONSTEXPR float
447 { return __builtin_sinf(__x); }
449 inline _GLIBCXX_CONSTEXPR long double
451 { return __builtin_sinl(__x); }
454 template<typename _Tp>
455 inline _GLIBCXX_CONSTEXPR
456 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
459 { return __builtin_sin(__x); }
463 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
464 inline _GLIBCXX_CONSTEXPR float
466 { return __builtin_sinhf(__x); }
468 inline _GLIBCXX_CONSTEXPR long double
469 sinh(long double __x)
470 { return __builtin_sinhl(__x); }
473 template<typename _Tp>
474 inline _GLIBCXX_CONSTEXPR
475 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
478 { return __builtin_sinh(__x); }
482 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
483 inline _GLIBCXX_CONSTEXPR float
485 { return __builtin_sqrtf(__x); }
487 inline _GLIBCXX_CONSTEXPR long double
488 sqrt(long double __x)
489 { return __builtin_sqrtl(__x); }
492 template<typename _Tp>
493 inline _GLIBCXX_CONSTEXPR
494 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
497 { return __builtin_sqrt(__x); }
501 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
502 inline _GLIBCXX_CONSTEXPR float
504 { return __builtin_tanf(__x); }
506 inline _GLIBCXX_CONSTEXPR long double
508 { return __builtin_tanl(__x); }
511 template<typename _Tp>
512 inline _GLIBCXX_CONSTEXPR
513 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
516 { return __builtin_tan(__x); }
520 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
521 inline _GLIBCXX_CONSTEXPR float
523 { return __builtin_tanhf(__x); }
525 inline _GLIBCXX_CONSTEXPR long double
526 tanh(long double __x)
527 { return __builtin_tanhl(__x); }
530 template<typename _Tp>
531 inline _GLIBCXX_CONSTEXPR
532 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
535 { return __builtin_tanh(__x); }
537 _GLIBCXX_END_NAMESPACE_VERSION
540 #if _GLIBCXX_USE_C99_MATH
541 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
543 // These are possible macros imported from C99-land.
551 #undef isgreaterequal
557 namespace std _GLIBCXX_VISIBILITY(default)
559 _GLIBCXX_BEGIN_NAMESPACE_VERSION
561 #ifdef __GXX_EXPERIMENTAL_CXX0X__
563 fpclassify(float __x)
564 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
565 FP_SUBNORMAL, FP_ZERO, __x); }
568 fpclassify(double __x)
569 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
570 FP_SUBNORMAL, FP_ZERO, __x); }
573 fpclassify(long double __x)
574 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
575 FP_SUBNORMAL, FP_ZERO, __x); }
577 template<typename _Tp>
578 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
581 { return __x != 0 ? FP_NORMAL : FP_ZERO; }
585 { return __builtin_isfinite(__x); }
589 { return __builtin_isfinite(__x); }
592 isfinite(long double __x)
593 { return __builtin_isfinite(__x); }
595 template<typename _Tp>
596 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
603 { return __builtin_isinf(__x); }
607 { return __builtin_isinf(__x); }
610 isinf(long double __x)
611 { return __builtin_isinf(__x); }
613 template<typename _Tp>
614 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
621 { return __builtin_isnan(__x); }
625 { return __builtin_isnan(__x); }
628 isnan(long double __x)
629 { return __builtin_isnan(__x); }
631 template<typename _Tp>
632 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
639 { return __builtin_isnormal(__x); }
643 { return __builtin_isnormal(__x); }
646 isnormal(long double __x)
647 { return __builtin_isnormal(__x); }
649 template<typename _Tp>
650 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
653 { return __x != 0 ? true : false; }
657 { return __builtin_signbit(__x); }
661 { return __builtin_signbit(__x); }
664 signbit(long double __x)
665 { return __builtin_signbit(__x); }
667 template<typename _Tp>
668 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
671 { return __x < 0 ? true : false; }
674 isgreater(float __x, float __y)
675 { return __builtin_isgreater(__x, __y); }
678 isgreater(double __x, double __y)
679 { return __builtin_isgreater(__x, __y); }
682 isgreater(long double __x, long double __y)
683 { return __builtin_isgreater(__x, __y); }
685 template<typename _Tp, typename _Up>
687 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
688 && __is_arithmetic<_Up>::__value), bool>::__type
689 isgreater(_Tp __x, _Up __y)
691 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
692 return __builtin_isgreater(__type(__x), __type(__y));
696 isgreaterequal(float __x, float __y)
697 { return __builtin_isgreaterequal(__x, __y); }
700 isgreaterequal(double __x, double __y)
701 { return __builtin_isgreaterequal(__x, __y); }
704 isgreaterequal(long double __x, long double __y)
705 { return __builtin_isgreaterequal(__x, __y); }
707 template<typename _Tp, typename _Up>
709 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
710 && __is_arithmetic<_Up>::__value), bool>::__type
711 isgreaterequal(_Tp __x, _Up __y)
713 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
714 return __builtin_isgreaterequal(__type(__x), __type(__y));
718 isless(float __x, float __y)
719 { return __builtin_isless(__x, __y); }
722 isless(double __x, double __y)
723 { return __builtin_isless(__x, __y); }
726 isless(long double __x, long double __y)
727 { return __builtin_isless(__x, __y); }
729 template<typename _Tp, typename _Up>
731 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
732 && __is_arithmetic<_Up>::__value), bool>::__type
733 isless(_Tp __x, _Up __y)
735 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
736 return __builtin_isless(__type(__x), __type(__y));
740 islessequal(float __x, float __y)
741 { return __builtin_islessequal(__x, __y); }
744 islessequal(double __x, double __y)
745 { return __builtin_islessequal(__x, __y); }
748 islessequal(long double __x, long double __y)
749 { return __builtin_islessequal(__x, __y); }
751 template<typename _Tp, typename _Up>
753 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
754 && __is_arithmetic<_Up>::__value), bool>::__type
755 islessequal(_Tp __x, _Up __y)
757 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
758 return __builtin_islessequal(__type(__x), __type(__y));
762 islessgreater(float __x, float __y)
763 { return __builtin_islessgreater(__x, __y); }
766 islessgreater(double __x, double __y)
767 { return __builtin_islessgreater(__x, __y); }
770 islessgreater(long double __x, long double __y)
771 { return __builtin_islessgreater(__x, __y); }
773 template<typename _Tp, typename _Up>
775 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
776 && __is_arithmetic<_Up>::__value), bool>::__type
777 islessgreater(_Tp __x, _Up __y)
779 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
780 return __builtin_islessgreater(__type(__x), __type(__y));
784 isunordered(float __x, float __y)
785 { return __builtin_isunordered(__x, __y); }
788 isunordered(double __x, double __y)
789 { return __builtin_isunordered(__x, __y); }
792 isunordered(long double __x, long double __y)
793 { return __builtin_isunordered(__x, __y); }
795 template<typename _Tp, typename _Up>
797 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
798 && __is_arithmetic<_Up>::__value), bool>::__type
799 isunordered(_Tp __x, _Up __y)
801 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
802 return __builtin_isunordered(__type(__x), __type(__y));
807 template<typename _Tp>
808 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
812 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
813 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
814 FP_SUBNORMAL, FP_ZERO, __type(__f));
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_isfinite(__type(__f));
826 template<typename _Tp>
827 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
831 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
832 return __builtin_isinf(__type(__f));
835 template<typename _Tp>
836 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
840 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
841 return __builtin_isnan(__type(__f));
844 template<typename _Tp>
845 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
849 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
850 return __builtin_isnormal(__type(__f));
853 template<typename _Tp>
854 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
858 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
859 return __builtin_signbit(__type(__f));
862 template<typename _Tp>
863 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
865 isgreater(_Tp __f1, _Tp __f2)
867 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
868 return __builtin_isgreater(__type(__f1), __type(__f2));
871 template<typename _Tp>
872 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
874 isgreaterequal(_Tp __f1, _Tp __f2)
876 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
877 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
880 template<typename _Tp>
881 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
883 isless(_Tp __f1, _Tp __f2)
885 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
886 return __builtin_isless(__type(__f1), __type(__f2));
889 template<typename _Tp>
890 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
892 islessequal(_Tp __f1, _Tp __f2)
894 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
895 return __builtin_islessequal(__type(__f1), __type(__f2));
898 template<typename _Tp>
899 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
901 islessgreater(_Tp __f1, _Tp __f2)
903 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
904 return __builtin_islessgreater(__type(__f1), __type(__f2));
907 template<typename _Tp>
908 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
910 isunordered(_Tp __f1, _Tp __f2)
912 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
913 return __builtin_isunordered(__type(__f1), __type(__f2));
918 _GLIBCXX_END_NAMESPACE_VERSION
921 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
924 #ifdef __GXX_EXPERIMENTAL_CXX0X__
926 #ifdef _GLIBCXX_USE_C99_MATH_TR1
1034 namespace std _GLIBCXX_VISIBILITY(default)
1036 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1148 using ::nexttowardf;
1149 using ::nexttowardl;
1183 /// Additional overloads.
1186 { return __builtin_acoshf(__x); }
1188 constexpr long double
1189 acosh(long double __x)
1190 { return __builtin_acoshl(__x); }
1192 template<typename _Tp>
1193 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1196 { return __builtin_acosh(__x); }
1200 { return __builtin_asinhf(__x); }
1202 constexpr long double
1203 asinh(long double __x)
1204 { return __builtin_asinhl(__x); }
1206 template<typename _Tp>
1207 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1210 { return __builtin_asinh(__x); }
1214 { return __builtin_atanhf(__x); }
1216 constexpr long double
1217 atanh(long double __x)
1218 { return __builtin_atanhl(__x); }
1220 template<typename _Tp>
1221 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1224 { return __builtin_atanh(__x); }
1228 { return __builtin_cbrtf(__x); }
1230 constexpr long double
1231 cbrt(long double __x)
1232 { return __builtin_cbrtl(__x); }
1234 template<typename _Tp>
1235 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1238 { return __builtin_cbrt(__x); }
1241 copysign(float __x, float __y)
1242 { return __builtin_copysignf(__x, __y); }
1244 constexpr long double
1245 copysign(long double __x, long double __y)
1246 { return __builtin_copysignl(__x, __y); }
1248 template<typename _Tp, typename _Up>
1249 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1250 copysign(_Tp __x, _Up __y)
1252 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1253 return copysign(__type(__x), __type(__y));
1258 { return __builtin_erff(__x); }
1260 constexpr long double
1261 erf(long double __x)
1262 { return __builtin_erfl(__x); }
1264 template<typename _Tp>
1265 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1268 { return __builtin_erf(__x); }
1272 { return __builtin_erfcf(__x); }
1274 constexpr long double
1275 erfc(long double __x)
1276 { return __builtin_erfcl(__x); }
1278 template<typename _Tp>
1279 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1282 { return __builtin_erfc(__x); }
1286 { return __builtin_exp2f(__x); }
1288 constexpr long double
1289 exp2(long double __x)
1290 { return __builtin_exp2l(__x); }
1292 template<typename _Tp>
1293 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1296 { return __builtin_exp2(__x); }
1300 { return __builtin_expm1f(__x); }
1302 constexpr long double
1303 expm1(long double __x)
1304 { return __builtin_expm1l(__x); }
1306 template<typename _Tp>
1307 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1310 { return __builtin_expm1(__x); }
1313 fdim(float __x, float __y)
1314 { return __builtin_fdimf(__x, __y); }
1316 constexpr long double
1317 fdim(long double __x, long double __y)
1318 { return __builtin_fdiml(__x, __y); }
1320 template<typename _Tp, typename _Up>
1321 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1322 fdim(_Tp __x, _Up __y)
1324 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1325 return fdim(__type(__x), __type(__y));
1329 fma(float __x, float __y, float __z)
1330 { return __builtin_fmaf(__x, __y, __z); }
1332 constexpr long double
1333 fma(long double __x, long double __y, long double __z)
1334 { return __builtin_fmal(__x, __y, __z); }
1336 template<typename _Tp, typename _Up, typename _Vp>
1337 constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
1338 fma(_Tp __x, _Up __y, _Vp __z)
1340 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
1341 return fma(__type(__x), __type(__y), __type(__z));
1345 fmax(float __x, float __y)
1346 { return __builtin_fmaxf(__x, __y); }
1348 constexpr long double
1349 fmax(long double __x, long double __y)
1350 { return __builtin_fmaxl(__x, __y); }
1352 template<typename _Tp, typename _Up>
1353 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1354 fmax(_Tp __x, _Up __y)
1356 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1357 return fmax(__type(__x), __type(__y));
1361 fmin(float __x, float __y)
1362 { return __builtin_fminf(__x, __y); }
1364 constexpr long double
1365 fmin(long double __x, long double __y)
1366 { return __builtin_fminl(__x, __y); }
1368 template<typename _Tp, typename _Up>
1369 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1370 fmin(_Tp __x, _Up __y)
1372 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1373 return fmin(__type(__x), __type(__y));
1377 hypot(float __x, float __y)
1378 { return __builtin_hypotf(__x, __y); }
1380 constexpr long double
1381 hypot(long double __x, long double __y)
1382 { return __builtin_hypotl(__x, __y); }
1384 template<typename _Tp, typename _Up>
1385 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1386 hypot(_Tp __x, _Up __y)
1388 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1389 return hypot(__type(__x), __type(__y));
1394 { return __builtin_ilogbf(__x); }
1397 ilogb(long double __x)
1398 { return __builtin_ilogbl(__x); }
1400 template<typename _Tp>
1402 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1405 { return __builtin_ilogb(__x); }
1409 { return __builtin_lgammaf(__x); }
1411 constexpr long double
1412 lgamma(long double __x)
1413 { return __builtin_lgammal(__x); }
1415 template<typename _Tp>
1416 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1419 { return __builtin_lgamma(__x); }
1423 { return __builtin_llrintf(__x); }
1426 llrint(long double __x)
1427 { return __builtin_llrintl(__x); }
1429 template<typename _Tp>
1430 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1433 { return __builtin_llrint(__x); }
1437 { return __builtin_llroundf(__x); }
1440 llround(long double __x)
1441 { return __builtin_llroundl(__x); }
1443 template<typename _Tp>
1444 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1447 { return __builtin_llround(__x); }
1451 { return __builtin_log1pf(__x); }
1453 constexpr long double
1454 log1p(long double __x)
1455 { return __builtin_log1pl(__x); }
1457 template<typename _Tp>
1458 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1461 { return __builtin_log1p(__x); }
1466 { return __builtin_log2f(__x); }
1468 constexpr long double
1469 log2(long double __x)
1470 { return __builtin_log2l(__x); }
1472 template<typename _Tp>
1473 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1476 { return __builtin_log2(__x); }
1480 { return __builtin_logbf(__x); }
1482 constexpr long double
1483 logb(long double __x)
1484 { return __builtin_logbl(__x); }
1486 template<typename _Tp>
1487 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1490 { return __builtin_logb(__x); }
1494 { return __builtin_lrintf(__x); }
1497 lrint(long double __x)
1498 { return __builtin_lrintl(__x); }
1500 template<typename _Tp>
1501 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1504 { return __builtin_lrint(__x); }
1508 { return __builtin_lroundf(__x); }
1511 lround(long double __x)
1512 { return __builtin_lroundl(__x); }
1514 template<typename _Tp>
1515 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1518 { return __builtin_lround(__x); }
1521 nearbyint(float __x)
1522 { return __builtin_nearbyintf(__x); }
1524 constexpr long double
1525 nearbyint(long double __x)
1526 { return __builtin_nearbyintl(__x); }
1528 template<typename _Tp>
1529 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1532 { return __builtin_nearbyint(__x); }
1535 nextafter(float __x, float __y)
1536 { return __builtin_nextafterf(__x, __y); }
1538 constexpr long double
1539 nextafter(long double __x, long double __y)
1540 { return __builtin_nextafterl(__x, __y); }
1542 template<typename _Tp, typename _Up>
1543 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1544 nextafter(_Tp __x, _Up __y)
1546 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1547 return nextafter(__type(__x), __type(__y));
1551 nexttoward(float __x, long double __y)
1552 { return __builtin_nexttowardf(__x, __y); }
1554 constexpr long double
1555 nexttoward(long double __x, long double __y)
1556 { return __builtin_nexttowardl(__x, __y); }
1558 template<typename _Tp>
1559 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1561 nexttoward(_Tp __x, long double __y)
1562 { return __builtin_nexttoward(__x, __y); }
1565 remainder(float __x, float __y)
1566 { return __builtin_remainderf(__x, __y); }
1568 constexpr long double
1569 remainder(long double __x, long double __y)
1570 { return __builtin_remainderl(__x, __y); }
1572 template<typename _Tp, typename _Up>
1573 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1574 remainder(_Tp __x, _Up __y)
1576 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1577 return remainder(__type(__x), __type(__y));
1581 remquo(float __x, float __y, int* __pquo)
1582 { return __builtin_remquof(__x, __y, __pquo); }
1585 remquo(long double __x, long double __y, int* __pquo)
1586 { return __builtin_remquol(__x, __y, __pquo); }
1588 template<typename _Tp, typename _Up>
1589 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1590 remquo(_Tp __x, _Up __y, int* __pquo)
1592 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1593 return remquo(__type(__x), __type(__y), __pquo);
1598 { return __builtin_rintf(__x); }
1600 constexpr long double
1601 rint(long double __x)
1602 { return __builtin_rintl(__x); }
1604 template<typename _Tp>
1605 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1608 { return __builtin_rint(__x); }
1612 { return __builtin_roundf(__x); }
1614 constexpr long double
1615 round(long double __x)
1616 { return __builtin_roundl(__x); }
1618 template<typename _Tp>
1619 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1622 { return __builtin_round(__x); }
1625 scalbln(float __x, long __ex)
1626 { return __builtin_scalblnf(__x, __ex); }
1628 constexpr long double
1629 scalbln(long double __x, long __ex)
1630 { return __builtin_scalblnl(__x, __ex); }
1632 template<typename _Tp>
1633 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1635 scalbln(_Tp __x, long __ex)
1636 { return __builtin_scalbln(__x, __ex); }
1639 scalbn(float __x, int __ex)
1640 { return __builtin_scalbnf(__x, __ex); }
1642 constexpr long double
1643 scalbn(long double __x, int __ex)
1644 { return __builtin_scalbnl(__x, __ex); }
1646 template<typename _Tp>
1647 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1649 scalbn(_Tp __x, int __ex)
1650 { return __builtin_scalbn(__x, __ex); }
1654 { return __builtin_tgammaf(__x); }
1656 constexpr long double
1657 tgamma(long double __x)
1658 { return __builtin_tgammal(__x); }
1660 template<typename _Tp>
1661 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1664 { return __builtin_tgamma(__x); }
1668 { return __builtin_truncf(__x); }
1670 constexpr long double
1671 trunc(long double __x)
1672 { return __builtin_truncl(__x); }
1674 template<typename _Tp>
1675 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1678 { return __builtin_trunc(__x); }
1680 _GLIBCXX_END_NAMESPACE_VERSION
1683 #endif // _GLIBCXX_USE_C99_MATH_TR1
1685 #endif // __GXX_EXPERIMENTAL_CXX0X__