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 inline _GLIBCXX_CONSTEXPR double
83 { return __builtin_fabs(__x); }
85 inline _GLIBCXX_CONSTEXPR float
87 { return __builtin_fabsf(__x); }
89 inline _GLIBCXX_CONSTEXPR long double
91 { return __builtin_fabsl(__x); }
93 template<typename _Tp>
94 inline _GLIBCXX_CONSTEXPR
95 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
98 { return __builtin_fabs(__x); }
102 inline _GLIBCXX_CONSTEXPR float
104 { return __builtin_acosf(__x); }
106 inline _GLIBCXX_CONSTEXPR long double
107 acos(long double __x)
108 { return __builtin_acosl(__x); }
110 template<typename _Tp>
111 inline _GLIBCXX_CONSTEXPR
112 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
115 { return __builtin_acos(__x); }
119 inline _GLIBCXX_CONSTEXPR float
121 { return __builtin_asinf(__x); }
123 inline _GLIBCXX_CONSTEXPR long double
124 asin(long double __x)
125 { return __builtin_asinl(__x); }
127 template<typename _Tp>
128 inline _GLIBCXX_CONSTEXPR
129 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
132 { return __builtin_asin(__x); }
136 inline _GLIBCXX_CONSTEXPR float
138 { return __builtin_atanf(__x); }
140 inline _GLIBCXX_CONSTEXPR long double
141 atan(long double __x)
142 { return __builtin_atanl(__x); }
144 template<typename _Tp>
145 inline _GLIBCXX_CONSTEXPR
146 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
149 { return __builtin_atan(__x); }
153 inline _GLIBCXX_CONSTEXPR float
154 atan2(float __y, float __x)
155 { return __builtin_atan2f(__y, __x); }
157 inline _GLIBCXX_CONSTEXPR long double
158 atan2(long double __y, long double __x)
159 { return __builtin_atan2l(__y, __x); }
161 template<typename _Tp, typename _Up>
162 inline _GLIBCXX_CONSTEXPR
163 typename __gnu_cxx::__promote_2<
164 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
165 && __is_arithmetic<_Up>::__value,
166 _Tp>::__type, _Up>::__type
167 atan2(_Tp __y, _Up __x)
169 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
170 return atan2(__type(__y), __type(__x));
175 inline _GLIBCXX_CONSTEXPR float
177 { return __builtin_ceilf(__x); }
179 inline _GLIBCXX_CONSTEXPR long double
180 ceil(long double __x)
181 { return __builtin_ceill(__x); }
183 template<typename _Tp>
184 inline _GLIBCXX_CONSTEXPR
185 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
188 { return __builtin_ceil(__x); }
192 inline _GLIBCXX_CONSTEXPR float
194 { return __builtin_cosf(__x); }
196 inline _GLIBCXX_CONSTEXPR long double
198 { return __builtin_cosl(__x); }
200 template<typename _Tp>
201 inline _GLIBCXX_CONSTEXPR
202 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
205 { return __builtin_cos(__x); }
209 inline _GLIBCXX_CONSTEXPR float
211 { return __builtin_coshf(__x); }
213 inline _GLIBCXX_CONSTEXPR long double
214 cosh(long double __x)
215 { return __builtin_coshl(__x); }
217 template<typename _Tp>
218 inline _GLIBCXX_CONSTEXPR
219 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
222 { return __builtin_cosh(__x); }
226 inline _GLIBCXX_CONSTEXPR float
228 { return __builtin_expf(__x); }
230 inline _GLIBCXX_CONSTEXPR long double
232 { return __builtin_expl(__x); }
234 template<typename _Tp>
235 inline _GLIBCXX_CONSTEXPR
236 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
239 { return __builtin_exp(__x); }
243 inline _GLIBCXX_CONSTEXPR float
245 { return __builtin_fabsf(__x); }
247 inline _GLIBCXX_CONSTEXPR long double
248 fabs(long double __x)
249 { return __builtin_fabsl(__x); }
251 template<typename _Tp>
252 inline _GLIBCXX_CONSTEXPR
253 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
256 { return __builtin_fabs(__x); }
260 inline _GLIBCXX_CONSTEXPR float
262 { return __builtin_floorf(__x); }
264 inline _GLIBCXX_CONSTEXPR long double
265 floor(long double __x)
266 { return __builtin_floorl(__x); }
268 template<typename _Tp>
269 inline _GLIBCXX_CONSTEXPR
270 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
273 { return __builtin_floor(__x); }
277 inline _GLIBCXX_CONSTEXPR float
278 fmod(float __x, float __y)
279 { return __builtin_fmodf(__x, __y); }
281 inline _GLIBCXX_CONSTEXPR long double
282 fmod(long double __x, long double __y)
283 { return __builtin_fmodl(__x, __y); }
285 template<typename _Tp, typename _Up>
286 inline _GLIBCXX_CONSTEXPR
287 typename __gnu_cxx::__promote_2<
288 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
289 && __is_arithmetic<_Up>::__value,
290 _Tp>::__type, _Up>::__type
291 fmod(_Tp __x, _Up __y)
293 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
294 return fmod(__type(__x), __type(__y));
299 inline _GLIBCXX_CONSTEXPR float
300 frexp(float __x, int* __exp)
301 { return __builtin_frexpf(__x, __exp); }
303 inline _GLIBCXX_CONSTEXPR long double
304 frexp(long double __x, int* __exp)
305 { return __builtin_frexpl(__x, __exp); }
307 template<typename _Tp>
308 inline _GLIBCXX_CONSTEXPR
309 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
311 frexp(_Tp __x, int* __exp)
312 { return __builtin_frexp(__x, __exp); }
316 inline _GLIBCXX_CONSTEXPR float
317 ldexp(float __x, int __exp)
318 { return __builtin_ldexpf(__x, __exp); }
320 inline _GLIBCXX_CONSTEXPR long double
321 ldexp(long double __x, int __exp)
322 { return __builtin_ldexpl(__x, __exp); }
324 template<typename _Tp>
325 inline _GLIBCXX_CONSTEXPR
326 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
328 ldexp(_Tp __x, int __exp)
329 { return __builtin_ldexp(__x, __exp); }
333 inline _GLIBCXX_CONSTEXPR float
335 { return __builtin_logf(__x); }
337 inline _GLIBCXX_CONSTEXPR long double
339 { return __builtin_logl(__x); }
341 template<typename _Tp>
342 inline _GLIBCXX_CONSTEXPR
343 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
346 { return __builtin_log(__x); }
350 inline _GLIBCXX_CONSTEXPR float
352 { return __builtin_log10f(__x); }
354 inline _GLIBCXX_CONSTEXPR long double
355 log10(long double __x)
356 { return __builtin_log10l(__x); }
358 template<typename _Tp>
359 inline _GLIBCXX_CONSTEXPR
360 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
363 { return __builtin_log10(__x); }
367 inline _GLIBCXX_CONSTEXPR float
368 modf(float __x, float* __iptr)
369 { return __builtin_modff(__x, __iptr); }
371 inline _GLIBCXX_CONSTEXPR long double
372 modf(long double __x, long double* __iptr)
373 { return __builtin_modfl(__x, __iptr); }
377 inline _GLIBCXX_CONSTEXPR float
378 pow(float __x, float __y)
379 { return __builtin_powf(__x, __y); }
381 inline _GLIBCXX_CONSTEXPR long double
382 pow(long double __x, long double __y)
383 { return __builtin_powl(__x, __y); }
385 #ifndef __GXX_EXPERIMENTAL_CXX0X__
386 // _GLIBCXX_RESOLVE_LIB_DEFECTS
387 // DR 550. What should the return type of pow(float,int) be?
389 pow(double __x, int __i)
390 { return __builtin_powi(__x, __i); }
393 pow(float __x, int __n)
394 { return __builtin_powif(__x, __n); }
397 pow(long double __x, int __n)
398 { return __builtin_powil(__x, __n); }
401 template<typename _Tp, typename _Up>
402 inline _GLIBCXX_CONSTEXPR
403 typename __gnu_cxx::__promote_2<
404 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
405 && __is_arithmetic<_Up>::__value,
406 _Tp>::__type, _Up>::__type
407 pow(_Tp __x, _Up __y)
409 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
410 return pow(__type(__x), __type(__y));
415 inline _GLIBCXX_CONSTEXPR float
417 { return __builtin_sinf(__x); }
419 inline _GLIBCXX_CONSTEXPR long double
421 { return __builtin_sinl(__x); }
423 template<typename _Tp>
424 inline _GLIBCXX_CONSTEXPR
425 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
428 { return __builtin_sin(__x); }
432 inline _GLIBCXX_CONSTEXPR float
434 { return __builtin_sinhf(__x); }
436 inline _GLIBCXX_CONSTEXPR long double
437 sinh(long double __x)
438 { return __builtin_sinhl(__x); }
440 template<typename _Tp>
441 inline _GLIBCXX_CONSTEXPR
442 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
445 { return __builtin_sinh(__x); }
449 inline _GLIBCXX_CONSTEXPR float
451 { return __builtin_sqrtf(__x); }
453 inline _GLIBCXX_CONSTEXPR long double
454 sqrt(long double __x)
455 { return __builtin_sqrtl(__x); }
457 template<typename _Tp>
458 inline _GLIBCXX_CONSTEXPR
459 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
462 { return __builtin_sqrt(__x); }
466 inline _GLIBCXX_CONSTEXPR float
468 { return __builtin_tanf(__x); }
470 inline _GLIBCXX_CONSTEXPR long double
472 { return __builtin_tanl(__x); }
474 template<typename _Tp>
475 inline _GLIBCXX_CONSTEXPR
476 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
479 { return __builtin_tan(__x); }
483 inline _GLIBCXX_CONSTEXPR float
485 { return __builtin_tanhf(__x); }
487 inline _GLIBCXX_CONSTEXPR long double
488 tanh(long double __x)
489 { return __builtin_tanhl(__x); }
491 template<typename _Tp>
492 inline _GLIBCXX_CONSTEXPR
493 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
496 { return __builtin_tanh(__x); }
498 _GLIBCXX_END_NAMESPACE_VERSION
501 #if _GLIBCXX_USE_C99_MATH
502 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
504 // These are possible macros imported from C99-land.
512 #undef isgreaterequal
518 namespace std _GLIBCXX_VISIBILITY(default)
520 _GLIBCXX_BEGIN_NAMESPACE_VERSION
522 #ifdef __GXX_EXPERIMENTAL_CXX0X__
524 fpclassify(float __x)
525 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
526 FP_SUBNORMAL, FP_ZERO, __x); }
529 fpclassify(double __x)
530 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
531 FP_SUBNORMAL, FP_ZERO, __x); }
534 fpclassify(long double __x)
535 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
536 FP_SUBNORMAL, FP_ZERO, __x); }
538 template<typename _Tp>
539 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
542 { return __x != 0 ? FP_NORMAL : FP_ZERO; }
546 { return __builtin_isfinite(__x); }
550 { return __builtin_isfinite(__x); }
553 isfinite(long double __x)
554 { return __builtin_isfinite(__x); }
556 template<typename _Tp>
557 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
564 { return __builtin_isinf(__x); }
568 { return __builtin_isinf(__x); }
571 isinf(long double __x)
572 { return __builtin_isinf(__x); }
574 template<typename _Tp>
575 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
582 { return __builtin_isnan(__x); }
586 { return __builtin_isnan(__x); }
589 isnan(long double __x)
590 { return __builtin_isnan(__x); }
592 template<typename _Tp>
593 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
600 { return __builtin_isnormal(__x); }
604 { return __builtin_isnormal(__x); }
607 isnormal(long double __x)
608 { return __builtin_isnormal(__x); }
610 template<typename _Tp>
611 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
614 { return __x != 0 ? true : false; }
618 { return __builtin_signbit(__x); }
622 { return __builtin_signbit(__x); }
625 signbit(long double __x)
626 { return __builtin_signbit(__x); }
628 template<typename _Tp>
629 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
632 { return __x < 0 ? true : false; }
635 isgreater(float __x, float __y)
636 { return __builtin_isgreater(__x, __y); }
639 isgreater(double __x, double __y)
640 { return __builtin_isgreater(__x, __y); }
643 isgreater(long double __x, long double __y)
644 { return __builtin_isgreater(__x, __y); }
646 template<typename _Tp, typename _Up>
648 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
649 && __is_arithmetic<_Up>::__value), bool>::__type
650 isgreater(_Tp __x, _Up __y)
652 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
653 return __builtin_isgreater(__type(__x), __type(__y));
657 isgreaterequal(float __x, float __y)
658 { return __builtin_isgreaterequal(__x, __y); }
661 isgreaterequal(double __x, double __y)
662 { return __builtin_isgreaterequal(__x, __y); }
665 isgreaterequal(long double __x, long double __y)
666 { return __builtin_isgreaterequal(__x, __y); }
668 template<typename _Tp, typename _Up>
670 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
671 && __is_arithmetic<_Up>::__value), bool>::__type
672 isgreaterequal(_Tp __x, _Up __y)
674 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
675 return __builtin_isgreaterequal(__type(__x), __type(__y));
679 isless(float __x, float __y)
680 { return __builtin_isless(__x, __y); }
683 isless(double __x, double __y)
684 { return __builtin_isless(__x, __y); }
687 isless(long double __x, long double __y)
688 { return __builtin_isless(__x, __y); }
690 template<typename _Tp, typename _Up>
692 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
693 && __is_arithmetic<_Up>::__value), bool>::__type
694 isless(_Tp __x, _Up __y)
696 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
697 return __builtin_isless(__type(__x), __type(__y));
701 islessequal(float __x, float __y)
702 { return __builtin_islessequal(__x, __y); }
705 islessequal(double __x, double __y)
706 { return __builtin_islessequal(__x, __y); }
709 islessequal(long double __x, long double __y)
710 { return __builtin_islessequal(__x, __y); }
712 template<typename _Tp, typename _Up>
714 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
715 && __is_arithmetic<_Up>::__value), bool>::__type
716 islessequal(_Tp __x, _Up __y)
718 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
719 return __builtin_islessequal(__type(__x), __type(__y));
723 islessgreater(float __x, float __y)
724 { return __builtin_islessgreater(__x, __y); }
727 islessgreater(double __x, double __y)
728 { return __builtin_islessgreater(__x, __y); }
731 islessgreater(long double __x, long double __y)
732 { return __builtin_islessgreater(__x, __y); }
734 template<typename _Tp, typename _Up>
736 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
737 && __is_arithmetic<_Up>::__value), bool>::__type
738 islessgreater(_Tp __x, _Up __y)
740 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
741 return __builtin_islessgreater(__type(__x), __type(__y));
745 isunordered(float __x, float __y)
746 { return __builtin_isunordered(__x, __y); }
749 isunordered(double __x, double __y)
750 { return __builtin_isunordered(__x, __y); }
753 isunordered(long double __x, long double __y)
754 { return __builtin_isunordered(__x, __y); }
756 template<typename _Tp, typename _Up>
758 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
759 && __is_arithmetic<_Up>::__value), bool>::__type
760 isunordered(_Tp __x, _Up __y)
762 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
763 return __builtin_isunordered(__type(__x), __type(__y));
768 template<typename _Tp>
769 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
773 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
774 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
775 FP_SUBNORMAL, FP_ZERO, __type(__f));
778 template<typename _Tp>
779 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
783 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
784 return __builtin_isfinite(__type(__f));
787 template<typename _Tp>
788 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
792 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
793 return __builtin_isinf(__type(__f));
796 template<typename _Tp>
797 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
801 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
802 return __builtin_isnan(__type(__f));
805 template<typename _Tp>
806 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
810 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
811 return __builtin_isnormal(__type(__f));
814 template<typename _Tp>
815 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
819 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
820 return __builtin_signbit(__type(__f));
823 template<typename _Tp>
824 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
826 isgreater(_Tp __f1, _Tp __f2)
828 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
829 return __builtin_isgreater(__type(__f1), __type(__f2));
832 template<typename _Tp>
833 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
835 isgreaterequal(_Tp __f1, _Tp __f2)
837 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
838 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
841 template<typename _Tp>
842 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
844 isless(_Tp __f1, _Tp __f2)
846 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
847 return __builtin_isless(__type(__f1), __type(__f2));
850 template<typename _Tp>
851 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
853 islessequal(_Tp __f1, _Tp __f2)
855 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
856 return __builtin_islessequal(__type(__f1), __type(__f2));
859 template<typename _Tp>
860 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
862 islessgreater(_Tp __f1, _Tp __f2)
864 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
865 return __builtin_islessgreater(__type(__f1), __type(__f2));
868 template<typename _Tp>
869 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
871 isunordered(_Tp __f1, _Tp __f2)
873 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
874 return __builtin_isunordered(__type(__f1), __type(__f2));
879 _GLIBCXX_END_NAMESPACE_VERSION
882 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
885 #ifdef __GXX_EXPERIMENTAL_CXX0X__
887 #ifdef _GLIBCXX_USE_C99_MATH_TR1
995 namespace std _GLIBCXX_VISIBILITY(default)
997 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1109 using ::nexttowardf;
1110 using ::nexttowardl;
1144 /// Additional overloads.
1147 { return __builtin_acoshf(__x); }
1149 constexpr long double
1150 acosh(long double __x)
1151 { return __builtin_acoshl(__x); }
1153 template<typename _Tp>
1154 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1157 { return __builtin_acosh(__x); }
1161 { return __builtin_asinhf(__x); }
1163 constexpr long double
1164 asinh(long double __x)
1165 { return __builtin_asinhl(__x); }
1167 template<typename _Tp>
1168 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1171 { return __builtin_asinh(__x); }
1175 { return __builtin_atanhf(__x); }
1177 constexpr long double
1178 atanh(long double __x)
1179 { return __builtin_atanhl(__x); }
1181 template<typename _Tp>
1182 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1185 { return __builtin_atanh(__x); }
1189 { return __builtin_cbrtf(__x); }
1191 constexpr long double
1192 cbrt(long double __x)
1193 { return __builtin_cbrtl(__x); }
1195 template<typename _Tp>
1196 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1199 { return __builtin_cbrt(__x); }
1202 copysign(float __x, float __y)
1203 { return __builtin_copysignf(__x, __y); }
1205 constexpr long double
1206 copysign(long double __x, long double __y)
1207 { return __builtin_copysignl(__x, __y); }
1209 template<typename _Tp, typename _Up>
1211 typename __gnu_cxx::__promote_2<
1212 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1213 && __is_arithmetic<_Up>::__value,
1214 _Tp>::__type, _Up>::__type
1215 copysign(_Tp __x, _Up __y)
1217 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1218 return copysign(__type(__x), __type(__y));
1223 { return __builtin_erff(__x); }
1225 constexpr long double
1226 erf(long double __x)
1227 { return __builtin_erfl(__x); }
1229 template<typename _Tp>
1230 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1233 { return __builtin_erf(__x); }
1237 { return __builtin_erfcf(__x); }
1239 constexpr long double
1240 erfc(long double __x)
1241 { return __builtin_erfcl(__x); }
1243 template<typename _Tp>
1244 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1247 { return __builtin_erfc(__x); }
1251 { return __builtin_exp2f(__x); }
1253 constexpr long double
1254 exp2(long double __x)
1255 { return __builtin_exp2l(__x); }
1257 template<typename _Tp>
1258 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1261 { return __builtin_exp2(__x); }
1265 { return __builtin_expm1f(__x); }
1267 constexpr long double
1268 expm1(long double __x)
1269 { return __builtin_expm1l(__x); }
1271 template<typename _Tp>
1272 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1275 { return __builtin_expm1(__x); }
1278 fdim(float __x, float __y)
1279 { return __builtin_fdimf(__x, __y); }
1281 constexpr long double
1282 fdim(long double __x, long double __y)
1283 { return __builtin_fdiml(__x, __y); }
1285 template<typename _Tp, typename _Up>
1287 typename __gnu_cxx::__promote_2<
1288 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1289 && __is_arithmetic<_Up>::__value,
1290 _Tp>::__type, _Up>::__type
1291 fdim(_Tp __x, _Up __y)
1293 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1294 return fdim(__type(__x), __type(__y));
1298 fma(float __x, float __y, float __z)
1299 { return __builtin_fmaf(__x, __y, __z); }
1301 constexpr long double
1302 fma(long double __x, long double __y, long double __z)
1303 { return __builtin_fmal(__x, __y, __z); }
1305 template<typename _Tp, typename _Up, typename _Vp>
1307 typename __gnu_cxx::__promote_3<
1308 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1309 && __is_arithmetic<_Up>::__value
1310 && __is_arithmetic<_Vp>::__value,
1311 _Tp>::__type, _Up, _Vp>::__type
1312 fma(_Tp __x, _Up __y, _Vp __z)
1314 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
1315 return fma(__type(__x), __type(__y), __type(__z));
1319 fmax(float __x, float __y)
1320 { return __builtin_fmaxf(__x, __y); }
1322 constexpr long double
1323 fmax(long double __x, long double __y)
1324 { return __builtin_fmaxl(__x, __y); }
1326 template<typename _Tp, typename _Up>
1328 typename __gnu_cxx::__promote_2<
1329 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1330 && __is_arithmetic<_Up>::__value,
1331 _Tp>::__type, _Up>::__type
1332 fmax(_Tp __x, _Up __y)
1334 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1335 return fmax(__type(__x), __type(__y));
1339 fmin(float __x, float __y)
1340 { return __builtin_fminf(__x, __y); }
1342 constexpr long double
1343 fmin(long double __x, long double __y)
1344 { return __builtin_fminl(__x, __y); }
1346 template<typename _Tp, typename _Up>
1348 typename __gnu_cxx::__promote_2<
1349 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1350 && __is_arithmetic<_Up>::__value,
1351 _Tp>::__type, _Up>::__type
1352 fmin(_Tp __x, _Up __y)
1354 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1355 return fmin(__type(__x), __type(__y));
1359 hypot(float __x, float __y)
1360 { return __builtin_hypotf(__x, __y); }
1362 constexpr long double
1363 hypot(long double __x, long double __y)
1364 { return __builtin_hypotl(__x, __y); }
1366 template<typename _Tp, typename _Up>
1368 typename __gnu_cxx::__promote_2<
1369 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1370 && __is_arithmetic<_Up>::__value,
1371 _Tp>::__type, _Up>::__type
1372 hypot(_Tp __x, _Up __y)
1374 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1375 return hypot(__type(__x), __type(__y));
1380 { return __builtin_ilogbf(__x); }
1383 ilogb(long double __x)
1384 { return __builtin_ilogbl(__x); }
1386 template<typename _Tp>
1388 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1391 { return __builtin_ilogb(__x); }
1395 { return __builtin_lgammaf(__x); }
1397 constexpr long double
1398 lgamma(long double __x)
1399 { return __builtin_lgammal(__x); }
1401 template<typename _Tp>
1402 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1405 { return __builtin_lgamma(__x); }
1409 { return __builtin_llrintf(__x); }
1412 llrint(long double __x)
1413 { return __builtin_llrintl(__x); }
1415 template<typename _Tp>
1416 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1419 { return __builtin_llrint(__x); }
1423 { return __builtin_llroundf(__x); }
1426 llround(long double __x)
1427 { return __builtin_llroundl(__x); }
1429 template<typename _Tp>
1430 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1433 { return __builtin_llround(__x); }
1437 { return __builtin_log1pf(__x); }
1439 constexpr long double
1440 log1p(long double __x)
1441 { return __builtin_log1pl(__x); }
1443 template<typename _Tp>
1444 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1447 { return __builtin_log1p(__x); }
1452 { return __builtin_log2f(__x); }
1454 constexpr long double
1455 log2(long double __x)
1456 { return __builtin_log2l(__x); }
1458 template<typename _Tp>
1459 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1462 { return __builtin_log2(__x); }
1466 { return __builtin_logbf(__x); }
1468 constexpr long double
1469 logb(long double __x)
1470 { return __builtin_logbl(__x); }
1472 template<typename _Tp>
1473 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1476 { return __builtin_logb(__x); }
1480 { return __builtin_lrintf(__x); }
1483 lrint(long double __x)
1484 { return __builtin_lrintl(__x); }
1486 template<typename _Tp>
1487 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1490 { return __builtin_lrint(__x); }
1494 { return __builtin_lroundf(__x); }
1497 lround(long double __x)
1498 { return __builtin_lroundl(__x); }
1500 template<typename _Tp>
1501 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1504 { return __builtin_lround(__x); }
1507 nearbyint(float __x)
1508 { return __builtin_nearbyintf(__x); }
1510 constexpr long double
1511 nearbyint(long double __x)
1512 { return __builtin_nearbyintl(__x); }
1514 template<typename _Tp>
1515 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1518 { return __builtin_nearbyint(__x); }
1521 nextafter(float __x, float __y)
1522 { return __builtin_nextafterf(__x, __y); }
1524 constexpr long double
1525 nextafter(long double __x, long double __y)
1526 { return __builtin_nextafterl(__x, __y); }
1528 template<typename _Tp, typename _Up>
1530 typename __gnu_cxx::__promote_2<
1531 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1532 && __is_arithmetic<_Up>::__value,
1533 _Tp>::__type, _Up>::__type
1534 nextafter(_Tp __x, _Up __y)
1536 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1537 return nextafter(__type(__x), __type(__y));
1541 nexttoward(float __x, long double __y)
1542 { return __builtin_nexttowardf(__x, __y); }
1544 constexpr long double
1545 nexttoward(long double __x, long double __y)
1546 { return __builtin_nexttowardl(__x, __y); }
1548 template<typename _Tp>
1549 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1551 nexttoward(_Tp __x, long double __y)
1552 { return __builtin_nexttoward(__x, __y); }
1555 remainder(float __x, float __y)
1556 { return __builtin_remainderf(__x, __y); }
1558 constexpr long double
1559 remainder(long double __x, long double __y)
1560 { return __builtin_remainderl(__x, __y); }
1562 template<typename _Tp, typename _Up>
1564 typename __gnu_cxx::__promote_2<
1565 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1566 && __is_arithmetic<_Up>::__value,
1567 _Tp>::__type, _Up>::__type
1568 remainder(_Tp __x, _Up __y)
1570 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1571 return remainder(__type(__x), __type(__y));
1575 remquo(float __x, float __y, int* __pquo)
1576 { return __builtin_remquof(__x, __y, __pquo); }
1578 constexpr long double
1579 remquo(long double __x, long double __y, int* __pquo)
1580 { return __builtin_remquol(__x, __y, __pquo); }
1582 template<typename _Tp, typename _Up>
1584 typename __gnu_cxx::__promote_2<
1585 typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value
1586 && __is_arithmetic<_Up>::__value,
1587 _Tp>::__type, _Up>::__type
1588 remquo(_Tp __x, _Up __y, int* __pquo)
1590 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1591 return remquo(__type(__x), __type(__y), __pquo);
1596 { return __builtin_rintf(__x); }
1598 constexpr long double
1599 rint(long double __x)
1600 { return __builtin_rintl(__x); }
1602 template<typename _Tp>
1603 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1606 { return __builtin_rint(__x); }
1610 { return __builtin_roundf(__x); }
1612 constexpr long double
1613 round(long double __x)
1614 { return __builtin_roundl(__x); }
1616 template<typename _Tp>
1617 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1620 { return __builtin_round(__x); }
1623 scalbln(float __x, long __ex)
1624 { return __builtin_scalblnf(__x, __ex); }
1626 constexpr long double
1627 scalbln(long double __x, long __ex)
1628 { return __builtin_scalblnl(__x, __ex); }
1630 template<typename _Tp>
1631 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1633 scalbln(_Tp __x, long __ex)
1634 { return __builtin_scalbln(__x, __ex); }
1637 scalbn(float __x, int __ex)
1638 { return __builtin_scalbnf(__x, __ex); }
1640 constexpr long double
1641 scalbn(long double __x, int __ex)
1642 { return __builtin_scalbnl(__x, __ex); }
1644 template<typename _Tp>
1645 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1647 scalbn(_Tp __x, int __ex)
1648 { return __builtin_scalbn(__x, __ex); }
1652 { return __builtin_tgammaf(__x); }
1654 constexpr long double
1655 tgamma(long double __x)
1656 { return __builtin_tgammal(__x); }
1658 template<typename _Tp>
1659 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1662 { return __builtin_tgamma(__x); }
1666 { return __builtin_truncf(__x); }
1668 constexpr long double
1669 trunc(long double __x)
1670 { return __builtin_truncl(__x); }
1672 template<typename _Tp>
1673 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1676 { return __builtin_trunc(__x); }
1678 _GLIBCXX_END_NAMESPACE_VERSION
1681 #endif // _GLIBCXX_USE_C99_MATH_TR1
1683 #endif // __GXX_EXPERIMENTAL_CXX0X__