1 // -*- C++ -*- C forwarding header.
3 // Copyright (C) 1997-2024 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 /** @file include/cmath
26 * This is a Standard C++ Library file. You should @c \#include this file
27 * in your programs, rather than any of the @a *.h implementation files.
29 * This is the C++ version of the Standard C Library header @c math.h,
30 * and its contents are (mostly) the same as that header, but are all
31 * contained in the namespace @c std (except for names which are defined
36 // ISO C++ 14882: 26.5 C library
39 #pragma GCC system_header
41 #include <bits/requires_hosted.h>
43 #include <bits/c++config.h>
44 #include <bits/cpp_type_traits.h>
45 #include <ext/type_traits.h>
46 #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
47 #include_next <math.h>
48 #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
49 #include <bits/std_abs.h>
51 #ifndef _GLIBCXX_CMATH
52 #define _GLIBCXX_CMATH 1
54 #define __glibcxx_want_hypot
55 #define __glibcxx_want_interpolate
56 #include <bits/version.h>
58 // Get rid of those macros defined in <math.h> in lieu of real functions.
85 namespace std _GLIBCXX_VISIBILITY(default)
87 _GLIBCXX_BEGIN_NAMESPACE_VERSION
91 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
92 inline _GLIBCXX_CONSTEXPR float
94 { return __builtin_acosf(__x); }
96 inline _GLIBCXX_CONSTEXPR long double
98 { return __builtin_acosl(__x); }
101 template<typename _Tp>
102 inline _GLIBCXX_CONSTEXPR
103 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
106 { return __builtin_acos(__x); }
110 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
111 inline _GLIBCXX_CONSTEXPR float
113 { return __builtin_asinf(__x); }
115 inline _GLIBCXX_CONSTEXPR long double
116 asin(long double __x)
117 { return __builtin_asinl(__x); }
120 template<typename _Tp>
121 inline _GLIBCXX_CONSTEXPR
122 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
125 { return __builtin_asin(__x); }
129 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
130 inline _GLIBCXX_CONSTEXPR float
132 { return __builtin_atanf(__x); }
134 inline _GLIBCXX_CONSTEXPR long double
135 atan(long double __x)
136 { return __builtin_atanl(__x); }
139 template<typename _Tp>
140 inline _GLIBCXX_CONSTEXPR
141 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
144 { return __builtin_atan(__x); }
148 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
149 inline _GLIBCXX_CONSTEXPR float
150 atan2(float __y, float __x)
151 { return __builtin_atan2f(__y, __x); }
153 inline _GLIBCXX_CONSTEXPR long double
154 atan2(long double __y, long double __x)
155 { return __builtin_atan2l(__y, __x); }
160 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
161 inline _GLIBCXX_CONSTEXPR float
163 { return __builtin_ceilf(__x); }
165 inline _GLIBCXX_CONSTEXPR long double
166 ceil(long double __x)
167 { return __builtin_ceill(__x); }
170 template<typename _Tp>
171 inline _GLIBCXX_CONSTEXPR
172 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
175 { return __builtin_ceil(__x); }
179 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
180 inline _GLIBCXX_CONSTEXPR float
182 { return __builtin_cosf(__x); }
184 inline _GLIBCXX_CONSTEXPR long double
186 { return __builtin_cosl(__x); }
189 template<typename _Tp>
190 inline _GLIBCXX_CONSTEXPR
191 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
194 { return __builtin_cos(__x); }
198 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
199 inline _GLIBCXX_CONSTEXPR float
201 { return __builtin_coshf(__x); }
203 inline _GLIBCXX_CONSTEXPR long double
204 cosh(long double __x)
205 { return __builtin_coshl(__x); }
208 template<typename _Tp>
209 inline _GLIBCXX_CONSTEXPR
210 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
213 { return __builtin_cosh(__x); }
217 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
218 inline _GLIBCXX_CONSTEXPR float
220 { return __builtin_expf(__x); }
222 inline _GLIBCXX_CONSTEXPR long double
224 { return __builtin_expl(__x); }
227 template<typename _Tp>
228 inline _GLIBCXX_CONSTEXPR
229 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
232 { return __builtin_exp(__x); }
236 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
237 inline _GLIBCXX_CONSTEXPR float
239 { return __builtin_fabsf(__x); }
241 inline _GLIBCXX_CONSTEXPR long double
242 fabs(long double __x)
243 { return __builtin_fabsl(__x); }
246 template<typename _Tp>
247 inline _GLIBCXX_CONSTEXPR
248 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
251 { return __builtin_fabs(__x); }
255 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
256 inline _GLIBCXX_CONSTEXPR float
258 { return __builtin_floorf(__x); }
260 inline _GLIBCXX_CONSTEXPR long double
261 floor(long double __x)
262 { return __builtin_floorl(__x); }
265 template<typename _Tp>
266 inline _GLIBCXX_CONSTEXPR
267 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
270 { return __builtin_floor(__x); }
274 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
275 inline _GLIBCXX_CONSTEXPR float
276 fmod(float __x, float __y)
277 { return __builtin_fmodf(__x, __y); }
279 inline _GLIBCXX_CONSTEXPR long double
280 fmod(long double __x, long double __y)
281 { return __builtin_fmodl(__x, __y); }
286 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
288 frexp(float __x, int* __exp)
289 { return __builtin_frexpf(__x, __exp); }
292 frexp(long double __x, int* __exp)
293 { return __builtin_frexpl(__x, __exp); }
296 template<typename _Tp>
297 inline _GLIBCXX_CONSTEXPR
298 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
300 frexp(_Tp __x, int* __exp)
301 { return __builtin_frexp(__x, __exp); }
305 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
306 inline _GLIBCXX_CONSTEXPR float
307 ldexp(float __x, int __exp)
308 { return __builtin_ldexpf(__x, __exp); }
310 inline _GLIBCXX_CONSTEXPR long double
311 ldexp(long double __x, int __exp)
312 { return __builtin_ldexpl(__x, __exp); }
315 template<typename _Tp>
316 inline _GLIBCXX_CONSTEXPR
317 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
319 ldexp(_Tp __x, int __exp)
320 { return __builtin_ldexp(__x, __exp); }
324 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
325 inline _GLIBCXX_CONSTEXPR float
327 { return __builtin_logf(__x); }
329 inline _GLIBCXX_CONSTEXPR long double
331 { return __builtin_logl(__x); }
334 template<typename _Tp>
335 inline _GLIBCXX_CONSTEXPR
336 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
339 { return __builtin_log(__x); }
343 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
344 inline _GLIBCXX_CONSTEXPR float
346 { return __builtin_log10f(__x); }
348 inline _GLIBCXX_CONSTEXPR long double
349 log10(long double __x)
350 { return __builtin_log10l(__x); }
353 template<typename _Tp>
354 inline _GLIBCXX_CONSTEXPR
355 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
358 { return __builtin_log10(__x); }
362 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
364 modf(float __x, float* __iptr)
365 { return __builtin_modff(__x, __iptr); }
368 modf(long double __x, long double* __iptr)
369 { return __builtin_modfl(__x, __iptr); }
374 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
375 inline _GLIBCXX_CONSTEXPR float
376 pow(float __x, float __y)
377 { return __builtin_powf(__x, __y); }
379 inline _GLIBCXX_CONSTEXPR long double
380 pow(long double __x, long double __y)
381 { return __builtin_powl(__x, __y); }
383 #if __cplusplus < 201103L
384 // _GLIBCXX_RESOLVE_LIB_DEFECTS
385 // DR 550. What should the return type of pow(float,int) be?
387 pow(double __x, int __i)
388 { return __builtin_powi(__x, __i); }
391 pow(float __x, int __n)
392 { return __builtin_powif(__x, __n); }
395 pow(long double __x, int __n)
396 { return __builtin_powil(__x, __n); }
402 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
403 inline _GLIBCXX_CONSTEXPR float
405 { return __builtin_sinf(__x); }
407 inline _GLIBCXX_CONSTEXPR long double
409 { return __builtin_sinl(__x); }
412 template<typename _Tp>
413 inline _GLIBCXX_CONSTEXPR
414 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
417 { return __builtin_sin(__x); }
421 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
422 inline _GLIBCXX_CONSTEXPR float
424 { return __builtin_sinhf(__x); }
426 inline _GLIBCXX_CONSTEXPR long double
427 sinh(long double __x)
428 { return __builtin_sinhl(__x); }
431 template<typename _Tp>
432 inline _GLIBCXX_CONSTEXPR
433 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
436 { return __builtin_sinh(__x); }
440 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
441 inline _GLIBCXX_CONSTEXPR float
443 { return __builtin_sqrtf(__x); }
445 inline _GLIBCXX_CONSTEXPR long double
446 sqrt(long double __x)
447 { return __builtin_sqrtl(__x); }
450 template<typename _Tp>
451 inline _GLIBCXX_CONSTEXPR
452 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
455 { return __builtin_sqrt(__x); }
459 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
460 inline _GLIBCXX_CONSTEXPR float
462 { return __builtin_tanf(__x); }
464 inline _GLIBCXX_CONSTEXPR long double
466 { return __builtin_tanl(__x); }
469 template<typename _Tp>
470 inline _GLIBCXX_CONSTEXPR
471 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
474 { return __builtin_tan(__x); }
478 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
479 inline _GLIBCXX_CONSTEXPR float
481 { return __builtin_tanhf(__x); }
483 inline _GLIBCXX_CONSTEXPR long double
484 tanh(long double __x)
485 { return __builtin_tanhl(__x); }
488 template<typename _Tp>
489 inline _GLIBCXX_CONSTEXPR
490 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
493 { return __builtin_tanh(__x); }
495 #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
498 { return _Float16(__builtin_acosf(__x)); }
502 { return _Float16(__builtin_asinf(__x)); }
506 { return _Float16(__builtin_atanf(__x)); }
509 atan2(_Float16 __y, _Float16 __x)
510 { return _Float16(__builtin_atan2f(__y, __x)); }
514 { return _Float16(__builtin_ceilf(__x)); }
518 { return _Float16(__builtin_cosf(__x)); }
522 { return _Float16(__builtin_coshf(__x)); }
526 { return _Float16(__builtin_expf(__x)); }
530 { return _Float16(__builtin_fabsf(__x)); }
534 { return _Float16(__builtin_floorf(__x)); }
537 fmod(_Float16 __x, _Float16 __y)
538 { return _Float16(__builtin_fmodf(__x, __y)); }
541 frexp(_Float16 __x, int* __exp)
542 { return _Float16(__builtin_frexpf(__x, __exp)); }
545 ldexp(_Float16 __x, int __exp)
546 { return _Float16(__builtin_ldexpf(__x, __exp)); }
550 { return _Float16(__builtin_logf(__x)); }
554 { return _Float16(__builtin_log10f(__x)); }
557 modf(_Float16 __x, _Float16* __iptr)
559 float __i, __ret = __builtin_modff(__x, &__i);
560 *__iptr = _Float16(__i);
561 return _Float16(__ret);
565 pow(_Float16 __x, _Float16 __y)
566 { return _Float16(__builtin_powf(__x, __y)); }
570 { return _Float16(__builtin_sinf(__x)); }
574 { return _Float16(__builtin_sinhf(__x)); }
578 { return _Float16(__builtin_sqrtf(__x)); }
582 { return _Float16(__builtin_tanf(__x)); }
586 { return _Float16(__builtin_tanhf(__x)); }
589 #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
592 { return __builtin_acosf(__x); }
596 { return __builtin_asinf(__x); }
600 { return __builtin_atanf(__x); }
603 atan2(_Float32 __y, _Float32 __x)
604 { return __builtin_atan2f(__y, __x); }
608 { return __builtin_ceilf(__x); }
612 { return __builtin_cosf(__x); }
616 { return __builtin_coshf(__x); }
620 { return __builtin_expf(__x); }
624 { return __builtin_fabsf(__x); }
628 { return __builtin_floorf(__x); }
631 fmod(_Float32 __x, _Float32 __y)
632 { return __builtin_fmodf(__x, __y); }
635 frexp(_Float32 __x, int* __exp)
636 { return __builtin_frexpf(__x, __exp); }
639 ldexp(_Float32 __x, int __exp)
640 { return __builtin_ldexpf(__x, __exp); }
644 { return __builtin_logf(__x); }
648 { return __builtin_log10f(__x); }
651 modf(_Float32 __x, _Float32* __iptr)
653 float __i, __ret = __builtin_modff(__x, &__i);
659 pow(_Float32 __x, _Float32 __y)
660 { return __builtin_powf(__x, __y); }
664 { return __builtin_sinf(__x); }
668 { return __builtin_sinhf(__x); }
672 { return __builtin_sqrtf(__x); }
676 { return __builtin_tanf(__x); }
680 { return __builtin_tanhf(__x); }
683 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
686 { return __builtin_acos(__x); }
690 { return __builtin_asin(__x); }
694 { return __builtin_atan(__x); }
697 atan2(_Float64 __y, _Float64 __x)
698 { return __builtin_atan2(__y, __x); }
702 { return __builtin_ceil(__x); }
706 { return __builtin_cos(__x); }
710 { return __builtin_cosh(__x); }
714 { return __builtin_exp(__x); }
718 { return __builtin_fabs(__x); }
722 { return __builtin_floor(__x); }
725 fmod(_Float64 __x, _Float64 __y)
726 { return __builtin_fmod(__x, __y); }
729 frexp(_Float64 __x, int* __exp)
730 { return __builtin_frexp(__x, __exp); }
733 ldexp(_Float64 __x, int __exp)
734 { return __builtin_ldexp(__x, __exp); }
738 { return __builtin_log(__x); }
742 { return __builtin_log10(__x); }
745 modf(_Float64 __x, _Float64* __iptr)
747 double __i, __ret = __builtin_modf(__x, &__i);
753 pow(_Float64 __x, _Float64 __y)
754 { return __builtin_pow(__x, __y); }
758 { return __builtin_sin(__x); }
762 { return __builtin_sinh(__x); }
766 { return __builtin_sqrt(__x); }
770 { return __builtin_tan(__x); }
774 { return __builtin_tanh(__x); }
777 #if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
780 { return __builtin_acosl(__x); }
784 { return __builtin_asinl(__x); }
788 { return __builtin_atanl(__x); }
791 atan2(_Float128 __y, _Float128 __x)
792 { return __builtin_atan2l(__y, __x); }
796 { return __builtin_ceill(__x); }
800 { return __builtin_cosl(__x); }
804 { return __builtin_coshl(__x); }
808 { return __builtin_expl(__x); }
812 { return __builtin_fabsl(__x); }
816 { return __builtin_floorl(__x); }
819 fmod(_Float128 __x, _Float128 __y)
820 { return __builtin_fmodl(__x, __y); }
823 frexp(_Float128 __x, int* __exp)
824 { return __builtin_frexpl(__x, __exp); }
827 ldexp(_Float128 __x, int __exp)
828 { return __builtin_ldexpl(__x, __exp); }
832 { return __builtin_logl(__x); }
836 { return __builtin_log10l(__x); }
839 modf(_Float128 __x, _Float128* __iptr)
841 long double __i, __ret = __builtin_modfl(__x, &__i);
847 pow(_Float128 __x, _Float128 __y)
848 { return __builtin_powl(__x, __y); }
852 { return __builtin_sinl(__x); }
856 { return __builtin_sinhl(__x); }
860 { return __builtin_sqrtl(__x); }
864 { return __builtin_tanl(__x); }
868 { return __builtin_tanhl(__x); }
869 #elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
872 { return __builtin_acosf128(__x); }
876 { return __builtin_asinf128(__x); }
880 { return __builtin_atanf128(__x); }
883 atan2(_Float128 __y, _Float128 __x)
884 { return __builtin_atan2f128(__y, __x); }
888 { return __builtin_ceilf128(__x); }
892 { return __builtin_cosf128(__x); }
896 { return __builtin_coshf128(__x); }
900 { return __builtin_expf128(__x); }
904 { return __builtin_fabsf128(__x); }
908 { return __builtin_floorf128(__x); }
911 fmod(_Float128 __x, _Float128 __y)
912 { return __builtin_fmodf128(__x, __y); }
915 frexp(_Float128 __x, int* __exp)
916 { return __builtin_frexpf128(__x, __exp); }
919 ldexp(_Float128 __x, int __exp)
920 { return __builtin_ldexpf128(__x, __exp); }
924 { return __builtin_logf128(__x); }
928 { return __builtin_log10f128(__x); }
931 modf(_Float128 __x, _Float128* __iptr)
932 { return __builtin_modff128(__x, __iptr); }
935 pow(_Float128 __x, _Float128 __y)
936 { return __builtin_powf128(__x, __y); }
940 { return __builtin_sinf128(__x); }
944 { return __builtin_sinhf128(__x); }
948 { return __builtin_sqrtf128(__x); }
952 { return __builtin_tanf128(__x); }
956 { return __builtin_tanhf128(__x); }
959 #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
960 constexpr __gnu_cxx::__bfloat16_t
961 acos(__gnu_cxx::__bfloat16_t __x)
962 { return __gnu_cxx::__bfloat16_t(__builtin_acosf(__x)); }
964 constexpr __gnu_cxx::__bfloat16_t
965 asin(__gnu_cxx::__bfloat16_t __x)
966 { return __gnu_cxx::__bfloat16_t(__builtin_asinf(__x)); }
968 constexpr __gnu_cxx::__bfloat16_t
969 atan(__gnu_cxx::__bfloat16_t __x)
970 { return __gnu_cxx::__bfloat16_t(__builtin_atanf(__x)); }
972 constexpr __gnu_cxx::__bfloat16_t
973 atan2(__gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __x)
974 { return __gnu_cxx::__bfloat16_t(__builtin_atan2f(__y, __x)); }
976 constexpr __gnu_cxx::__bfloat16_t
977 ceil(__gnu_cxx::__bfloat16_t __x)
978 { return __gnu_cxx::__bfloat16_t(__builtin_ceilf(__x)); }
980 constexpr __gnu_cxx::__bfloat16_t
981 cos(__gnu_cxx::__bfloat16_t __x)
982 { return __gnu_cxx::__bfloat16_t(__builtin_cosf(__x)); }
984 constexpr __gnu_cxx::__bfloat16_t
985 cosh(__gnu_cxx::__bfloat16_t __x)
986 { return __gnu_cxx::__bfloat16_t(__builtin_coshf(__x)); }
988 constexpr __gnu_cxx::__bfloat16_t
989 exp(__gnu_cxx::__bfloat16_t __x)
990 { return __gnu_cxx::__bfloat16_t(__builtin_expf(__x)); }
992 constexpr __gnu_cxx::__bfloat16_t
993 fabs(__gnu_cxx::__bfloat16_t __x)
994 { return __gnu_cxx::__bfloat16_t(__builtin_fabsf(__x)); }
996 constexpr __gnu_cxx::__bfloat16_t
997 floor(__gnu_cxx::__bfloat16_t __x)
998 { return __gnu_cxx::__bfloat16_t(__builtin_floorf(__x)); }
1000 constexpr __gnu_cxx::__bfloat16_t
1001 fmod(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1002 { return __gnu_cxx::__bfloat16_t(__builtin_fmodf(__x, __y)); }
1004 inline __gnu_cxx::__bfloat16_t
1005 frexp(__gnu_cxx::__bfloat16_t __x, int* __exp)
1006 { return __gnu_cxx::__bfloat16_t(__builtin_frexpf(__x, __exp)); }
1008 constexpr __gnu_cxx::__bfloat16_t
1009 ldexp(__gnu_cxx::__bfloat16_t __x, int __exp)
1010 { return __gnu_cxx::__bfloat16_t(__builtin_ldexpf(__x, __exp)); }
1012 constexpr __gnu_cxx::__bfloat16_t
1013 log(__gnu_cxx::__bfloat16_t __x)
1014 { return __gnu_cxx::__bfloat16_t(__builtin_logf(__x)); }
1016 constexpr __gnu_cxx::__bfloat16_t
1017 log10(__gnu_cxx::__bfloat16_t __x)
1018 { return __gnu_cxx::__bfloat16_t(__builtin_log10f(__x)); }
1020 inline __gnu_cxx::__bfloat16_t
1021 modf(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t* __iptr)
1023 float __i, __ret = __builtin_modff(__x, &__i);
1024 *__iptr = __gnu_cxx::__bfloat16_t(__i);
1025 return __gnu_cxx::__bfloat16_t(__ret);
1028 constexpr __gnu_cxx::__bfloat16_t
1029 pow(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1030 { return __gnu_cxx::__bfloat16_t(__builtin_powf(__x, __y)); }
1032 constexpr __gnu_cxx::__bfloat16_t
1033 sin(__gnu_cxx::__bfloat16_t __x)
1034 { return __gnu_cxx::__bfloat16_t(__builtin_sinf(__x)); }
1036 constexpr __gnu_cxx::__bfloat16_t
1037 sinh(__gnu_cxx::__bfloat16_t __x)
1038 { return __gnu_cxx::__bfloat16_t(__builtin_sinhf(__x)); }
1040 constexpr __gnu_cxx::__bfloat16_t
1041 sqrt(__gnu_cxx::__bfloat16_t __x)
1042 { return __gnu_cxx::__bfloat16_t(__builtin_sqrtf(__x)); }
1044 constexpr __gnu_cxx::__bfloat16_t
1045 tan(__gnu_cxx::__bfloat16_t __x)
1046 { return __gnu_cxx::__bfloat16_t(__builtin_tanf(__x)); }
1048 constexpr __gnu_cxx::__bfloat16_t
1049 tanh(__gnu_cxx::__bfloat16_t __x)
1050 { return __gnu_cxx::__bfloat16_t(__builtin_tanhf(__x)); }
1053 template<typename _Tp, typename _Up>
1054 inline _GLIBCXX_CONSTEXPR
1055 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1056 atan2(_Tp __y, _Up __x)
1058 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1059 return atan2(__type(__y), __type(__x));
1062 template<typename _Tp, typename _Up>
1063 inline _GLIBCXX_CONSTEXPR
1064 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1065 fmod(_Tp __x, _Up __y)
1067 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1068 return fmod(__type(__x), __type(__y));
1071 template<typename _Tp, typename _Up>
1072 inline _GLIBCXX_CONSTEXPR
1073 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1074 pow(_Tp __x, _Up __y)
1076 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1077 return pow(__type(__x), __type(__y));
1080 #if _GLIBCXX_USE_C99_MATH
1081 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
1083 // These are possible macros imported from C99-land.
1091 #undef isgreaterequal
1094 #undef islessgreater
1097 #if __cplusplus >= 201103L
1099 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1101 fpclassify(float __x)
1102 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1103 FP_SUBNORMAL, FP_ZERO, __x); }
1106 fpclassify(double __x)
1107 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1108 FP_SUBNORMAL, FP_ZERO, __x); }
1111 fpclassify(long double __x)
1112 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1113 FP_SUBNORMAL, FP_ZERO, __x); }
1116 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1117 template<typename _Tp>
1118 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1121 { return __x != 0 ? FP_NORMAL : FP_ZERO; }
1124 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1127 { return __builtin_isfinite(__x); }
1130 isfinite(double __x)
1131 { return __builtin_isfinite(__x); }
1134 isfinite(long double __x)
1135 { return __builtin_isfinite(__x); }
1138 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1139 template<typename _Tp>
1140 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1146 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1149 { return __builtin_isinf(__x); }
1151 #if _GLIBCXX_HAVE_OBSOLETE_ISINF \
1152 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
1157 { return __builtin_isinf(__x); }
1161 isinf(long double __x)
1162 { return __builtin_isinf(__x); }
1165 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1166 template<typename _Tp>
1167 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1173 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1176 { return __builtin_isnan(__x); }
1178 #if _GLIBCXX_HAVE_OBSOLETE_ISNAN \
1179 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
1184 { return __builtin_isnan(__x); }
1188 isnan(long double __x)
1189 { return __builtin_isnan(__x); }
1192 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1193 template<typename _Tp>
1194 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1200 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1203 { return __builtin_isnormal(__x); }
1206 isnormal(double __x)
1207 { return __builtin_isnormal(__x); }
1210 isnormal(long double __x)
1211 { return __builtin_isnormal(__x); }
1214 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1215 template<typename _Tp>
1216 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1219 { return __x != 0 ? true : false; }
1222 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1223 // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic.
1226 { return __builtin_signbit(__x); }
1230 { return __builtin_signbit(__x); }
1233 signbit(long double __x)
1234 { return __builtin_signbit(__x); }
1237 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1238 template<typename _Tp>
1239 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1242 { return __x < 0 ? true : false; }
1245 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1247 isgreater(float __x, float __y)
1248 { return __builtin_isgreater(__x, __y); }
1251 isgreater(double __x, double __y)
1252 { return __builtin_isgreater(__x, __y); }
1255 isgreater(long double __x, long double __y)
1256 { return __builtin_isgreater(__x, __y); }
1259 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1260 template<typename _Tp, typename _Up>
1262 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1263 && __is_arithmetic<_Up>::__value), bool>::__type
1264 isgreater(_Tp __x, _Up __y)
1266 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1267 return __builtin_isgreater(__type(__x), __type(__y));
1271 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1273 isgreaterequal(float __x, float __y)
1274 { return __builtin_isgreaterequal(__x, __y); }
1277 isgreaterequal(double __x, double __y)
1278 { return __builtin_isgreaterequal(__x, __y); }
1281 isgreaterequal(long double __x, long double __y)
1282 { return __builtin_isgreaterequal(__x, __y); }
1285 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1286 template<typename _Tp, typename _Up>
1288 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1289 && __is_arithmetic<_Up>::__value), bool>::__type
1290 isgreaterequal(_Tp __x, _Up __y)
1292 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1293 return __builtin_isgreaterequal(__type(__x), __type(__y));
1297 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1299 isless(float __x, float __y)
1300 { return __builtin_isless(__x, __y); }
1303 isless(double __x, double __y)
1304 { return __builtin_isless(__x, __y); }
1307 isless(long double __x, long double __y)
1308 { return __builtin_isless(__x, __y); }
1311 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1312 template<typename _Tp, typename _Up>
1314 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1315 && __is_arithmetic<_Up>::__value), bool>::__type
1316 isless(_Tp __x, _Up __y)
1318 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1319 return __builtin_isless(__type(__x), __type(__y));
1323 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1325 islessequal(float __x, float __y)
1326 { return __builtin_islessequal(__x, __y); }
1329 islessequal(double __x, double __y)
1330 { return __builtin_islessequal(__x, __y); }
1333 islessequal(long double __x, long double __y)
1334 { return __builtin_islessequal(__x, __y); }
1337 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1338 template<typename _Tp, typename _Up>
1340 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1341 && __is_arithmetic<_Up>::__value), bool>::__type
1342 islessequal(_Tp __x, _Up __y)
1344 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1345 return __builtin_islessequal(__type(__x), __type(__y));
1349 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1351 islessgreater(float __x, float __y)
1352 { return __builtin_islessgreater(__x, __y); }
1355 islessgreater(double __x, double __y)
1356 { return __builtin_islessgreater(__x, __y); }
1359 islessgreater(long double __x, long double __y)
1360 { return __builtin_islessgreater(__x, __y); }
1363 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1364 template<typename _Tp, typename _Up>
1366 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1367 && __is_arithmetic<_Up>::__value), bool>::__type
1368 islessgreater(_Tp __x, _Up __y)
1370 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1371 return __builtin_islessgreater(__type(__x), __type(__y));
1375 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1377 isunordered(float __x, float __y)
1378 { return __builtin_isunordered(__x, __y); }
1381 isunordered(double __x, double __y)
1382 { return __builtin_isunordered(__x, __y); }
1385 isunordered(long double __x, long double __y)
1386 { return __builtin_isunordered(__x, __y); }
1389 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1390 template<typename _Tp, typename _Up>
1392 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1393 && __is_arithmetic<_Up>::__value), bool>::__type
1394 isunordered(_Tp __x, _Up __y)
1396 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1397 return __builtin_isunordered(__type(__x), __type(__y));
1403 template<typename _Tp>
1404 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1408 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1409 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1410 FP_SUBNORMAL, FP_ZERO, __type(__f));
1413 template<typename _Tp>
1414 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1418 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1419 return __builtin_isfinite(__type(__f));
1422 template<typename _Tp>
1423 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1427 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1428 return __builtin_isinf(__type(__f));
1431 template<typename _Tp>
1432 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1436 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1437 return __builtin_isnan(__type(__f));
1440 template<typename _Tp>
1441 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1445 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1446 return __builtin_isnormal(__type(__f));
1449 template<typename _Tp>
1450 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1454 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1455 return __builtin_signbit(__type(__f));
1458 template<typename _Tp>
1459 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1461 isgreater(_Tp __f1, _Tp __f2)
1463 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1464 return __builtin_isgreater(__type(__f1), __type(__f2));
1467 template<typename _Tp>
1468 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1470 isgreaterequal(_Tp __f1, _Tp __f2)
1472 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1473 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
1476 template<typename _Tp>
1477 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1479 isless(_Tp __f1, _Tp __f2)
1481 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1482 return __builtin_isless(__type(__f1), __type(__f2));
1485 template<typename _Tp>
1486 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1488 islessequal(_Tp __f1, _Tp __f2)
1490 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1491 return __builtin_islessequal(__type(__f1), __type(__f2));
1494 template<typename _Tp>
1495 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1497 islessgreater(_Tp __f1, _Tp __f2)
1499 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1500 return __builtin_islessgreater(__type(__f1), __type(__f2));
1503 template<typename _Tp>
1504 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1506 isunordered(_Tp __f1, _Tp __f2)
1508 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1509 return __builtin_isunordered(__type(__f1), __type(__f2));
1514 #ifdef __STDCPP_FLOAT16_T__
1516 fpclassify(_Float16 __x)
1517 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1518 FP_SUBNORMAL, FP_ZERO, __x); }
1521 isfinite(_Float16 __x)
1522 { return __builtin_isfinite(__x); }
1526 { return __builtin_isinf(__x); }
1530 { return __builtin_isnan(__x); }
1533 isnormal(_Float16 __x)
1534 { return __builtin_isnormal(__x); }
1537 signbit(_Float16 __x)
1538 { return __builtin_signbit(__x); }
1541 isgreater(_Float16 __x, _Float16 __y)
1542 { return __builtin_isgreater(__x, __y); }
1545 isgreaterequal(_Float16 __x, _Float16 __y)
1546 { return __builtin_isgreaterequal(__x, __y); }
1549 isless(_Float16 __x, _Float16 __y)
1550 { return __builtin_isless(__x, __y); }
1553 islessequal(_Float16 __x, _Float16 __y)
1554 { return __builtin_islessequal(__x, __y); }
1557 islessgreater(_Float16 __x, _Float16 __y)
1558 { return __builtin_islessgreater(__x, __y); }
1561 isunordered(_Float16 __x, _Float16 __y)
1562 { return __builtin_isunordered(__x, __y); }
1565 #ifdef __STDCPP_FLOAT32_T__
1567 fpclassify(_Float32 __x)
1568 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1569 FP_SUBNORMAL, FP_ZERO, __x); }
1572 isfinite(_Float32 __x)
1573 { return __builtin_isfinite(__x); }
1577 { return __builtin_isinf(__x); }
1581 { return __builtin_isnan(__x); }
1584 isnormal(_Float32 __x)
1585 { return __builtin_isnormal(__x); }
1588 signbit(_Float32 __x)
1589 { return __builtin_signbit(__x); }
1592 isgreater(_Float32 __x, _Float32 __y)
1593 { return __builtin_isgreater(__x, __y); }
1596 isgreaterequal(_Float32 __x, _Float32 __y)
1597 { return __builtin_isgreaterequal(__x, __y); }
1600 isless(_Float32 __x, _Float32 __y)
1601 { return __builtin_isless(__x, __y); }
1604 islessequal(_Float32 __x, _Float32 __y)
1605 { return __builtin_islessequal(__x, __y); }
1608 islessgreater(_Float32 __x, _Float32 __y)
1609 { return __builtin_islessgreater(__x, __y); }
1612 isunordered(_Float32 __x, _Float32 __y)
1613 { return __builtin_isunordered(__x, __y); }
1616 #ifdef __STDCPP_FLOAT64_T__
1618 fpclassify(_Float64 __x)
1619 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1620 FP_SUBNORMAL, FP_ZERO, __x); }
1623 isfinite(_Float64 __x)
1624 { return __builtin_isfinite(__x); }
1628 { return __builtin_isinf(__x); }
1632 { return __builtin_isnan(__x); }
1635 isnormal(_Float64 __x)
1636 { return __builtin_isnormal(__x); }
1639 signbit(_Float64 __x)
1640 { return __builtin_signbit(__x); }
1643 isgreater(_Float64 __x, _Float64 __y)
1644 { return __builtin_isgreater(__x, __y); }
1647 isgreaterequal(_Float64 __x, _Float64 __y)
1648 { return __builtin_isgreaterequal(__x, __y); }
1651 isless(_Float64 __x, _Float64 __y)
1652 { return __builtin_isless(__x, __y); }
1655 islessequal(_Float64 __x, _Float64 __y)
1656 { return __builtin_islessequal(__x, __y); }
1659 islessgreater(_Float64 __x, _Float64 __y)
1660 { return __builtin_islessgreater(__x, __y); }
1663 isunordered(_Float64 __x, _Float64 __y)
1664 { return __builtin_isunordered(__x, __y); }
1667 #ifdef __STDCPP_FLOAT128_T__
1669 fpclassify(_Float128 __x)
1670 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1671 FP_SUBNORMAL, FP_ZERO, __x); }
1674 isfinite(_Float128 __x)
1675 { return __builtin_isfinite(__x); }
1678 isinf(_Float128 __x)
1679 { return __builtin_isinf(__x); }
1682 isnan(_Float128 __x)
1683 { return __builtin_isnan(__x); }
1686 isnormal(_Float128 __x)
1687 { return __builtin_isnormal(__x); }
1690 signbit(_Float128 __x)
1691 { return __builtin_signbit(__x); }
1694 isgreater(_Float128 __x, _Float128 __y)
1695 { return __builtin_isgreater(__x, __y); }
1698 isgreaterequal(_Float128 __x, _Float128 __y)
1699 { return __builtin_isgreaterequal(__x, __y); }
1702 isless(_Float128 __x, _Float128 __y)
1703 { return __builtin_isless(__x, __y); }
1706 islessequal(_Float128 __x, _Float128 __y)
1707 { return __builtin_islessequal(__x, __y); }
1710 islessgreater(_Float128 __x, _Float128 __y)
1711 { return __builtin_islessgreater(__x, __y); }
1714 isunordered(_Float128 __x, _Float128 __y)
1715 { return __builtin_isunordered(__x, __y); }
1718 #ifdef __STDCPP_BFLOAT16_T__
1720 fpclassify(__gnu_cxx::__bfloat16_t __x)
1721 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1722 FP_SUBNORMAL, FP_ZERO, __x); }
1725 isfinite(__gnu_cxx::__bfloat16_t __x)
1726 { return __builtin_isfinite(__x); }
1729 isinf(__gnu_cxx::__bfloat16_t __x)
1730 { return __builtin_isinf(__x); }
1733 isnan(__gnu_cxx::__bfloat16_t __x)
1734 { return __builtin_isnan(__x); }
1737 isnormal(__gnu_cxx::__bfloat16_t __x)
1738 { return __builtin_isnormal(__x); }
1741 signbit(__gnu_cxx::__bfloat16_t __x)
1742 { return __builtin_signbit(__x); }
1745 isgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1746 { return __builtin_isgreater(__x, __y); }
1749 isgreaterequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1750 { return __builtin_isgreaterequal(__x, __y); }
1753 isless(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1754 { return __builtin_isless(__x, __y); }
1757 islessequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1758 { return __builtin_islessequal(__x, __y); }
1761 islessgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1762 { return __builtin_islessgreater(__x, __y); }
1765 isunordered(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1766 { return __builtin_isunordered(__x, __y); }
1769 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
1770 #endif /* _GLIBCXX_USE_C99_MATH */
1772 #if __cplusplus >= 201103L
1819 #ifdef _GLIBCXX_HAVE_ACOSF
1822 #ifdef _GLIBCXX_HAVE_ACOSL
1826 #ifdef _GLIBCXX_HAVE_ASINF
1829 #ifdef _GLIBCXX_HAVE_ASINL
1833 #ifdef _GLIBCXX_HAVE_ATANF
1836 #ifdef _GLIBCXX_HAVE_ATANL
1840 #ifdef _GLIBCXX_HAVE_ATAN2F
1843 #ifdef _GLIBCXX_HAVE_ATAN2L
1847 #ifdef _GLIBCXX_HAVE_CEILF
1850 #ifdef _GLIBCXX_HAVE_CEILL
1854 #ifdef _GLIBCXX_HAVE_COSF
1857 #ifdef _GLIBCXX_HAVE_COSL
1861 #ifdef _GLIBCXX_HAVE_COSHF
1864 #ifdef _GLIBCXX_HAVE_COSHL
1868 #ifdef _GLIBCXX_HAVE_EXPF
1871 #ifdef _GLIBCXX_HAVE_EXPL
1875 #ifdef _GLIBCXX_HAVE_FABSF
1878 #ifdef _GLIBCXX_HAVE_FABSL
1882 #ifdef _GLIBCXX_HAVE_FLOORF
1885 #ifdef _GLIBCXX_HAVE_FLOORL
1889 #ifdef _GLIBCXX_HAVE_FMODF
1892 #ifdef _GLIBCXX_HAVE_FMODL
1896 #ifdef _GLIBCXX_HAVE_FREXPF
1899 #ifdef _GLIBCXX_HAVE_FREXPL
1903 #ifdef _GLIBCXX_HAVE_LDEXPF
1906 #ifdef _GLIBCXX_HAVE_LDEXPL
1910 #ifdef _GLIBCXX_HAVE_LOGF
1913 #ifdef _GLIBCXX_HAVE_LOGL
1917 #ifdef _GLIBCXX_HAVE_LOG10F
1920 #ifdef _GLIBCXX_HAVE_LOG10L
1924 #ifdef _GLIBCXX_HAVE_MODFF
1927 #ifdef _GLIBCXX_HAVE_MODFL
1931 #ifdef _GLIBCXX_HAVE_POWF
1934 #ifdef _GLIBCXX_HAVE_POWL
1938 #ifdef _GLIBCXX_HAVE_SINF
1941 #ifdef _GLIBCXX_HAVE_SINL
1945 #ifdef _GLIBCXX_HAVE_SINHF
1948 #ifdef _GLIBCXX_HAVE_SINHL
1952 #ifdef _GLIBCXX_HAVE_SQRTF
1955 #ifdef _GLIBCXX_HAVE_SQRTL
1959 #ifdef _GLIBCXX_HAVE_TANF
1962 #ifdef _GLIBCXX_HAVE_TANL
1966 #ifdef _GLIBCXX_HAVE_TANHF
1969 #ifdef _GLIBCXX_HAVE_TANHL
1973 #ifdef _GLIBCXX_USE_C99_MATH_FUNCS
2023 #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
2083 #ifdef _GLIBCXX_HAVE_C99_FLT_EVAL_TYPES
2154 #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
2197 using ::nexttowardf;
2198 using ::nexttowardl;
2232 /// Additional overloads.
2233 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2236 { return __builtin_acoshf(__x); }
2238 constexpr long double
2239 acosh(long double __x)
2240 { return __builtin_acoshl(__x); }
2243 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2244 template<typename _Tp>
2245 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2248 { return __builtin_acosh(__x); }
2251 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2254 { return __builtin_asinhf(__x); }
2256 constexpr long double
2257 asinh(long double __x)
2258 { return __builtin_asinhl(__x); }
2261 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2262 template<typename _Tp>
2263 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2266 { return __builtin_asinh(__x); }
2269 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2272 { return __builtin_atanhf(__x); }
2274 constexpr long double
2275 atanh(long double __x)
2276 { return __builtin_atanhl(__x); }
2279 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2280 template<typename _Tp>
2281 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2284 { return __builtin_atanh(__x); }
2287 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2290 { return __builtin_cbrtf(__x); }
2292 constexpr long double
2293 cbrt(long double __x)
2294 { return __builtin_cbrtl(__x); }
2297 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2298 template<typename _Tp>
2299 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2302 { return __builtin_cbrt(__x); }
2305 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2307 copysign(float __x, float __y)
2308 { return __builtin_copysignf(__x, __y); }
2310 constexpr long double
2311 copysign(long double __x, long double __y)
2312 { return __builtin_copysignl(__x, __y); }
2315 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2318 { return __builtin_erff(__x); }
2320 constexpr long double
2321 erf(long double __x)
2322 { return __builtin_erfl(__x); }
2325 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2326 template<typename _Tp>
2327 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2330 { return __builtin_erf(__x); }
2333 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2336 { return __builtin_erfcf(__x); }
2338 constexpr long double
2339 erfc(long double __x)
2340 { return __builtin_erfcl(__x); }
2343 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2344 template<typename _Tp>
2345 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2348 { return __builtin_erfc(__x); }
2351 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2354 { return __builtin_exp2f(__x); }
2356 constexpr long double
2357 exp2(long double __x)
2358 { return __builtin_exp2l(__x); }
2361 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2362 template<typename _Tp>
2363 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2366 { return __builtin_exp2(__x); }
2369 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2372 { return __builtin_expm1f(__x); }
2374 constexpr long double
2375 expm1(long double __x)
2376 { return __builtin_expm1l(__x); }
2379 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2380 template<typename _Tp>
2381 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2384 { return __builtin_expm1(__x); }
2387 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2389 fdim(float __x, float __y)
2390 { return __builtin_fdimf(__x, __y); }
2392 constexpr long double
2393 fdim(long double __x, long double __y)
2394 { return __builtin_fdiml(__x, __y); }
2397 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2399 fma(float __x, float __y, float __z)
2400 { return __builtin_fmaf(__x, __y, __z); }
2402 constexpr long double
2403 fma(long double __x, long double __y, long double __z)
2404 { return __builtin_fmal(__x, __y, __z); }
2407 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2409 fmax(float __x, float __y)
2410 { return __builtin_fmaxf(__x, __y); }
2412 constexpr long double
2413 fmax(long double __x, long double __y)
2414 { return __builtin_fmaxl(__x, __y); }
2417 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2419 fmin(float __x, float __y)
2420 { return __builtin_fminf(__x, __y); }
2422 constexpr long double
2423 fmin(long double __x, long double __y)
2424 { return __builtin_fminl(__x, __y); }
2427 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2429 hypot(float __x, float __y)
2430 { return __builtin_hypotf(__x, __y); }
2432 constexpr long double
2433 hypot(long double __x, long double __y)
2434 { return __builtin_hypotl(__x, __y); }
2437 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2440 { return __builtin_ilogbf(__x); }
2443 ilogb(long double __x)
2444 { return __builtin_ilogbl(__x); }
2447 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2448 template<typename _Tp>
2450 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2453 { return __builtin_ilogb(__x); }
2456 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2459 { return __builtin_lgammaf(__x); }
2461 constexpr long double
2462 lgamma(long double __x)
2463 { return __builtin_lgammal(__x); }
2466 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2467 template<typename _Tp>
2468 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2471 { return __builtin_lgamma(__x); }
2474 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2477 { return __builtin_llrintf(__x); }
2480 llrint(long double __x)
2481 { return __builtin_llrintl(__x); }
2484 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2485 template<typename _Tp>
2486 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2489 { return __builtin_llrint(__x); }
2492 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2495 { return __builtin_llroundf(__x); }
2498 llround(long double __x)
2499 { return __builtin_llroundl(__x); }
2502 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2503 template<typename _Tp>
2504 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2507 { return __builtin_llround(__x); }
2510 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2513 { return __builtin_log1pf(__x); }
2515 constexpr long double
2516 log1p(long double __x)
2517 { return __builtin_log1pl(__x); }
2520 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2521 template<typename _Tp>
2522 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2525 { return __builtin_log1p(__x); }
2528 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2532 { return __builtin_log2f(__x); }
2534 constexpr long double
2535 log2(long double __x)
2536 { return __builtin_log2l(__x); }
2539 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2540 template<typename _Tp>
2541 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2544 { return __builtin_log2(__x); }
2547 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2550 { return __builtin_logbf(__x); }
2552 constexpr long double
2553 logb(long double __x)
2554 { return __builtin_logbl(__x); }
2557 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2558 template<typename _Tp>
2559 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2562 { return __builtin_logb(__x); }
2565 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2568 { return __builtin_lrintf(__x); }
2571 lrint(long double __x)
2572 { return __builtin_lrintl(__x); }
2575 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2576 template<typename _Tp>
2577 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2580 { return __builtin_lrint(__x); }
2583 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2586 { return __builtin_lroundf(__x); }
2589 lround(long double __x)
2590 { return __builtin_lroundl(__x); }
2593 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2594 template<typename _Tp>
2595 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2598 { return __builtin_lround(__x); }
2601 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2603 nearbyint(float __x)
2604 { return __builtin_nearbyintf(__x); }
2606 constexpr long double
2607 nearbyint(long double __x)
2608 { return __builtin_nearbyintl(__x); }
2611 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2612 template<typename _Tp>
2613 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2616 { return __builtin_nearbyint(__x); }
2619 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2621 nextafter(float __x, float __y)
2622 { return __builtin_nextafterf(__x, __y); }
2624 constexpr long double
2625 nextafter(long double __x, long double __y)
2626 { return __builtin_nextafterl(__x, __y); }
2629 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2631 nexttoward(float __x, long double __y)
2632 { return __builtin_nexttowardf(__x, __y); }
2634 constexpr long double
2635 nexttoward(long double __x, long double __y)
2636 { return __builtin_nexttowardl(__x, __y); }
2639 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2640 template<typename _Tp>
2641 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2643 nexttoward(_Tp __x, long double __y)
2644 { return __builtin_nexttoward(__x, __y); }
2647 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2649 remainder(float __x, float __y)
2650 { return __builtin_remainderf(__x, __y); }
2652 constexpr long double
2653 remainder(long double __x, long double __y)
2654 { return __builtin_remainderl(__x, __y); }
2657 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2659 remquo(float __x, float __y, int* __pquo)
2660 { return __builtin_remquof(__x, __y, __pquo); }
2663 remquo(long double __x, long double __y, int* __pquo)
2664 { return __builtin_remquol(__x, __y, __pquo); }
2667 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2670 { return __builtin_rintf(__x); }
2672 constexpr long double
2673 rint(long double __x)
2674 { return __builtin_rintl(__x); }
2677 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2678 template<typename _Tp>
2679 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2682 { return __builtin_rint(__x); }
2685 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2688 { return __builtin_roundf(__x); }
2690 constexpr long double
2691 round(long double __x)
2692 { return __builtin_roundl(__x); }
2695 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2696 template<typename _Tp>
2697 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2700 { return __builtin_round(__x); }
2703 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2705 scalbln(float __x, long __ex)
2706 { return __builtin_scalblnf(__x, __ex); }
2708 constexpr long double
2709 scalbln(long double __x, long __ex)
2710 { return __builtin_scalblnl(__x, __ex); }
2713 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2714 template<typename _Tp>
2715 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2717 scalbln(_Tp __x, long __ex)
2718 { return __builtin_scalbln(__x, __ex); }
2721 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2723 scalbn(float __x, int __ex)
2724 { return __builtin_scalbnf(__x, __ex); }
2726 constexpr long double
2727 scalbn(long double __x, int __ex)
2728 { return __builtin_scalbnl(__x, __ex); }
2731 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2732 template<typename _Tp>
2733 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2735 scalbn(_Tp __x, int __ex)
2736 { return __builtin_scalbn(__x, __ex); }
2739 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2742 { return __builtin_tgammaf(__x); }
2744 constexpr long double
2745 tgamma(long double __x)
2746 { return __builtin_tgammal(__x); }
2749 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2750 template<typename _Tp>
2751 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2754 { return __builtin_tgamma(__x); }
2757 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2760 { return __builtin_truncf(__x); }
2762 constexpr long double
2763 trunc(long double __x)
2764 { return __builtin_truncl(__x); }
2767 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2768 template<typename _Tp>
2769 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2772 { return __builtin_trunc(__x); }
2775 #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2778 { return _Float16(__builtin_acoshf(__x)); }
2782 { return _Float16(__builtin_asinhf(__x)); }
2786 { return _Float16(__builtin_atanhf(__x)); }
2790 { return _Float16(__builtin_cbrtf(__x)); }
2793 copysign(_Float16 __x, _Float16 __y)
2794 { return __builtin_copysignf16(__x, __y); }
2798 { return _Float16(__builtin_erff(__x)); }
2802 { return _Float16(__builtin_erfcf(__x)); }
2806 { return _Float16(__builtin_exp2f(__x)); }
2810 { return _Float16(__builtin_expm1f(__x)); }
2813 fdim(_Float16 __x, _Float16 __y)
2814 { return _Float16(__builtin_fdimf(__x, __y)); }
2817 fma(_Float16 __x, _Float16 __y, _Float16 __z)
2818 { return _Float16(__builtin_fmaf(__x, __y, __z)); }
2821 fmax(_Float16 __x, _Float16 __y)
2822 { return _Float16(__builtin_fmaxf(__x, __y)); }
2825 fmin(_Float16 __x, _Float16 __y)
2826 { return _Float16(__builtin_fminf(__x, __y)); }
2829 hypot(_Float16 __x, _Float16 __y)
2830 { return _Float16(__builtin_hypotf(__x, __y)); }
2834 { return _Float16(__builtin_ilogbf(__x)); }
2837 lgamma(_Float16 __x)
2838 { return _Float16(__builtin_lgammaf(__x)); }
2841 llrint(_Float16 __x)
2842 { return _Float16(__builtin_llrintf(__x)); }
2845 llround(_Float16 __x)
2846 { return _Float16(__builtin_llroundf(__x)); }
2850 { return _Float16(__builtin_log1pf(__x)); }
2855 { return _Float16(__builtin_log2f(__x)); }
2859 { return _Float16(__builtin_logbf(__x)); }
2863 { return _Float16(__builtin_lrintf(__x)); }
2866 lround(_Float16 __x)
2867 { return _Float16(__builtin_lroundf(__x)); }
2870 nearbyint(_Float16 __x)
2871 { return _Float16(__builtin_nearbyintf(__x)); }
2874 nextafter(_Float16 __x, _Float16 __y)
2876 if (std::__is_constant_evaluated())
2877 return __builtin_nextafterf16(__x, __y);
2878 #ifdef __INT16_TYPE__
2879 using __float16_int_type = __INT16_TYPE__;
2881 using __float16_int_type = short int;
2883 __float16_int_type __hx, __hy, __ix, __iy;
2884 __builtin_memcpy(&__hx, &__x, sizeof(__x));
2885 __builtin_memcpy(&__hy, &__y, sizeof(__x));
2886 __ix = __hx & 0x7fff; // |x|
2887 __iy = __hy & 0x7fff; // |y|
2888 if (__ix > 0x7c00 || __iy > 0x7c00) // x or y is NaN
2891 return __y; // x == y, return y
2892 if (__ix == 0) // x == 0
2894 __hy = (__hy & 0x8000) | 1; // return +-__FLT16_DENORM_MIN__
2895 __builtin_memcpy(&__x, &__hy, sizeof(__x));
2896 __builtin_nextafterf(0.0f, 1.0f); // raise underflow
2899 if (__hx >= 0) // x > 0
2901 if (__hx > __hy) // x > y, x -= ulp
2903 else // x < y, x += ulp
2908 if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp
2910 else // x > y, x += ulp
2913 __hy = __hx & 0x7c00;
2915 __builtin_nextafterf(__FLT_MAX__, __builtin_inff()); // overflow
2916 else if (__hy < 0x0400)
2917 __builtin_nextafterf(__FLT_MIN__, 0.0f); // underflow
2918 __builtin_memcpy(&__x, &__hx, sizeof(__x));
2923 remainder(_Float16 __x, _Float16 __y)
2924 { return _Float16(__builtin_remainderf(__x, __y)); }
2927 remquo(_Float16 __x, _Float16 __y, int* __pquo)
2928 { return _Float16(__builtin_remquof(__x, __y, __pquo)); }
2932 { return _Float16(__builtin_rintf(__x)); }
2936 { return _Float16(__builtin_roundf(__x)); }
2939 scalbln(_Float16 __x, long __ex)
2940 { return _Float16(__builtin_scalblnf(__x, __ex)); }
2943 scalbn(_Float16 __x, int __ex)
2944 { return _Float16(__builtin_scalbnf(__x, __ex)); }
2947 tgamma(_Float16 __x)
2948 { return _Float16(__builtin_tgammaf(__x)); }
2952 { return _Float16(__builtin_truncf(__x)); }
2955 #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2958 { return __builtin_acoshf(__x); }
2962 { return __builtin_asinhf(__x); }
2966 { return __builtin_atanhf(__x); }
2970 { return __builtin_cbrtf(__x); }
2973 copysign(_Float32 __x, _Float32 __y)
2974 { return __builtin_copysignf(__x, __y); }
2978 { return __builtin_erff(__x); }
2982 { return __builtin_erfcf(__x); }
2986 { return __builtin_exp2f(__x); }
2990 { return __builtin_expm1f(__x); }
2993 fdim(_Float32 __x, _Float32 __y)
2994 { return __builtin_fdimf(__x, __y); }
2997 fma(_Float32 __x, _Float32 __y, _Float32 __z)
2998 { return __builtin_fmaf(__x, __y, __z); }
3001 fmax(_Float32 __x, _Float32 __y)
3002 { return __builtin_fmaxf(__x, __y); }
3005 fmin(_Float32 __x, _Float32 __y)
3006 { return __builtin_fminf(__x, __y); }
3009 hypot(_Float32 __x, _Float32 __y)
3010 { return __builtin_hypotf(__x, __y); }
3014 { return __builtin_ilogbf(__x); }
3017 lgamma(_Float32 __x)
3018 { return __builtin_lgammaf(__x); }
3021 llrint(_Float32 __x)
3022 { return __builtin_llrintf(__x); }
3025 llround(_Float32 __x)
3026 { return __builtin_llroundf(__x); }
3030 { return __builtin_log1pf(__x); }
3035 { return __builtin_log2f(__x); }
3039 { return __builtin_logbf(__x); }
3043 { return __builtin_lrintf(__x); }
3046 lround(_Float32 __x)
3047 { return __builtin_lroundf(__x); }
3050 nearbyint(_Float32 __x)
3051 { return __builtin_nearbyintf(__x); }
3054 nextafter(_Float32 __x, _Float32 __y)
3055 { return __builtin_nextafterf(__x, __y); }
3058 remainder(_Float32 __x, _Float32 __y)
3059 { return __builtin_remainderf(__x, __y); }
3062 remquo(_Float32 __x, _Float32 __y, int* __pquo)
3063 { return __builtin_remquof(__x, __y, __pquo); }
3067 { return __builtin_rintf(__x); }
3071 { return __builtin_roundf(__x); }
3074 scalbln(_Float32 __x, long __ex)
3075 { return __builtin_scalblnf(__x, __ex); }
3078 scalbn(_Float32 __x, int __ex)
3079 { return __builtin_scalbnf(__x, __ex); }
3082 tgamma(_Float32 __x)
3083 { return __builtin_tgammaf(__x); }
3087 { return __builtin_truncf(__x); }
3090 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
3093 { return __builtin_acosh(__x); }
3097 { return __builtin_asinh(__x); }
3101 { return __builtin_atanh(__x); }
3105 { return __builtin_cbrt(__x); }
3108 copysign(_Float64 __x, _Float64 __y)
3109 { return __builtin_copysign(__x, __y); }
3113 { return __builtin_erf(__x); }
3117 { return __builtin_erfc(__x); }
3121 { return __builtin_exp2(__x); }
3125 { return __builtin_expm1(__x); }
3128 fdim(_Float64 __x, _Float64 __y)
3129 { return __builtin_fdim(__x, __y); }
3132 fma(_Float64 __x, _Float64 __y, _Float64 __z)
3133 { return __builtin_fma(__x, __y, __z); }
3136 fmax(_Float64 __x, _Float64 __y)
3137 { return __builtin_fmax(__x, __y); }
3140 fmin(_Float64 __x, _Float64 __y)
3141 { return __builtin_fmin(__x, __y); }
3144 hypot(_Float64 __x, _Float64 __y)
3145 { return __builtin_hypot(__x, __y); }
3149 { return __builtin_ilogb(__x); }
3152 lgamma(_Float64 __x)
3153 { return __builtin_lgamma(__x); }
3156 llrint(_Float64 __x)
3157 { return __builtin_llrint(__x); }
3160 llround(_Float64 __x)
3161 { return __builtin_llround(__x); }
3165 { return __builtin_log1p(__x); }
3170 { return __builtin_log2(__x); }
3174 { return __builtin_logb(__x); }
3178 { return __builtin_lrint(__x); }
3181 lround(_Float64 __x)
3182 { return __builtin_lround(__x); }
3185 nearbyint(_Float64 __x)
3186 { return __builtin_nearbyint(__x); }
3189 nextafter(_Float64 __x, _Float64 __y)
3190 { return __builtin_nextafter(__x, __y); }
3193 remainder(_Float64 __x, _Float64 __y)
3194 { return __builtin_remainder(__x, __y); }
3197 remquo(_Float64 __x, _Float64 __y, int* __pquo)
3198 { return __builtin_remquo(__x, __y, __pquo); }
3202 { return __builtin_rint(__x); }
3206 { return __builtin_round(__x); }
3209 scalbln(_Float64 __x, long __ex)
3210 { return __builtin_scalbln(__x, __ex); }
3213 scalbn(_Float64 __x, int __ex)
3214 { return __builtin_scalbn(__x, __ex); }
3217 tgamma(_Float64 __x)
3218 { return __builtin_tgamma(__x); }
3222 { return __builtin_trunc(__x); }
3225 #if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
3227 acosh(_Float128 __x)
3228 { return __builtin_acoshl(__x); }
3231 asinh(_Float128 __x)
3232 { return __builtin_asinhl(__x); }
3235 atanh(_Float128 __x)
3236 { return __builtin_atanhl(__x); }
3240 { return __builtin_cbrtl(__x); }
3243 copysign(_Float128 __x, _Float128 __y)
3244 { return __builtin_copysignl(__x, __y); }
3248 { return __builtin_erfl(__x); }
3252 { return __builtin_erfcl(__x); }
3256 { return __builtin_exp2l(__x); }
3259 expm1(_Float128 __x)
3260 { return __builtin_expm1l(__x); }
3263 fdim(_Float128 __x, _Float128 __y)
3264 { return __builtin_fdiml(__x, __y); }
3267 fma(_Float128 __x, _Float128 __y, _Float128 __z)
3268 { return __builtin_fmal(__x, __y, __z); }
3271 fmax(_Float128 __x, _Float128 __y)
3272 { return __builtin_fmaxl(__x, __y); }
3275 fmin(_Float128 __x, _Float128 __y)
3276 { return __builtin_fminl(__x, __y); }
3279 hypot(_Float128 __x, _Float128 __y)
3280 { return __builtin_hypotl(__x, __y); }
3283 ilogb(_Float128 __x)
3284 { return __builtin_ilogbl(__x); }
3287 lgamma(_Float128 __x)
3288 { return __builtin_lgammal(__x); }
3291 llrint(_Float128 __x)
3292 { return __builtin_llrintl(__x); }
3295 llround(_Float128 __x)
3296 { return __builtin_llroundl(__x); }
3299 log1p(_Float128 __x)
3300 { return __builtin_log1pl(__x); }
3305 { return __builtin_log2l(__x); }
3309 { return __builtin_logbl(__x); }
3312 lrint(_Float128 __x)
3313 { return __builtin_lrintl(__x); }
3316 lround(_Float128 __x)
3317 { return __builtin_lroundl(__x); }
3320 nearbyint(_Float128 __x)
3321 { return __builtin_nearbyintl(__x); }
3324 nextafter(_Float128 __x, _Float128 __y)
3325 { return __builtin_nextafterl(__x, __y); }
3328 remainder(_Float128 __x, _Float128 __y)
3329 { return __builtin_remainderl(__x, __y); }
3332 remquo(_Float128 __x, _Float128 __y, int* __pquo)
3333 { return __builtin_remquol(__x, __y, __pquo); }
3337 { return __builtin_rintl(__x); }
3340 round(_Float128 __x)
3341 { return __builtin_roundl(__x); }
3344 scalbln(_Float128 __x, long __ex)
3345 { return __builtin_scalblnl(__x, __ex); }
3348 scalbn(_Float128 __x, int __ex)
3349 { return __builtin_scalbnl(__x, __ex); }
3352 tgamma(_Float128 __x)
3353 { return __builtin_tgammal(__x); }
3356 trunc(_Float128 __x)
3357 { return __builtin_truncl(__x); }
3358 #elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
3360 acosh(_Float128 __x)
3361 { return __builtin_acoshf128(__x); }
3364 asinh(_Float128 __x)
3365 { return __builtin_asinhf128(__x); }
3368 atanh(_Float128 __x)
3369 { return __builtin_atanhf128(__x); }
3373 { return __builtin_cbrtf128(__x); }
3376 copysign(_Float128 __x, _Float128 __y)
3377 { return __builtin_copysignf128(__x, __y); }
3381 { return __builtin_erff128(__x); }
3385 { return __builtin_erfcf128(__x); }
3389 { return __builtin_exp2f128(__x); }
3392 expm1(_Float128 __x)
3393 { return __builtin_expm1f128(__x); }
3396 fdim(_Float128 __x, _Float128 __y)
3397 { return __builtin_fdimf128(__x, __y); }
3400 fma(_Float128 __x, _Float128 __y, _Float128 __z)
3401 { return __builtin_fmaf128(__x, __y, __z); }
3404 fmax(_Float128 __x, _Float128 __y)
3405 { return __builtin_fmaxf128(__x, __y); }
3408 fmin(_Float128 __x, _Float128 __y)
3409 { return __builtin_fminf128(__x, __y); }
3412 hypot(_Float128 __x, _Float128 __y)
3413 { return __builtin_hypotf128(__x, __y); }
3416 ilogb(_Float128 __x)
3417 { return __builtin_ilogbf128(__x); }
3420 lgamma(_Float128 __x)
3421 { return __builtin_lgammaf128(__x); }
3424 llrint(_Float128 __x)
3425 { return __builtin_llrintf128(__x); }
3428 llround(_Float128 __x)
3429 { return __builtin_llroundf128(__x); }
3432 log1p(_Float128 __x)
3433 { return __builtin_log1pf128(__x); }
3438 { return __builtin_log2f128(__x); }
3442 { return __builtin_logbf128(__x); }
3445 lrint(_Float128 __x)
3446 { return __builtin_lrintf128(__x); }
3449 lround(_Float128 __x)
3450 { return __builtin_lroundf128(__x); }
3453 nearbyint(_Float128 __x)
3454 { return __builtin_nearbyintf128(__x); }
3457 nextafter(_Float128 __x, _Float128 __y)
3458 { return __builtin_nextafterf128(__x, __y); }
3461 remainder(_Float128 __x, _Float128 __y)
3462 { return __builtin_remainderf128(__x, __y); }
3465 remquo(_Float128 __x, _Float128 __y, int* __pquo)
3466 { return __builtin_remquof128(__x, __y, __pquo); }
3470 { return __builtin_rintf128(__x); }
3473 round(_Float128 __x)
3474 { return __builtin_roundf128(__x); }
3477 scalbln(_Float128 __x, long __ex)
3478 { return __builtin_scalblnf128(__x, __ex); }
3481 scalbn(_Float128 __x, int __ex)
3482 { return __builtin_scalbnf128(__x, __ex); }
3485 tgamma(_Float128 __x)
3486 { return __builtin_tgammaf128(__x); }
3489 trunc(_Float128 __x)
3490 { return __builtin_truncf128(__x); }
3493 #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3494 constexpr __gnu_cxx::__bfloat16_t
3495 acosh(__gnu_cxx::__bfloat16_t __x)
3496 { return __gnu_cxx::__bfloat16_t(__builtin_acoshf(__x)); }
3498 constexpr __gnu_cxx::__bfloat16_t
3499 asinh(__gnu_cxx::__bfloat16_t __x)
3500 { return __gnu_cxx::__bfloat16_t(__builtin_asinhf(__x)); }
3502 constexpr __gnu_cxx::__bfloat16_t
3503 atanh(__gnu_cxx::__bfloat16_t __x)
3504 { return __gnu_cxx::__bfloat16_t(__builtin_atanhf(__x)); }
3506 constexpr __gnu_cxx::__bfloat16_t
3507 cbrt(__gnu_cxx::__bfloat16_t __x)
3508 { return __gnu_cxx::__bfloat16_t(__builtin_cbrtf(__x)); }
3510 constexpr __gnu_cxx::__bfloat16_t
3511 copysign(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3512 { return __gnu_cxx::__bfloat16_t(__builtin_copysignf(__x, __y)); }
3514 constexpr __gnu_cxx::__bfloat16_t
3515 erf(__gnu_cxx::__bfloat16_t __x)
3516 { return __gnu_cxx::__bfloat16_t(__builtin_erff(__x)); }
3518 constexpr __gnu_cxx::__bfloat16_t
3519 erfc(__gnu_cxx::__bfloat16_t __x)
3520 { return __gnu_cxx::__bfloat16_t(__builtin_erfcf(__x)); }
3522 constexpr __gnu_cxx::__bfloat16_t
3523 exp2(__gnu_cxx::__bfloat16_t __x)
3524 { return __gnu_cxx::__bfloat16_t(__builtin_exp2f(__x)); }
3526 constexpr __gnu_cxx::__bfloat16_t
3527 expm1(__gnu_cxx::__bfloat16_t __x)
3528 { return __gnu_cxx::__bfloat16_t(__builtin_expm1f(__x)); }
3530 constexpr __gnu_cxx::__bfloat16_t
3531 fdim(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3532 { return __gnu_cxx::__bfloat16_t(__builtin_fdimf(__x, __y)); }
3534 constexpr __gnu_cxx::__bfloat16_t
3535 fma(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z)
3536 { return __gnu_cxx::__bfloat16_t(__builtin_fmaf(__x, __y, __z)); }
3538 constexpr __gnu_cxx::__bfloat16_t
3539 fmax(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3540 { return __gnu_cxx::__bfloat16_t(__builtin_fmaxf(__x, __y)); }
3542 constexpr __gnu_cxx::__bfloat16_t
3543 fmin(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3544 { return __gnu_cxx::__bfloat16_t(__builtin_fminf(__x, __y)); }
3546 constexpr __gnu_cxx::__bfloat16_t
3547 hypot(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3548 { return __gnu_cxx::__bfloat16_t(__builtin_hypotf(__x, __y)); }
3551 ilogb(__gnu_cxx::__bfloat16_t __x)
3552 { return __gnu_cxx::__bfloat16_t(__builtin_ilogbf(__x)); }
3554 constexpr __gnu_cxx::__bfloat16_t
3555 lgamma(__gnu_cxx::__bfloat16_t __x)
3556 { return __gnu_cxx::__bfloat16_t(__builtin_lgammaf(__x)); }
3559 llrint(__gnu_cxx::__bfloat16_t __x)
3560 { return __gnu_cxx::__bfloat16_t(__builtin_llrintf(__x)); }
3563 llround(__gnu_cxx::__bfloat16_t __x)
3564 { return __gnu_cxx::__bfloat16_t(__builtin_llroundf(__x)); }
3566 constexpr __gnu_cxx::__bfloat16_t
3567 log1p(__gnu_cxx::__bfloat16_t __x)
3568 { return __gnu_cxx::__bfloat16_t(__builtin_log1pf(__x)); }
3571 constexpr __gnu_cxx::__bfloat16_t
3572 log2(__gnu_cxx::__bfloat16_t __x)
3573 { return __gnu_cxx::__bfloat16_t(__builtin_log2f(__x)); }
3575 constexpr __gnu_cxx::__bfloat16_t
3576 logb(__gnu_cxx::__bfloat16_t __x)
3577 { return __gnu_cxx::__bfloat16_t(__builtin_logbf(__x)); }
3580 lrint(__gnu_cxx::__bfloat16_t __x)
3581 { return __gnu_cxx::__bfloat16_t(__builtin_lrintf(__x)); }
3584 lround(__gnu_cxx::__bfloat16_t __x)
3585 { return __gnu_cxx::__bfloat16_t(__builtin_lroundf(__x)); }
3587 constexpr __gnu_cxx::__bfloat16_t
3588 nearbyint(__gnu_cxx::__bfloat16_t __x)
3589 { return __gnu_cxx::__bfloat16_t(__builtin_nearbyintf(__x)); }
3591 constexpr __gnu_cxx::__bfloat16_t
3592 nextafter(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3594 if (std::__is_constant_evaluated())
3595 return __builtin_nextafterf16b(__x, __y);
3596 #ifdef __INT16_TYPE__
3597 using __bfloat16_int_type = __INT16_TYPE__;
3599 using __bfloat16_int_type = short int;
3601 __bfloat16_int_type __hx, __hy, __ix, __iy;
3602 __builtin_memcpy(&__hx, &__x, sizeof(__x));
3603 __builtin_memcpy(&__hy, &__y, sizeof(__x));
3604 __ix = __hx & 0x7fff; // |x|
3605 __iy = __hy & 0x7fff; // |y|
3606 if (__ix > 0x7f80 || __iy > 0x7f80) // x or y is NaN
3609 return __y; // x == y, return y
3610 if (__ix == 0) // x == 0
3612 __hy = (__hy & 0x8000) | 1; // return +-__BFLT16_DENORM_MIN__
3613 __builtin_memcpy(&__x, &__hy, sizeof(__x));
3614 __builtin_nextafterf(0.0f, 1.0f); // raise underflow
3617 if (__hx >= 0) // x > 0
3619 if (__hx > __hy) // x > y, x -= ulp
3621 else // x < y, x += ulp
3626 if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp
3628 else // x > y, x += ulp
3631 __hy = __hx & 0x7f80;
3633 __builtin_nextafterf(__FLT_MAX__, __builtin_inff()); // overflow
3634 else if (__hy < 0x0080)
3635 __builtin_nextafterf(__FLT_MIN__, 0.0f); // underflow
3636 __builtin_memcpy(&__x, &__hx, sizeof(__x));
3640 constexpr __gnu_cxx::__bfloat16_t
3641 remainder(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3642 { return __gnu_cxx::__bfloat16_t(__builtin_remainderf(__x, __y)); }
3644 inline __gnu_cxx::__bfloat16_t
3645 remquo(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, int* __pquo)
3646 { return __gnu_cxx::__bfloat16_t(__builtin_remquof(__x, __y, __pquo)); }
3648 constexpr __gnu_cxx::__bfloat16_t
3649 rint(__gnu_cxx::__bfloat16_t __x)
3650 { return __gnu_cxx::__bfloat16_t(__builtin_rintf(__x)); }
3652 constexpr __gnu_cxx::__bfloat16_t
3653 round(__gnu_cxx::__bfloat16_t __x)
3654 { return __gnu_cxx::__bfloat16_t(__builtin_roundf(__x)); }
3656 constexpr __gnu_cxx::__bfloat16_t
3657 scalbln(__gnu_cxx::__bfloat16_t __x, long __ex)
3658 { return __gnu_cxx::__bfloat16_t(__builtin_scalblnf(__x, __ex)); }
3660 constexpr __gnu_cxx::__bfloat16_t
3661 scalbn(__gnu_cxx::__bfloat16_t __x, int __ex)
3662 { return __gnu_cxx::__bfloat16_t(__builtin_scalbnf(__x, __ex)); }
3664 constexpr __gnu_cxx::__bfloat16_t
3665 tgamma(__gnu_cxx::__bfloat16_t __x)
3666 { return __gnu_cxx::__bfloat16_t(__builtin_tgammaf(__x)); }
3668 constexpr __gnu_cxx::__bfloat16_t
3669 trunc(__gnu_cxx::__bfloat16_t __x)
3670 { return __gnu_cxx::__bfloat16_t(__builtin_truncf(__x)); }
3673 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
3674 template<typename _Tp, typename _Up>
3675 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3676 copysign(_Tp __x, _Up __y)
3678 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3679 return copysign(__type(__x), __type(__y));
3682 template<typename _Tp, typename _Up>
3683 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3684 fdim(_Tp __x, _Up __y)
3686 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3687 return fdim(__type(__x), __type(__y));
3690 template<typename _Tp, typename _Up>
3691 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3692 fmax(_Tp __x, _Up __y)
3694 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3695 return fmax(__type(__x), __type(__y));
3698 template<typename _Tp, typename _Up>
3699 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3700 fmin(_Tp __x, _Up __y)
3702 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3703 return fmin(__type(__x), __type(__y));
3706 template<typename _Tp, typename _Up>
3707 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3708 hypot(_Tp __x, _Up __y)
3710 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3711 return hypot(__type(__x), __type(__y));
3714 template<typename _Tp, typename _Up>
3715 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3716 nextafter(_Tp __x, _Up __y)
3718 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3719 return nextafter(__type(__x), __type(__y));
3722 template<typename _Tp, typename _Up>
3723 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3724 remainder(_Tp __x, _Up __y)
3726 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3727 return remainder(__type(__x), __type(__y));
3730 template<typename _Tp, typename _Up>
3731 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3732 remquo(_Tp __x, _Up __y, int* __pquo)
3734 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3735 return remquo(__type(__x), __type(__y), __pquo);
3738 template<typename _Tp, typename _Up, typename _Vp>
3739 constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
3740 fma(_Tp __x, _Up __y, _Vp __z)
3742 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
3743 return fma(__type(__x), __type(__y), __type(__z));
3747 #endif // _GLIBCXX_USE_C99_MATH_FUNCS
3750 #ifdef __cpp_lib_hypot // C++ >= 17 && HOSTED
3751 // [c.math.hypot3], three-dimensional hypotenuse
3752 template<typename _Tp>
3754 __hypot3(_Tp __x, _Tp __y, _Tp __z)
3756 __x = std::abs(__x);
3757 __y = std::abs(__y);
3758 __z = std::abs(__z);
3759 if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x)
3760 return __a * std::sqrt((__x / __a) * (__x / __a)
3761 + (__y / __a) * (__y / __a)
3762 + (__z / __a) * (__z / __a));
3768 hypot(float __x, float __y, float __z)
3769 { return std::__hypot3<float>(__x, __y, __z); }
3772 hypot(double __x, double __y, double __z)
3773 { return std::__hypot3<double>(__x, __y, __z); }
3776 hypot(long double __x, long double __y, long double __z)
3777 { return std::__hypot3<long double>(__x, __y, __z); }
3779 template<typename _Tp, typename _Up, typename _Vp>
3780 __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>
3781 hypot(_Tp __x, _Up __y, _Vp __z)
3783 using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>;
3784 return std::__hypot3<__type>(__x, __y, __z);
3787 #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3789 hypot(_Float16 __x, _Float16 __y, _Float16 __z)
3790 { return std::__hypot3<_Float16>(__x, __y, __z); }
3793 #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3795 hypot(_Float32 __x, _Float32 __y, _Float32 __z)
3796 { return std::__hypot3<_Float32>(__x, __y, __z); }
3799 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
3801 hypot(_Float64 __x, _Float64 __y, _Float64 __z)
3802 { return std::__hypot3<_Float64>(__x, __y, __z); }
3805 #if defined(__STDCPP_FLOAT128_T__) \
3806 && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \
3807 || defined(_GLIBCXX_HAVE_FLOAT128_MATH))
3809 hypot(_Float128 __x, _Float128 __y, _Float128 __z)
3810 { return std::__hypot3<_Float128>(__x, __y, __z); }
3813 #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3814 inline __gnu_cxx::__bfloat16_t
3815 hypot(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z)
3816 { return std::__hypot3<__gnu_cxx::__bfloat16_t>(__x, __y, __z); }
3819 #endif // __cpp_lib_hypot
3821 #ifdef __cpp_lib_interpolate // C++ >= 20
3822 // linear interpolation
3823 template<typename _Fp>
3825 __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept
3827 if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
3828 return __t * __b + (1 - __t) * __a;
3831 return __b; // exact
3833 // Exact at __t=0, monotonic except near __t=1,
3834 // bounded, determinate, and consistent:
3835 const _Fp __x = __a + __t * (__b - __a);
3836 return (__t > 1) == (__b > __a)
3837 ? (__b < __x ? __x : __b)
3838 : (__b > __x ? __x : __b); // monotonic near __t=1
3842 lerp(float __a, float __b, float __t) noexcept
3843 { return std::__lerp(__a, __b, __t); }
3846 lerp(double __a, double __b, double __t) noexcept
3847 { return std::__lerp(__a, __b, __t); }
3849 constexpr long double
3850 lerp(long double __a, long double __b, long double __t) noexcept
3851 { return std::__lerp(__a, __b, __t); }
3853 template<typename _Tp, typename _Up, typename _Vp>
3854 constexpr __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>
3855 lerp(_Tp __x, _Up __y, _Vp __z) noexcept
3857 using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>;
3858 return std::__lerp<__type>(__x, __y, __z);
3861 #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3863 lerp(_Float16 __x, _Float16 __y, _Float16 __z) noexcept
3864 { return std::__lerp<_Float16>(__x, __y, __z); }
3867 #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3869 lerp(_Float32 __x, _Float32 __y, _Float32 __z) noexcept
3870 { return std::__lerp<_Float32>(__x, __y, __z); }
3873 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
3875 lerp(_Float64 __x, _Float64 __y, _Float64 __z) noexcept
3876 { return std::__lerp<_Float64>(__x, __y, __z); }
3879 #if defined(__STDCPP_FLOAT128_T__) \
3880 && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \
3881 || defined(_GLIBCXX_HAVE_FLOAT128_MATH))
3883 lerp(_Float128 __x, _Float128 __y, _Float128 __z) noexcept
3884 { return std::__lerp<_Float128>(__x, __y, __z); }
3887 #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3888 inline __gnu_cxx::__bfloat16_t
3889 lerp(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z) noexcept
3890 { return std::__lerp<__gnu_cxx::__bfloat16_t>(__x, __y, __z); }
3892 #endif // __cpp_lib_interpolate
3894 _GLIBCXX_END_NAMESPACE_VERSION
3897 #if _GLIBCXX_USE_STD_SPEC_FUNCS
3898 # include <bits/specfun.h>