1// -*- C++ -*- C forwarding header.
3// Copyright (C) 1997-2025 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
40#define _GLIBCXX_CMATH 1
43#pragma GCC system_header
46#include <bits/requires_hosted.h>
48#include <bits/c++config.h>
49#include <bits/cpp_type_traits.h>
50#include <ext/type_traits.h>
52#pragma GCC diagnostic push
53#pragma GCC diagnostic ignored "-Wpedantic" // include_next
54#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
56#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
57#pragma GCC diagnostic pop
59#include <bits/std_abs.h>
61#define __glibcxx_want_hypot
62#define __glibcxx_want_interpolate
63#include <bits/version.h>
65// Get rid of those macros defined in <math.h> in lieu of real functions.
92namespace std _GLIBCXX_VISIBILITY(default)
94_GLIBCXX_BEGIN_NAMESPACE_VERSION
98#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
99 inline _GLIBCXX_CONSTEXPR float
101 { return __builtin_acosf(__x); }
103 inline _GLIBCXX_CONSTEXPR long double
104 acos(long double __x)
105 { return __builtin_acosl(__x); }
108 template<typename _Tp>
109 inline _GLIBCXX_CONSTEXPR
110 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
113 { return __builtin_acos(__x); }
117#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
118 inline _GLIBCXX_CONSTEXPR float
120 { return __builtin_asinf(__x); }
122 inline _GLIBCXX_CONSTEXPR long double
123 asin(long double __x)
124 { 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#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
137 inline _GLIBCXX_CONSTEXPR float
139 { return __builtin_atanf(__x); }
141 inline _GLIBCXX_CONSTEXPR long double
142 atan(long double __x)
143 { return __builtin_atanl(__x); }
146 template<typename _Tp>
147 inline _GLIBCXX_CONSTEXPR
148 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
151 { return __builtin_atan(__x); }
155#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
156 inline _GLIBCXX_CONSTEXPR float
157 atan2(float __y, float __x)
158 { return __builtin_atan2f(__y, __x); }
160 inline _GLIBCXX_CONSTEXPR long double
161 atan2(long double __y, long double __x)
162 { return __builtin_atan2l(__y, __x); }
167#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
168 inline _GLIBCXX_CONSTEXPR float
170 { return __builtin_ceilf(__x); }
172 inline _GLIBCXX_CONSTEXPR long double
173 ceil(long double __x)
174 { return __builtin_ceill(__x); }
177 template<typename _Tp>
178 inline _GLIBCXX_CONSTEXPR
179 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
182 { return __builtin_ceil(__x); }
186#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
187 inline _GLIBCXX_CONSTEXPR float
189 { return __builtin_cosf(__x); }
191 inline _GLIBCXX_CONSTEXPR long double
193 { return __builtin_cosl(__x); }
196 template<typename _Tp>
197 inline _GLIBCXX_CONSTEXPR
198 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
201 { return __builtin_cos(__x); }
205#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
206 inline _GLIBCXX_CONSTEXPR float
208 { return __builtin_coshf(__x); }
210 inline _GLIBCXX_CONSTEXPR long double
211 cosh(long double __x)
212 { return __builtin_coshl(__x); }
215 template<typename _Tp>
216 inline _GLIBCXX_CONSTEXPR
217 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
220 { return __builtin_cosh(__x); }
224#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
225 inline _GLIBCXX_CONSTEXPR float
227 { return __builtin_expf(__x); }
229 inline _GLIBCXX_CONSTEXPR long double
231 { 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#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
244 inline _GLIBCXX_CONSTEXPR float
246 { return __builtin_fabsf(__x); }
248 inline _GLIBCXX_CONSTEXPR long double
249 fabs(long double __x)
250 { return __builtin_fabsl(__x); }
253 template<typename _Tp>
254 inline _GLIBCXX_CONSTEXPR
255 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
258 { return __builtin_fabs(__x); }
262#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
263 inline _GLIBCXX_CONSTEXPR float
265 { return __builtin_floorf(__x); }
267 inline _GLIBCXX_CONSTEXPR long double
268 floor(long double __x)
269 { return __builtin_floorl(__x); }
272 template<typename _Tp>
273 inline _GLIBCXX_CONSTEXPR
274 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
277 { return __builtin_floor(__x); }
281#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
282 inline _GLIBCXX_CONSTEXPR float
283 fmod(float __x, float __y)
284 { return __builtin_fmodf(__x, __y); }
286 inline _GLIBCXX_CONSTEXPR long double
287 fmod(long double __x, long double __y)
288 { return __builtin_fmodl(__x, __y); }
293#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
295 frexp(float __x, int* __exp)
296 { return __builtin_frexpf(__x, __exp); }
299 frexp(long double __x, int* __exp)
300 { return __builtin_frexpl(__x, __exp); }
303 template<typename _Tp>
304 inline _GLIBCXX_CONSTEXPR
305 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
307 frexp(_Tp __x, int* __exp)
308 { return __builtin_frexp(__x, __exp); }
312#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
313 inline _GLIBCXX_CONSTEXPR float
314 ldexp(float __x, int __exp)
315 { return __builtin_ldexpf(__x, __exp); }
317 inline _GLIBCXX_CONSTEXPR long double
318 ldexp(long double __x, int __exp)
319 { return __builtin_ldexpl(__x, __exp); }
322 template<typename _Tp>
323 inline _GLIBCXX_CONSTEXPR
324 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
326 ldexp(_Tp __x, int __exp)
327 { return __builtin_ldexp(__x, __exp); }
331#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
332 inline _GLIBCXX_CONSTEXPR float
334 { return __builtin_logf(__x); }
336 inline _GLIBCXX_CONSTEXPR long double
338 { 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#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
351 inline _GLIBCXX_CONSTEXPR float
353 { return __builtin_log10f(__x); }
355 inline _GLIBCXX_CONSTEXPR long double
356 log10(long double __x)
357 { return __builtin_log10l(__x); }
360 template<typename _Tp>
361 inline _GLIBCXX_CONSTEXPR
362 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
365 { return __builtin_log10(__x); }
369#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
371 modf(float __x, float* __iptr)
372 { return __builtin_modff(__x, __iptr); }
375 modf(long double __x, long double* __iptr)
376 { return __builtin_modfl(__x, __iptr); }
381#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
382 inline _GLIBCXX_CONSTEXPR float
383 pow(float __x, float __y)
384 { return __builtin_powf(__x, __y); }
386 inline _GLIBCXX_CONSTEXPR long double
387 pow(long double __x, long double __y)
388 { return __builtin_powl(__x, __y); }
390#if __cplusplus < 201103L
391 // _GLIBCXX_RESOLVE_LIB_DEFECTS
392 // DR 550. What should the return type of pow(float,int) be?
394 pow(double __x, int __i)
395 { return __builtin_powi(__x, __i); }
398 pow(float __x, int __n)
399 { return __builtin_powif(__x, __n); }
402 pow(long double __x, int __n)
403 { return __builtin_powil(__x, __n); }
409#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
410 inline _GLIBCXX_CONSTEXPR float
412 { return __builtin_sinf(__x); }
414 inline _GLIBCXX_CONSTEXPR long double
416 { return __builtin_sinl(__x); }
419 template<typename _Tp>
420 inline _GLIBCXX_CONSTEXPR
421 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
424 { return __builtin_sin(__x); }
428#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
429 inline _GLIBCXX_CONSTEXPR float
431 { return __builtin_sinhf(__x); }
433 inline _GLIBCXX_CONSTEXPR long double
434 sinh(long double __x)
435 { return __builtin_sinhl(__x); }
438 template<typename _Tp>
439 inline _GLIBCXX_CONSTEXPR
440 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
443 { return __builtin_sinh(__x); }
447#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
448 inline _GLIBCXX_CONSTEXPR float
450 { return __builtin_sqrtf(__x); }
452 inline _GLIBCXX_CONSTEXPR long double
453 sqrt(long double __x)
454 { 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#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
467 inline _GLIBCXX_CONSTEXPR float
469 { return __builtin_tanf(__x); }
471 inline _GLIBCXX_CONSTEXPR long double
473 { return __builtin_tanl(__x); }
476 template<typename _Tp>
477 inline _GLIBCXX_CONSTEXPR
478 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
481 { return __builtin_tan(__x); }
485#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
486 inline _GLIBCXX_CONSTEXPR float
488 { return __builtin_tanhf(__x); }
490 inline _GLIBCXX_CONSTEXPR long double
491 tanh(long double __x)
492 { return __builtin_tanhl(__x); }
495 template<typename _Tp>
496 inline _GLIBCXX_CONSTEXPR
497 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
500 { return __builtin_tanh(__x); }
502#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
505 { return _Float16(__builtin_acosf(__x)); }
509 { return _Float16(__builtin_asinf(__x)); }
513 { return _Float16(__builtin_atanf(__x)); }
516 atan2(_Float16 __y, _Float16 __x)
517 { return _Float16(__builtin_atan2f(__y, __x)); }
521 { return _Float16(__builtin_ceilf(__x)); }
525 { return _Float16(__builtin_cosf(__x)); }
529 { return _Float16(__builtin_coshf(__x)); }
533 { return _Float16(__builtin_expf(__x)); }
537 { return _Float16(__builtin_fabsf(__x)); }
541 { return _Float16(__builtin_floorf(__x)); }
544 fmod(_Float16 __x, _Float16 __y)
545 { return _Float16(__builtin_fmodf(__x, __y)); }
548 frexp(_Float16 __x, int* __exp)
549 { return _Float16(__builtin_frexpf(__x, __exp)); }
552 ldexp(_Float16 __x, int __exp)
553 { return _Float16(__builtin_ldexpf(__x, __exp)); }
557 { return _Float16(__builtin_logf(__x)); }
561 { return _Float16(__builtin_log10f(__x)); }
564 modf(_Float16 __x, _Float16* __iptr)
566 float __i, __ret = __builtin_modff(__x, &__i);
567 *__iptr = _Float16(__i);
568 return _Float16(__ret);
572 pow(_Float16 __x, _Float16 __y)
573 { return _Float16(__builtin_powf(__x, __y)); }
577 { return _Float16(__builtin_sinf(__x)); }
581 { return _Float16(__builtin_sinhf(__x)); }
585 { return _Float16(__builtin_sqrtf(__x)); }
589 { return _Float16(__builtin_tanf(__x)); }
593 { return _Float16(__builtin_tanhf(__x)); }
596#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
599 { return __builtin_acosf(__x); }
603 { return __builtin_asinf(__x); }
607 { return __builtin_atanf(__x); }
610 atan2(_Float32 __y, _Float32 __x)
611 { return __builtin_atan2f(__y, __x); }
615 { return __builtin_ceilf(__x); }
619 { return __builtin_cosf(__x); }
623 { return __builtin_coshf(__x); }
627 { return __builtin_expf(__x); }
631 { return __builtin_fabsf(__x); }
635 { return __builtin_floorf(__x); }
638 fmod(_Float32 __x, _Float32 __y)
639 { return __builtin_fmodf(__x, __y); }
642 frexp(_Float32 __x, int* __exp)
643 { return __builtin_frexpf(__x, __exp); }
646 ldexp(_Float32 __x, int __exp)
647 { return __builtin_ldexpf(__x, __exp); }
651 { return __builtin_logf(__x); }
655 { return __builtin_log10f(__x); }
658 modf(_Float32 __x, _Float32* __iptr)
660 float __i, __ret = __builtin_modff(__x, &__i);
666 pow(_Float32 __x, _Float32 __y)
667 { return __builtin_powf(__x, __y); }
671 { return __builtin_sinf(__x); }
675 { return __builtin_sinhf(__x); }
679 { return __builtin_sqrtf(__x); }
683 { return __builtin_tanf(__x); }
687 { return __builtin_tanhf(__x); }
690#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
693 { return __builtin_acos(__x); }
697 { return __builtin_asin(__x); }
701 { return __builtin_atan(__x); }
704 atan2(_Float64 __y, _Float64 __x)
705 { return __builtin_atan2(__y, __x); }
709 { return __builtin_ceil(__x); }
713 { return __builtin_cos(__x); }
717 { return __builtin_cosh(__x); }
721 { return __builtin_exp(__x); }
725 { return __builtin_fabs(__x); }
729 { return __builtin_floor(__x); }
732 fmod(_Float64 __x, _Float64 __y)
733 { return __builtin_fmod(__x, __y); }
736 frexp(_Float64 __x, int* __exp)
737 { return __builtin_frexp(__x, __exp); }
740 ldexp(_Float64 __x, int __exp)
741 { return __builtin_ldexp(__x, __exp); }
745 { return __builtin_log(__x); }
749 { return __builtin_log10(__x); }
752 modf(_Float64 __x, _Float64* __iptr)
754 double __i, __ret = __builtin_modf(__x, &__i);
760 pow(_Float64 __x, _Float64 __y)
761 { return __builtin_pow(__x, __y); }
765 { return __builtin_sin(__x); }
769 { return __builtin_sinh(__x); }
773 { return __builtin_sqrt(__x); }
777 { return __builtin_tan(__x); }
781 { return __builtin_tanh(__x); }
784#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
787 { return __builtin_acosl(__x); }
791 { return __builtin_asinl(__x); }
795 { return __builtin_atanl(__x); }
798 atan2(_Float128 __y, _Float128 __x)
799 { return __builtin_atan2l(__y, __x); }
803 { return __builtin_ceill(__x); }
807 { return __builtin_cosl(__x); }
811 { return __builtin_coshl(__x); }
815 { return __builtin_expl(__x); }
819 { return __builtin_fabsl(__x); }
823 { return __builtin_floorl(__x); }
826 fmod(_Float128 __x, _Float128 __y)
827 { return __builtin_fmodl(__x, __y); }
830 frexp(_Float128 __x, int* __exp)
831 { return __builtin_frexpl(__x, __exp); }
834 ldexp(_Float128 __x, int __exp)
835 { return __builtin_ldexpl(__x, __exp); }
839 { return __builtin_logl(__x); }
843 { return __builtin_log10l(__x); }
846 modf(_Float128 __x, _Float128* __iptr)
848 long double __i, __ret = __builtin_modfl(__x, &__i);
854 pow(_Float128 __x, _Float128 __y)
855 { return __builtin_powl(__x, __y); }
859 { return __builtin_sinl(__x); }
863 { return __builtin_sinhl(__x); }
867 { return __builtin_sqrtl(__x); }
871 { return __builtin_tanl(__x); }
875 { return __builtin_tanhl(__x); }
876#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
879 { return __builtin_acosf128(__x); }
883 { return __builtin_asinf128(__x); }
887 { return __builtin_atanf128(__x); }
890 atan2(_Float128 __y, _Float128 __x)
891 { return __builtin_atan2f128(__y, __x); }
895 { return __builtin_ceilf128(__x); }
899 { return __builtin_cosf128(__x); }
903 { return __builtin_coshf128(__x); }
907 { return __builtin_expf128(__x); }
911 { return __builtin_fabsf128(__x); }
915 { return __builtin_floorf128(__x); }
918 fmod(_Float128 __x, _Float128 __y)
919 { return __builtin_fmodf128(__x, __y); }
922 frexp(_Float128 __x, int* __exp)
923 { return __builtin_frexpf128(__x, __exp); }
926 ldexp(_Float128 __x, int __exp)
927 { return __builtin_ldexpf128(__x, __exp); }
931 { return __builtin_logf128(__x); }
935 { return __builtin_log10f128(__x); }
938 modf(_Float128 __x, _Float128* __iptr)
939 { return __builtin_modff128(__x, __iptr); }
942 pow(_Float128 __x, _Float128 __y)
943 { return __builtin_powf128(__x, __y); }
947 { return __builtin_sinf128(__x); }
951 { return __builtin_sinhf128(__x); }
955 { return __builtin_sqrtf128(__x); }
959 { return __builtin_tanf128(__x); }
963 { return __builtin_tanhf128(__x); }
966#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
967 constexpr __gnu_cxx::__bfloat16_t
968 acos(__gnu_cxx::__bfloat16_t __x)
969 { return __gnu_cxx::__bfloat16_t(__builtin_acosf(__x)); }
971 constexpr __gnu_cxx::__bfloat16_t
972 asin(__gnu_cxx::__bfloat16_t __x)
973 { return __gnu_cxx::__bfloat16_t(__builtin_asinf(__x)); }
975 constexpr __gnu_cxx::__bfloat16_t
976 atan(__gnu_cxx::__bfloat16_t __x)
977 { return __gnu_cxx::__bfloat16_t(__builtin_atanf(__x)); }
979 constexpr __gnu_cxx::__bfloat16_t
980 atan2(__gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __x)
981 { return __gnu_cxx::__bfloat16_t(__builtin_atan2f(__y, __x)); }
983 constexpr __gnu_cxx::__bfloat16_t
984 ceil(__gnu_cxx::__bfloat16_t __x)
985 { return __gnu_cxx::__bfloat16_t(__builtin_ceilf(__x)); }
987 constexpr __gnu_cxx::__bfloat16_t
988 cos(__gnu_cxx::__bfloat16_t __x)
989 { return __gnu_cxx::__bfloat16_t(__builtin_cosf(__x)); }
991 constexpr __gnu_cxx::__bfloat16_t
992 cosh(__gnu_cxx::__bfloat16_t __x)
993 { return __gnu_cxx::__bfloat16_t(__builtin_coshf(__x)); }
995 constexpr __gnu_cxx::__bfloat16_t
996 exp(__gnu_cxx::__bfloat16_t __x)
997 { return __gnu_cxx::__bfloat16_t(__builtin_expf(__x)); }
999 constexpr __gnu_cxx::__bfloat16_t
1000 fabs(__gnu_cxx::__bfloat16_t __x)
1001 { return __gnu_cxx::__bfloat16_t(__builtin_fabsf(__x)); }
1003 constexpr __gnu_cxx::__bfloat16_t
1004 floor(__gnu_cxx::__bfloat16_t __x)
1005 { return __gnu_cxx::__bfloat16_t(__builtin_floorf(__x)); }
1007 constexpr __gnu_cxx::__bfloat16_t
1008 fmod(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1009 { return __gnu_cxx::__bfloat16_t(__builtin_fmodf(__x, __y)); }
1011 inline __gnu_cxx::__bfloat16_t
1012 frexp(__gnu_cxx::__bfloat16_t __x, int* __exp)
1013 { return __gnu_cxx::__bfloat16_t(__builtin_frexpf(__x, __exp)); }
1015 constexpr __gnu_cxx::__bfloat16_t
1016 ldexp(__gnu_cxx::__bfloat16_t __x, int __exp)
1017 { return __gnu_cxx::__bfloat16_t(__builtin_ldexpf(__x, __exp)); }
1019 constexpr __gnu_cxx::__bfloat16_t
1020 log(__gnu_cxx::__bfloat16_t __x)
1021 { return __gnu_cxx::__bfloat16_t(__builtin_logf(__x)); }
1023 constexpr __gnu_cxx::__bfloat16_t
1024 log10(__gnu_cxx::__bfloat16_t __x)
1025 { return __gnu_cxx::__bfloat16_t(__builtin_log10f(__x)); }
1027 inline __gnu_cxx::__bfloat16_t
1028 modf(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t* __iptr)
1030 float __i, __ret = __builtin_modff(__x, &__i);
1031 *__iptr = __gnu_cxx::__bfloat16_t(__i);
1032 return __gnu_cxx::__bfloat16_t(__ret);
1035 constexpr __gnu_cxx::__bfloat16_t
1036 pow(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1037 { return __gnu_cxx::__bfloat16_t(__builtin_powf(__x, __y)); }
1039 constexpr __gnu_cxx::__bfloat16_t
1040 sin(__gnu_cxx::__bfloat16_t __x)
1041 { return __gnu_cxx::__bfloat16_t(__builtin_sinf(__x)); }
1043 constexpr __gnu_cxx::__bfloat16_t
1044 sinh(__gnu_cxx::__bfloat16_t __x)
1045 { return __gnu_cxx::__bfloat16_t(__builtin_sinhf(__x)); }
1047 constexpr __gnu_cxx::__bfloat16_t
1048 sqrt(__gnu_cxx::__bfloat16_t __x)
1049 { return __gnu_cxx::__bfloat16_t(__builtin_sqrtf(__x)); }
1051 constexpr __gnu_cxx::__bfloat16_t
1052 tan(__gnu_cxx::__bfloat16_t __x)
1053 { return __gnu_cxx::__bfloat16_t(__builtin_tanf(__x)); }
1055 constexpr __gnu_cxx::__bfloat16_t
1056 tanh(__gnu_cxx::__bfloat16_t __x)
1057 { return __gnu_cxx::__bfloat16_t(__builtin_tanhf(__x)); }
1060 template<typename _Tp, typename _Up>
1061 inline _GLIBCXX_CONSTEXPR
1062 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1063 atan2(_Tp __y, _Up __x)
1065 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1066 return atan2(__type(__y), __type(__x));
1069 template<typename _Tp, typename _Up>
1070 inline _GLIBCXX_CONSTEXPR
1071 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1072 fmod(_Tp __x, _Up __y)
1074 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1075 return fmod(__type(__x), __type(__y));
1078 template<typename _Tp, typename _Up>
1079 inline _GLIBCXX_CONSTEXPR
1080 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1081 pow(_Tp __x, _Up __y)
1083 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1084 return pow(__type(__x), __type(__y));
1087#if _GLIBCXX_USE_C99_MATH
1088#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
1090// These are possible macros imported from C99-land.
1098#undef isgreaterequal
1104#if __cplusplus >= 201103L
1106#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1108 fpclassify(float __x)
1109 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1110 FP_SUBNORMAL, FP_ZERO, __x); }
1113 fpclassify(double __x)
1114 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1115 FP_SUBNORMAL, FP_ZERO, __x); }
1118 fpclassify(long double __x)
1119 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1120 FP_SUBNORMAL, FP_ZERO, __x); }
1123#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1124 template<typename _Tp>
1125 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1128 { return __x != 0 ? FP_NORMAL : FP_ZERO; }
1131#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1134 { return __builtin_isfinite(__x); }
1137 isfinite(double __x)
1138 { return __builtin_isfinite(__x); }
1141 isfinite(long double __x)
1142 { return __builtin_isfinite(__x); }
1145#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1146 template<typename _Tp>
1147 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1153#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1156 { return __builtin_isinf(__x); }
1158#if _GLIBCXX_HAVE_OBSOLETE_ISINF \
1159 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
1164 { return __builtin_isinf(__x); }
1168 isinf(long double __x)
1169 { return __builtin_isinf(__x); }
1172#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1173 template<typename _Tp>
1174 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1180#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1183 { return __builtin_isnan(__x); }
1185#if _GLIBCXX_HAVE_OBSOLETE_ISNAN \
1186 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
1191 { return __builtin_isnan(__x); }
1195 isnan(long double __x)
1196 { return __builtin_isnan(__x); }
1199#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1200 template<typename _Tp>
1201 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1207#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1210 { return __builtin_isnormal(__x); }
1213 isnormal(double __x)
1214 { return __builtin_isnormal(__x); }
1217 isnormal(long double __x)
1218 { return __builtin_isnormal(__x); }
1221#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1222 template<typename _Tp>
1223 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1226 { return __x != 0 ? true : false; }
1229#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1230 // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic.
1233 { return __builtin_signbit(__x); }
1237 { return __builtin_signbit(__x); }
1240 signbit(long double __x)
1241 { return __builtin_signbit(__x); }
1244#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1245 template<typename _Tp>
1246 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1249 { return __x < 0 ? true : false; }
1252#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1254 isgreater(float __x, float __y)
1255 { return __builtin_isgreater(__x, __y); }
1258 isgreater(double __x, double __y)
1259 { return __builtin_isgreater(__x, __y); }
1262 isgreater(long double __x, long double __y)
1263 { return __builtin_isgreater(__x, __y); }
1266#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1267 template<typename _Tp, typename _Up>
1269 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1270 && __is_arithmetic<_Up>::__value), bool>::__type
1271 isgreater(_Tp __x, _Up __y)
1273 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1274 return __builtin_isgreater(__type(__x), __type(__y));
1278#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1280 isgreaterequal(float __x, float __y)
1281 { return __builtin_isgreaterequal(__x, __y); }
1284 isgreaterequal(double __x, double __y)
1285 { return __builtin_isgreaterequal(__x, __y); }
1288 isgreaterequal(long double __x, long double __y)
1289 { return __builtin_isgreaterequal(__x, __y); }
1292#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1293 template<typename _Tp, typename _Up>
1295 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1296 && __is_arithmetic<_Up>::__value), bool>::__type
1297 isgreaterequal(_Tp __x, _Up __y)
1299 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1300 return __builtin_isgreaterequal(__type(__x), __type(__y));
1304#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1306 isless(float __x, float __y)
1307 { return __builtin_isless(__x, __y); }
1310 isless(double __x, double __y)
1311 { return __builtin_isless(__x, __y); }
1314 isless(long double __x, long double __y)
1315 { return __builtin_isless(__x, __y); }
1318#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1319 template<typename _Tp, typename _Up>
1321 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1322 && __is_arithmetic<_Up>::__value), bool>::__type
1323 isless(_Tp __x, _Up __y)
1325 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1326 return __builtin_isless(__type(__x), __type(__y));
1330#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1332 islessequal(float __x, float __y)
1333 { return __builtin_islessequal(__x, __y); }
1336 islessequal(double __x, double __y)
1337 { return __builtin_islessequal(__x, __y); }
1340 islessequal(long double __x, long double __y)
1341 { return __builtin_islessequal(__x, __y); }
1344#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1345 template<typename _Tp, typename _Up>
1347 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1348 && __is_arithmetic<_Up>::__value), bool>::__type
1349 islessequal(_Tp __x, _Up __y)
1351 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1352 return __builtin_islessequal(__type(__x), __type(__y));
1356#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1358 islessgreater(float __x, float __y)
1359 { return __builtin_islessgreater(__x, __y); }
1362 islessgreater(double __x, double __y)
1363 { return __builtin_islessgreater(__x, __y); }
1366 islessgreater(long double __x, long double __y)
1367 { return __builtin_islessgreater(__x, __y); }
1370#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1371 template<typename _Tp, typename _Up>
1373 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1374 && __is_arithmetic<_Up>::__value), bool>::__type
1375 islessgreater(_Tp __x, _Up __y)
1377 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1378 return __builtin_islessgreater(__type(__x), __type(__y));
1382#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1384 isunordered(float __x, float __y)
1385 { return __builtin_isunordered(__x, __y); }
1388 isunordered(double __x, double __y)
1389 { return __builtin_isunordered(__x, __y); }
1392 isunordered(long double __x, long double __y)
1393 { return __builtin_isunordered(__x, __y); }
1396#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1397 template<typename _Tp, typename _Up>
1399 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
1400 && __is_arithmetic<_Up>::__value), bool>::__type
1401 isunordered(_Tp __x, _Up __y)
1403 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1404 return __builtin_isunordered(__type(__x), __type(__y));
1410 template<typename _Tp>
1411 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1415 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1416 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1417 FP_SUBNORMAL, FP_ZERO, __type(__f));
1420 template<typename _Tp>
1421 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1425 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1426 return __builtin_isfinite(__type(__f));
1429 template<typename _Tp>
1430 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1434 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1435 return __builtin_isinf(__type(__f));
1438 template<typename _Tp>
1439 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1443 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1444 return __builtin_isnan(__type(__f));
1447 template<typename _Tp>
1448 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1452 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1453 return __builtin_isnormal(__type(__f));
1456 template<typename _Tp>
1457 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1461 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1462 return __builtin_signbit(__type(__f));
1465 template<typename _Tp>
1466 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1468 isgreater(_Tp __f1, _Tp __f2)
1470 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1471 return __builtin_isgreater(__type(__f1), __type(__f2));
1474 template<typename _Tp>
1475 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1477 isgreaterequal(_Tp __f1, _Tp __f2)
1479 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1480 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
1483 template<typename _Tp>
1484 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1486 isless(_Tp __f1, _Tp __f2)
1488 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1489 return __builtin_isless(__type(__f1), __type(__f2));
1492 template<typename _Tp>
1493 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1495 islessequal(_Tp __f1, _Tp __f2)
1497 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1498 return __builtin_islessequal(__type(__f1), __type(__f2));
1501 template<typename _Tp>
1502 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1504 islessgreater(_Tp __f1, _Tp __f2)
1506 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1507 return __builtin_islessgreater(__type(__f1), __type(__f2));
1510 template<typename _Tp>
1511 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
1513 isunordered(_Tp __f1, _Tp __f2)
1515 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1516 return __builtin_isunordered(__type(__f1), __type(__f2));
1521#ifdef __STDCPP_FLOAT16_T__
1523 fpclassify(_Float16 __x)
1524 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1525 FP_SUBNORMAL, FP_ZERO, __x); }
1528 isfinite(_Float16 __x)
1529 { return __builtin_isfinite(__x); }
1533 { return __builtin_isinf(__x); }
1537 { return __builtin_isnan(__x); }
1540 isnormal(_Float16 __x)
1541 { return __builtin_isnormal(__x); }
1544 signbit(_Float16 __x)
1545 { return __builtin_signbit(__x); }
1548 isgreater(_Float16 __x, _Float16 __y)
1549 { return __builtin_isgreater(__x, __y); }
1552 isgreaterequal(_Float16 __x, _Float16 __y)
1553 { return __builtin_isgreaterequal(__x, __y); }
1556 isless(_Float16 __x, _Float16 __y)
1557 { return __builtin_isless(__x, __y); }
1560 islessequal(_Float16 __x, _Float16 __y)
1561 { return __builtin_islessequal(__x, __y); }
1564 islessgreater(_Float16 __x, _Float16 __y)
1565 { return __builtin_islessgreater(__x, __y); }
1568 isunordered(_Float16 __x, _Float16 __y)
1569 { return __builtin_isunordered(__x, __y); }
1572#ifdef __STDCPP_FLOAT32_T__
1574 fpclassify(_Float32 __x)
1575 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1576 FP_SUBNORMAL, FP_ZERO, __x); }
1579 isfinite(_Float32 __x)
1580 { return __builtin_isfinite(__x); }
1584 { return __builtin_isinf(__x); }
1588 { return __builtin_isnan(__x); }
1591 isnormal(_Float32 __x)
1592 { return __builtin_isnormal(__x); }
1595 signbit(_Float32 __x)
1596 { return __builtin_signbit(__x); }
1599 isgreater(_Float32 __x, _Float32 __y)
1600 { return __builtin_isgreater(__x, __y); }
1603 isgreaterequal(_Float32 __x, _Float32 __y)
1604 { return __builtin_isgreaterequal(__x, __y); }
1607 isless(_Float32 __x, _Float32 __y)
1608 { return __builtin_isless(__x, __y); }
1611 islessequal(_Float32 __x, _Float32 __y)
1612 { return __builtin_islessequal(__x, __y); }
1615 islessgreater(_Float32 __x, _Float32 __y)
1616 { return __builtin_islessgreater(__x, __y); }
1619 isunordered(_Float32 __x, _Float32 __y)
1620 { return __builtin_isunordered(__x, __y); }
1623#ifdef __STDCPP_FLOAT64_T__
1625 fpclassify(_Float64 __x)
1626 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1627 FP_SUBNORMAL, FP_ZERO, __x); }
1630 isfinite(_Float64 __x)
1631 { return __builtin_isfinite(__x); }
1635 { return __builtin_isinf(__x); }
1639 { return __builtin_isnan(__x); }
1642 isnormal(_Float64 __x)
1643 { return __builtin_isnormal(__x); }
1646 signbit(_Float64 __x)
1647 { return __builtin_signbit(__x); }
1650 isgreater(_Float64 __x, _Float64 __y)
1651 { return __builtin_isgreater(__x, __y); }
1654 isgreaterequal(_Float64 __x, _Float64 __y)
1655 { return __builtin_isgreaterequal(__x, __y); }
1658 isless(_Float64 __x, _Float64 __y)
1659 { return __builtin_isless(__x, __y); }
1662 islessequal(_Float64 __x, _Float64 __y)
1663 { return __builtin_islessequal(__x, __y); }
1666 islessgreater(_Float64 __x, _Float64 __y)
1667 { return __builtin_islessgreater(__x, __y); }
1670 isunordered(_Float64 __x, _Float64 __y)
1671 { return __builtin_isunordered(__x, __y); }
1674#ifdef __STDCPP_FLOAT128_T__
1676 fpclassify(_Float128 __x)
1677 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1678 FP_SUBNORMAL, FP_ZERO, __x); }
1681 isfinite(_Float128 __x)
1682 { return __builtin_isfinite(__x); }
1685 isinf(_Float128 __x)
1686 { return __builtin_isinf(__x); }
1689 isnan(_Float128 __x)
1690 { return __builtin_isnan(__x); }
1693 isnormal(_Float128 __x)
1694 { return __builtin_isnormal(__x); }
1697 signbit(_Float128 __x)
1698 { return __builtin_signbit(__x); }
1701 isgreater(_Float128 __x, _Float128 __y)
1702 { return __builtin_isgreater(__x, __y); }
1705 isgreaterequal(_Float128 __x, _Float128 __y)
1706 { return __builtin_isgreaterequal(__x, __y); }
1709 isless(_Float128 __x, _Float128 __y)
1710 { return __builtin_isless(__x, __y); }
1713 islessequal(_Float128 __x, _Float128 __y)
1714 { return __builtin_islessequal(__x, __y); }
1717 islessgreater(_Float128 __x, _Float128 __y)
1718 { return __builtin_islessgreater(__x, __y); }
1721 isunordered(_Float128 __x, _Float128 __y)
1722 { return __builtin_isunordered(__x, __y); }
1725#ifdef __STDCPP_BFLOAT16_T__
1727 fpclassify(__gnu_cxx::__bfloat16_t __x)
1728 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
1729 FP_SUBNORMAL, FP_ZERO, __x); }
1732 isfinite(__gnu_cxx::__bfloat16_t __x)
1733 { return __builtin_isfinite(__x); }
1736 isinf(__gnu_cxx::__bfloat16_t __x)
1737 { return __builtin_isinf(__x); }
1740 isnan(__gnu_cxx::__bfloat16_t __x)
1741 { return __builtin_isnan(__x); }
1744 isnormal(__gnu_cxx::__bfloat16_t __x)
1745 { return __builtin_isnormal(__x); }
1748 signbit(__gnu_cxx::__bfloat16_t __x)
1749 { return __builtin_signbit(__x); }
1752 isgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1753 { return __builtin_isgreater(__x, __y); }
1756 isgreaterequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1757 { return __builtin_isgreaterequal(__x, __y); }
1760 isless(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1761 { return __builtin_isless(__x, __y); }
1764 islessequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1765 { return __builtin_islessequal(__x, __y); }
1768 islessgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1769 { return __builtin_islessgreater(__x, __y); }
1772 isunordered(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
1773 { return __builtin_isunordered(__x, __y); }
1776#endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
1777#endif /* _GLIBCXX_USE_C99_MATH */
1779#if __cplusplus >= 201103L
1826#ifdef _GLIBCXX_HAVE_ACOSF
1829#ifdef _GLIBCXX_HAVE_ACOSL
1833#ifdef _GLIBCXX_HAVE_ASINF
1836#ifdef _GLIBCXX_HAVE_ASINL
1840#ifdef _GLIBCXX_HAVE_ATANF
1843#ifdef _GLIBCXX_HAVE_ATANL
1847#ifdef _GLIBCXX_HAVE_ATAN2F
1850#ifdef _GLIBCXX_HAVE_ATAN2L
1854#ifdef _GLIBCXX_HAVE_CEILF
1857#ifdef _GLIBCXX_HAVE_CEILL
1861#ifdef _GLIBCXX_HAVE_COSF
1864#ifdef _GLIBCXX_HAVE_COSL
1868#ifdef _GLIBCXX_HAVE_COSHF
1871#ifdef _GLIBCXX_HAVE_COSHL
1875#ifdef _GLIBCXX_HAVE_EXPF
1878#ifdef _GLIBCXX_HAVE_EXPL
1882#ifdef _GLIBCXX_HAVE_FABSF
1885#ifdef _GLIBCXX_HAVE_FABSL
1889#ifdef _GLIBCXX_HAVE_FLOORF
1892#ifdef _GLIBCXX_HAVE_FLOORL
1896#ifdef _GLIBCXX_HAVE_FMODF
1899#ifdef _GLIBCXX_HAVE_FMODL
1903#ifdef _GLIBCXX_HAVE_FREXPF
1906#ifdef _GLIBCXX_HAVE_FREXPL
1910#ifdef _GLIBCXX_HAVE_LDEXPF
1913#ifdef _GLIBCXX_HAVE_LDEXPL
1917#ifdef _GLIBCXX_HAVE_LOGF
1920#ifdef _GLIBCXX_HAVE_LOGL
1924#ifdef _GLIBCXX_HAVE_LOG10F
1927#ifdef _GLIBCXX_HAVE_LOG10L
1931#ifdef _GLIBCXX_HAVE_MODFF
1934#ifdef _GLIBCXX_HAVE_MODFL
1938#ifdef _GLIBCXX_HAVE_POWF
1941#ifdef _GLIBCXX_HAVE_POWL
1945#ifdef _GLIBCXX_HAVE_SINF
1948#ifdef _GLIBCXX_HAVE_SINL
1952#ifdef _GLIBCXX_HAVE_SINHF
1955#ifdef _GLIBCXX_HAVE_SINHL
1959#ifdef _GLIBCXX_HAVE_SQRTF
1962#ifdef _GLIBCXX_HAVE_SQRTL
1966#ifdef _GLIBCXX_HAVE_TANF
1969#ifdef _GLIBCXX_HAVE_TANL
1973#ifdef _GLIBCXX_HAVE_TANHF
1976#ifdef _GLIBCXX_HAVE_TANHL
1980#ifdef _GLIBCXX_USE_C99_MATH_FUNCS
2030#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
2090#ifdef _GLIBCXX_HAVE_C99_FLT_EVAL_TYPES
2161#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
2204 using ::nexttowardf;
2205 using ::nexttowardl;
2239 /// Additional overloads.
2240#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2243 { return __builtin_acoshf(__x); }
2245 constexpr long double
2246 acosh(long double __x)
2247 { return __builtin_acoshl(__x); }
2250#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2251 template<typename _Tp>
2252 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2255 { return __builtin_acosh(__x); }
2258#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2261 { return __builtin_asinhf(__x); }
2263 constexpr long double
2264 asinh(long double __x)
2265 { return __builtin_asinhl(__x); }
2268#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2269 template<typename _Tp>
2270 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2273 { return __builtin_asinh(__x); }
2276#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2279 { return __builtin_atanhf(__x); }
2281 constexpr long double
2282 atanh(long double __x)
2283 { return __builtin_atanhl(__x); }
2286#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2287 template<typename _Tp>
2288 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2291 { return __builtin_atanh(__x); }
2294#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2297 { return __builtin_cbrtf(__x); }
2299 constexpr long double
2300 cbrt(long double __x)
2301 { return __builtin_cbrtl(__x); }
2304#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2305 template<typename _Tp>
2306 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2309 { return __builtin_cbrt(__x); }
2312#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2314 copysign(float __x, float __y)
2315 { return __builtin_copysignf(__x, __y); }
2317 constexpr long double
2318 copysign(long double __x, long double __y)
2319 { return __builtin_copysignl(__x, __y); }
2322#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2325 { return __builtin_erff(__x); }
2327 constexpr long double
2328 erf(long double __x)
2329 { return __builtin_erfl(__x); }
2332#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2333 template<typename _Tp>
2334 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2337 { return __builtin_erf(__x); }
2340#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2343 { return __builtin_erfcf(__x); }
2345 constexpr long double
2346 erfc(long double __x)
2347 { return __builtin_erfcl(__x); }
2350#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2351 template<typename _Tp>
2352 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2355 { return __builtin_erfc(__x); }
2358#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2361 { return __builtin_exp2f(__x); }
2363 constexpr long double
2364 exp2(long double __x)
2365 { return __builtin_exp2l(__x); }
2368#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2369 template<typename _Tp>
2370 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2373 { return __builtin_exp2(__x); }
2376#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2379 { return __builtin_expm1f(__x); }
2381 constexpr long double
2382 expm1(long double __x)
2383 { return __builtin_expm1l(__x); }
2386#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2387 template<typename _Tp>
2388 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2391 { return __builtin_expm1(__x); }
2394#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2396 fdim(float __x, float __y)
2397 { return __builtin_fdimf(__x, __y); }
2399 constexpr long double
2400 fdim(long double __x, long double __y)
2401 { return __builtin_fdiml(__x, __y); }
2404#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2406 fma(float __x, float __y, float __z)
2407 { return __builtin_fmaf(__x, __y, __z); }
2409 constexpr long double
2410 fma(long double __x, long double __y, long double __z)
2411 { return __builtin_fmal(__x, __y, __z); }
2414#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2416 fmax(float __x, float __y)
2417 { return __builtin_fmaxf(__x, __y); }
2419 constexpr long double
2420 fmax(long double __x, long double __y)
2421 { return __builtin_fmaxl(__x, __y); }
2424#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2426 fmin(float __x, float __y)
2427 { return __builtin_fminf(__x, __y); }
2429 constexpr long double
2430 fmin(long double __x, long double __y)
2431 { return __builtin_fminl(__x, __y); }
2434#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2436 hypot(float __x, float __y)
2437 { return __builtin_hypotf(__x, __y); }
2439 constexpr long double
2440 hypot(long double __x, long double __y)
2441 { return __builtin_hypotl(__x, __y); }
2444#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2447 { return __builtin_ilogbf(__x); }
2450 ilogb(long double __x)
2451 { return __builtin_ilogbl(__x); }
2454#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2455 template<typename _Tp>
2457 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2460 { return __builtin_ilogb(__x); }
2463#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2466 { return __builtin_lgammaf(__x); }
2468 constexpr long double
2469 lgamma(long double __x)
2470 { return __builtin_lgammal(__x); }
2473#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2474 template<typename _Tp>
2475 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2478 { return __builtin_lgamma(__x); }
2481#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2484 { return __builtin_llrintf(__x); }
2487 llrint(long double __x)
2488 { return __builtin_llrintl(__x); }
2491#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2492 template<typename _Tp>
2493 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2496 { return __builtin_llrint(__x); }
2499#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2502 { return __builtin_llroundf(__x); }
2505 llround(long double __x)
2506 { return __builtin_llroundl(__x); }
2509#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2510 template<typename _Tp>
2511 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2514 { return __builtin_llround(__x); }
2517#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2520 { return __builtin_log1pf(__x); }
2522 constexpr long double
2523 log1p(long double __x)
2524 { return __builtin_log1pl(__x); }
2527#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2528 template<typename _Tp>
2529 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2532 { return __builtin_log1p(__x); }
2535#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2539 { return __builtin_log2f(__x); }
2541 constexpr long double
2542 log2(long double __x)
2543 { return __builtin_log2l(__x); }
2546#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2547 template<typename _Tp>
2548 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2551 { return __builtin_log2(__x); }
2554#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2557 { return __builtin_logbf(__x); }
2559 constexpr long double
2560 logb(long double __x)
2561 { return __builtin_logbl(__x); }
2564#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2565 template<typename _Tp>
2566 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2569 { return __builtin_logb(__x); }
2572#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2575 { return __builtin_lrintf(__x); }
2578 lrint(long double __x)
2579 { return __builtin_lrintl(__x); }
2582#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2583 template<typename _Tp>
2584 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2587 { return __builtin_lrint(__x); }
2590#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2593 { return __builtin_lroundf(__x); }
2596 lround(long double __x)
2597 { return __builtin_lroundl(__x); }
2600#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2601 template<typename _Tp>
2602 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2605 { return __builtin_lround(__x); }
2608#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2610 nearbyint(float __x)
2611 { return __builtin_nearbyintf(__x); }
2613 constexpr long double
2614 nearbyint(long double __x)
2615 { return __builtin_nearbyintl(__x); }
2618#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2619 template<typename _Tp>
2620 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2623 { return __builtin_nearbyint(__x); }
2626#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2628 nextafter(float __x, float __y)
2629 { return __builtin_nextafterf(__x, __y); }
2631 constexpr long double
2632 nextafter(long double __x, long double __y)
2633 { return __builtin_nextafterl(__x, __y); }
2636#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2638 nexttoward(float __x, long double __y)
2639 { return __builtin_nexttowardf(__x, __y); }
2641 constexpr long double
2642 nexttoward(long double __x, long double __y)
2643 { return __builtin_nexttowardl(__x, __y); }
2646#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2647 template<typename _Tp>
2648 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2650 nexttoward(_Tp __x, long double __y)
2651 { return __builtin_nexttoward(__x, __y); }
2654#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2656 remainder(float __x, float __y)
2657 { return __builtin_remainderf(__x, __y); }
2659 constexpr long double
2660 remainder(long double __x, long double __y)
2661 { return __builtin_remainderl(__x, __y); }
2664#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2666 remquo(float __x, float __y, int* __pquo)
2667 { return __builtin_remquof(__x, __y, __pquo); }
2670 remquo(long double __x, long double __y, int* __pquo)
2671 { return __builtin_remquol(__x, __y, __pquo); }
2674#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2677 { return __builtin_rintf(__x); }
2679 constexpr long double
2680 rint(long double __x)
2681 { return __builtin_rintl(__x); }
2684#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2685 template<typename _Tp>
2686 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2689 { return __builtin_rint(__x); }
2692#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2695 { return __builtin_roundf(__x); }
2697 constexpr long double
2698 round(long double __x)
2699 { return __builtin_roundl(__x); }
2702#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2703 template<typename _Tp>
2704 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2707 { return __builtin_round(__x); }
2710#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2712 scalbln(float __x, long __ex)
2713 { return __builtin_scalblnf(__x, __ex); }
2715 constexpr long double
2716 scalbln(long double __x, long __ex)
2717 { return __builtin_scalblnl(__x, __ex); }
2720#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2721 template<typename _Tp>
2722 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2724 scalbln(_Tp __x, long __ex)
2725 { return __builtin_scalbln(__x, __ex); }
2728#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2730 scalbn(float __x, int __ex)
2731 { return __builtin_scalbnf(__x, __ex); }
2733 constexpr long double
2734 scalbn(long double __x, int __ex)
2735 { return __builtin_scalbnl(__x, __ex); }
2738#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2739 template<typename _Tp>
2740 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2742 scalbn(_Tp __x, int __ex)
2743 { return __builtin_scalbn(__x, __ex); }
2746#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2749 { return __builtin_tgammaf(__x); }
2751 constexpr long double
2752 tgamma(long double __x)
2753 { return __builtin_tgammal(__x); }
2756#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2757 template<typename _Tp>
2758 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2761 { return __builtin_tgamma(__x); }
2764#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
2767 { return __builtin_truncf(__x); }
2769 constexpr long double
2770 trunc(long double __x)
2771 { return __builtin_truncl(__x); }
2774#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
2775 template<typename _Tp>
2776 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
2779 { return __builtin_trunc(__x); }
2782#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2785 { return _Float16(__builtin_acoshf(__x)); }
2789 { return _Float16(__builtin_asinhf(__x)); }
2793 { return _Float16(__builtin_atanhf(__x)); }
2797 { return _Float16(__builtin_cbrtf(__x)); }
2800 copysign(_Float16 __x, _Float16 __y)
2801 { return __builtin_copysignf16(__x, __y); }
2805 { return _Float16(__builtin_erff(__x)); }
2809 { return _Float16(__builtin_erfcf(__x)); }
2813 { return _Float16(__builtin_exp2f(__x)); }
2817 { return _Float16(__builtin_expm1f(__x)); }
2820 fdim(_Float16 __x, _Float16 __y)
2821 { return _Float16(__builtin_fdimf(__x, __y)); }
2824 fma(_Float16 __x, _Float16 __y, _Float16 __z)
2825 { return _Float16(__builtin_fmaf(__x, __y, __z)); }
2828 fmax(_Float16 __x, _Float16 __y)
2829 { return _Float16(__builtin_fmaxf(__x, __y)); }
2832 fmin(_Float16 __x, _Float16 __y)
2833 { return _Float16(__builtin_fminf(__x, __y)); }
2836 hypot(_Float16 __x, _Float16 __y)
2837 { return _Float16(__builtin_hypotf(__x, __y)); }
2841 { return __builtin_ilogbf(__x); }
2844 lgamma(_Float16 __x)
2845 { return _Float16(__builtin_lgammaf(__x)); }
2848 llrint(_Float16 __x)
2849 { return __builtin_llrintf(__x); }
2852 llround(_Float16 __x)
2853 { return __builtin_llroundf(__x); }
2857 { return _Float16(__builtin_log1pf(__x)); }
2862 { return _Float16(__builtin_log2f(__x)); }
2866 { return _Float16(__builtin_logbf(__x)); }
2870 { return __builtin_lrintf(__x); }
2873 lround(_Float16 __x)
2874 { return __builtin_lroundf(__x); }
2877 nearbyint(_Float16 __x)
2878 { return _Float16(__builtin_nearbyintf(__x)); }
2881 nextafter(_Float16 __x, _Float16 __y)
2883#if __cpp_if_consteval >= 202106L
2884 // Can't use if (std::__is_constant_evaluated()) here, as it
2885 // doesn't guarantee optimizing the body away at -O0 and
2886 // nothing defines nextafterf16.
2887 if consteval { return __builtin_nextafterf16(__x, __y); }
2889#ifdef __INT16_TYPE__
2890 using __float16_int_type = __INT16_TYPE__;
2892 using __float16_int_type = short int;
2894 __float16_int_type __hx, __hy, __ix, __iy;
2895 __builtin_memcpy(&__hx, &__x, sizeof(__x));
2896 __builtin_memcpy(&__hy, &__y, sizeof(__x));
2897 __ix = __hx & 0x7fff; // |x|
2898 __iy = __hy & 0x7fff; // |y|
2899 if (__ix > 0x7c00 || __iy > 0x7c00) // x or y is NaN
2902 return __y; // x == y, return y
2903 if (__ix == 0) // x == 0
2905 __hy = (__hy & 0x8000) | 1; // return +-__FLT16_DENORM_MIN__
2906 __builtin_memcpy(&__x, &__hy, sizeof(__x));
2907 __builtin_nextafterf(0.0f, 1.0f); // raise underflow
2910 if (__hx >= 0) // x > 0
2912 if (__hx > __hy) // x > y, x -= ulp
2914 else // x < y, x += ulp
2919 if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp
2921 else // x > y, x += ulp
2924 __hy = __hx & 0x7c00;
2926 __builtin_nextafterf(__FLT_MAX__, __builtin_inff()); // overflow
2927 else if (__hy < 0x0400)
2928 __builtin_nextafterf(__FLT_MIN__, 0.0f); // underflow
2929 __builtin_memcpy(&__x, &__hx, sizeof(__x));
2934 remainder(_Float16 __x, _Float16 __y)
2935 { return _Float16(__builtin_remainderf(__x, __y)); }
2938 remquo(_Float16 __x, _Float16 __y, int* __pquo)
2939 { return _Float16(__builtin_remquof(__x, __y, __pquo)); }
2943 { return _Float16(__builtin_rintf(__x)); }
2947 { return _Float16(__builtin_roundf(__x)); }
2950 scalbln(_Float16 __x, long __ex)
2951 { return _Float16(__builtin_scalblnf(__x, __ex)); }
2954 scalbn(_Float16 __x, int __ex)
2955 { return _Float16(__builtin_scalbnf(__x, __ex)); }
2958 tgamma(_Float16 __x)
2959 { return _Float16(__builtin_tgammaf(__x)); }
2963 { return _Float16(__builtin_truncf(__x)); }
2966#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
2969 { return __builtin_acoshf(__x); }
2973 { return __builtin_asinhf(__x); }
2977 { return __builtin_atanhf(__x); }
2981 { return __builtin_cbrtf(__x); }
2984 copysign(_Float32 __x, _Float32 __y)
2985 { return __builtin_copysignf(__x, __y); }
2989 { return __builtin_erff(__x); }
2993 { return __builtin_erfcf(__x); }
2997 { return __builtin_exp2f(__x); }
3001 { return __builtin_expm1f(__x); }
3004 fdim(_Float32 __x, _Float32 __y)
3005 { return __builtin_fdimf(__x, __y); }
3008 fma(_Float32 __x, _Float32 __y, _Float32 __z)
3009 { return __builtin_fmaf(__x, __y, __z); }
3012 fmax(_Float32 __x, _Float32 __y)
3013 { return __builtin_fmaxf(__x, __y); }
3016 fmin(_Float32 __x, _Float32 __y)
3017 { return __builtin_fminf(__x, __y); }
3020 hypot(_Float32 __x, _Float32 __y)
3021 { return __builtin_hypotf(__x, __y); }
3025 { return __builtin_ilogbf(__x); }
3028 lgamma(_Float32 __x)
3029 { return __builtin_lgammaf(__x); }
3032 llrint(_Float32 __x)
3033 { return __builtin_llrintf(__x); }
3036 llround(_Float32 __x)
3037 { return __builtin_llroundf(__x); }
3041 { return __builtin_log1pf(__x); }
3046 { return __builtin_log2f(__x); }
3050 { return __builtin_logbf(__x); }
3054 { return __builtin_lrintf(__x); }
3057 lround(_Float32 __x)
3058 { return __builtin_lroundf(__x); }
3061 nearbyint(_Float32 __x)
3062 { return __builtin_nearbyintf(__x); }
3065 nextafter(_Float32 __x, _Float32 __y)
3066 { return __builtin_nextafterf(__x, __y); }
3069 remainder(_Float32 __x, _Float32 __y)
3070 { return __builtin_remainderf(__x, __y); }
3073 remquo(_Float32 __x, _Float32 __y, int* __pquo)
3074 { return __builtin_remquof(__x, __y, __pquo); }
3078 { return __builtin_rintf(__x); }
3082 { return __builtin_roundf(__x); }
3085 scalbln(_Float32 __x, long __ex)
3086 { return __builtin_scalblnf(__x, __ex); }
3089 scalbn(_Float32 __x, int __ex)
3090 { return __builtin_scalbnf(__x, __ex); }
3093 tgamma(_Float32 __x)
3094 { return __builtin_tgammaf(__x); }
3098 { return __builtin_truncf(__x); }
3101#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
3104 { return __builtin_acosh(__x); }
3108 { return __builtin_asinh(__x); }
3112 { return __builtin_atanh(__x); }
3116 { return __builtin_cbrt(__x); }
3119 copysign(_Float64 __x, _Float64 __y)
3120 { return __builtin_copysign(__x, __y); }
3124 { return __builtin_erf(__x); }
3128 { return __builtin_erfc(__x); }
3132 { return __builtin_exp2(__x); }
3136 { return __builtin_expm1(__x); }
3139 fdim(_Float64 __x, _Float64 __y)
3140 { return __builtin_fdim(__x, __y); }
3143 fma(_Float64 __x, _Float64 __y, _Float64 __z)
3144 { return __builtin_fma(__x, __y, __z); }
3147 fmax(_Float64 __x, _Float64 __y)
3148 { return __builtin_fmax(__x, __y); }
3151 fmin(_Float64 __x, _Float64 __y)
3152 { return __builtin_fmin(__x, __y); }
3155 hypot(_Float64 __x, _Float64 __y)
3156 { return __builtin_hypot(__x, __y); }
3160 { return __builtin_ilogb(__x); }
3163 lgamma(_Float64 __x)
3164 { return __builtin_lgamma(__x); }
3167 llrint(_Float64 __x)
3168 { return __builtin_llrint(__x); }
3171 llround(_Float64 __x)
3172 { return __builtin_llround(__x); }
3176 { return __builtin_log1p(__x); }
3181 { return __builtin_log2(__x); }
3185 { return __builtin_logb(__x); }
3189 { return __builtin_lrint(__x); }
3192 lround(_Float64 __x)
3193 { return __builtin_lround(__x); }
3196 nearbyint(_Float64 __x)
3197 { return __builtin_nearbyint(__x); }
3200 nextafter(_Float64 __x, _Float64 __y)
3201 { return __builtin_nextafter(__x, __y); }
3204 remainder(_Float64 __x, _Float64 __y)
3205 { return __builtin_remainder(__x, __y); }
3208 remquo(_Float64 __x, _Float64 __y, int* __pquo)
3209 { return __builtin_remquo(__x, __y, __pquo); }
3213 { return __builtin_rint(__x); }
3217 { return __builtin_round(__x); }
3220 scalbln(_Float64 __x, long __ex)
3221 { return __builtin_scalbln(__x, __ex); }
3224 scalbn(_Float64 __x, int __ex)
3225 { return __builtin_scalbn(__x, __ex); }
3228 tgamma(_Float64 __x)
3229 { return __builtin_tgamma(__x); }
3233 { return __builtin_trunc(__x); }
3236#if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
3238 acosh(_Float128 __x)
3239 { return __builtin_acoshl(__x); }
3242 asinh(_Float128 __x)
3243 { return __builtin_asinhl(__x); }
3246 atanh(_Float128 __x)
3247 { return __builtin_atanhl(__x); }
3251 { return __builtin_cbrtl(__x); }
3254 copysign(_Float128 __x, _Float128 __y)
3255 { return __builtin_copysignl(__x, __y); }
3259 { return __builtin_erfl(__x); }
3263 { return __builtin_erfcl(__x); }
3267 { return __builtin_exp2l(__x); }
3270 expm1(_Float128 __x)
3271 { return __builtin_expm1l(__x); }
3274 fdim(_Float128 __x, _Float128 __y)
3275 { return __builtin_fdiml(__x, __y); }
3278 fma(_Float128 __x, _Float128 __y, _Float128 __z)
3279 { return __builtin_fmal(__x, __y, __z); }
3282 fmax(_Float128 __x, _Float128 __y)
3283 { return __builtin_fmaxl(__x, __y); }
3286 fmin(_Float128 __x, _Float128 __y)
3287 { return __builtin_fminl(__x, __y); }
3290 hypot(_Float128 __x, _Float128 __y)
3291 { return __builtin_hypotl(__x, __y); }
3294 ilogb(_Float128 __x)
3295 { return __builtin_ilogbl(__x); }
3298 lgamma(_Float128 __x)
3299 { return __builtin_lgammal(__x); }
3302 llrint(_Float128 __x)
3303 { return __builtin_llrintl(__x); }
3306 llround(_Float128 __x)
3307 { return __builtin_llroundl(__x); }
3310 log1p(_Float128 __x)
3311 { return __builtin_log1pl(__x); }
3316 { return __builtin_log2l(__x); }
3320 { return __builtin_logbl(__x); }
3323 lrint(_Float128 __x)
3324 { return __builtin_lrintl(__x); }
3327 lround(_Float128 __x)
3328 { return __builtin_lroundl(__x); }
3331 nearbyint(_Float128 __x)
3332 { return __builtin_nearbyintl(__x); }
3335 nextafter(_Float128 __x, _Float128 __y)
3336 { return __builtin_nextafterl(__x, __y); }
3339 remainder(_Float128 __x, _Float128 __y)
3340 { return __builtin_remainderl(__x, __y); }
3343 remquo(_Float128 __x, _Float128 __y, int* __pquo)
3344 { return __builtin_remquol(__x, __y, __pquo); }
3348 { return __builtin_rintl(__x); }
3351 round(_Float128 __x)
3352 { return __builtin_roundl(__x); }
3355 scalbln(_Float128 __x, long __ex)
3356 { return __builtin_scalblnl(__x, __ex); }
3359 scalbn(_Float128 __x, int __ex)
3360 { return __builtin_scalbnl(__x, __ex); }
3363 tgamma(_Float128 __x)
3364 { return __builtin_tgammal(__x); }
3367 trunc(_Float128 __x)
3368 { return __builtin_truncl(__x); }
3369#elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
3371 acosh(_Float128 __x)
3372 { return __builtin_acoshf128(__x); }
3375 asinh(_Float128 __x)
3376 { return __builtin_asinhf128(__x); }
3379 atanh(_Float128 __x)
3380 { return __builtin_atanhf128(__x); }
3384 { return __builtin_cbrtf128(__x); }
3387 copysign(_Float128 __x, _Float128 __y)
3388 { return __builtin_copysignf128(__x, __y); }
3392 { return __builtin_erff128(__x); }
3396 { return __builtin_erfcf128(__x); }
3400 { return __builtin_exp2f128(__x); }
3403 expm1(_Float128 __x)
3404 { return __builtin_expm1f128(__x); }
3407 fdim(_Float128 __x, _Float128 __y)
3408 { return __builtin_fdimf128(__x, __y); }
3411 fma(_Float128 __x, _Float128 __y, _Float128 __z)
3412 { return __builtin_fmaf128(__x, __y, __z); }
3415 fmax(_Float128 __x, _Float128 __y)
3416 { return __builtin_fmaxf128(__x, __y); }
3419 fmin(_Float128 __x, _Float128 __y)
3420 { return __builtin_fminf128(__x, __y); }
3423 hypot(_Float128 __x, _Float128 __y)
3424 { return __builtin_hypotf128(__x, __y); }
3427 ilogb(_Float128 __x)
3428 { return __builtin_ilogbf128(__x); }
3431 lgamma(_Float128 __x)
3432 { return __builtin_lgammaf128(__x); }
3435 llrint(_Float128 __x)
3436 { return __builtin_llrintf128(__x); }
3439 llround(_Float128 __x)
3440 { return __builtin_llroundf128(__x); }
3443 log1p(_Float128 __x)
3444 { return __builtin_log1pf128(__x); }
3449 { return __builtin_log2f128(__x); }
3453 { return __builtin_logbf128(__x); }
3456 lrint(_Float128 __x)
3457 { return __builtin_lrintf128(__x); }
3460 lround(_Float128 __x)
3461 { return __builtin_lroundf128(__x); }
3464 nearbyint(_Float128 __x)
3465 { return __builtin_nearbyintf128(__x); }
3468 nextafter(_Float128 __x, _Float128 __y)
3469 { return __builtin_nextafterf128(__x, __y); }
3472 remainder(_Float128 __x, _Float128 __y)
3473 { return __builtin_remainderf128(__x, __y); }
3476 remquo(_Float128 __x, _Float128 __y, int* __pquo)
3477 { return __builtin_remquof128(__x, __y, __pquo); }
3481 { return __builtin_rintf128(__x); }
3484 round(_Float128 __x)
3485 { return __builtin_roundf128(__x); }
3488 scalbln(_Float128 __x, long __ex)
3489 { return __builtin_scalblnf128(__x, __ex); }
3492 scalbn(_Float128 __x, int __ex)
3493 { return __builtin_scalbnf128(__x, __ex); }
3496 tgamma(_Float128 __x)
3497 { return __builtin_tgammaf128(__x); }
3500 trunc(_Float128 __x)
3501 { return __builtin_truncf128(__x); }
3504#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3505 constexpr __gnu_cxx::__bfloat16_t
3506 acosh(__gnu_cxx::__bfloat16_t __x)
3507 { return __gnu_cxx::__bfloat16_t(__builtin_acoshf(__x)); }
3509 constexpr __gnu_cxx::__bfloat16_t
3510 asinh(__gnu_cxx::__bfloat16_t __x)
3511 { return __gnu_cxx::__bfloat16_t(__builtin_asinhf(__x)); }
3513 constexpr __gnu_cxx::__bfloat16_t
3514 atanh(__gnu_cxx::__bfloat16_t __x)
3515 { return __gnu_cxx::__bfloat16_t(__builtin_atanhf(__x)); }
3517 constexpr __gnu_cxx::__bfloat16_t
3518 cbrt(__gnu_cxx::__bfloat16_t __x)
3519 { return __gnu_cxx::__bfloat16_t(__builtin_cbrtf(__x)); }
3521 constexpr __gnu_cxx::__bfloat16_t
3522 copysign(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3523 { return __gnu_cxx::__bfloat16_t(__builtin_copysignf(__x, __y)); }
3525 constexpr __gnu_cxx::__bfloat16_t
3526 erf(__gnu_cxx::__bfloat16_t __x)
3527 { return __gnu_cxx::__bfloat16_t(__builtin_erff(__x)); }
3529 constexpr __gnu_cxx::__bfloat16_t
3530 erfc(__gnu_cxx::__bfloat16_t __x)
3531 { return __gnu_cxx::__bfloat16_t(__builtin_erfcf(__x)); }
3533 constexpr __gnu_cxx::__bfloat16_t
3534 exp2(__gnu_cxx::__bfloat16_t __x)
3535 { return __gnu_cxx::__bfloat16_t(__builtin_exp2f(__x)); }
3537 constexpr __gnu_cxx::__bfloat16_t
3538 expm1(__gnu_cxx::__bfloat16_t __x)
3539 { return __gnu_cxx::__bfloat16_t(__builtin_expm1f(__x)); }
3541 constexpr __gnu_cxx::__bfloat16_t
3542 fdim(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3543 { return __gnu_cxx::__bfloat16_t(__builtin_fdimf(__x, __y)); }
3545 constexpr __gnu_cxx::__bfloat16_t
3546 fma(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z)
3547 { return __gnu_cxx::__bfloat16_t(__builtin_fmaf(__x, __y, __z)); }
3549 constexpr __gnu_cxx::__bfloat16_t
3550 fmax(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3551 { return __gnu_cxx::__bfloat16_t(__builtin_fmaxf(__x, __y)); }
3553 constexpr __gnu_cxx::__bfloat16_t
3554 fmin(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3555 { return __gnu_cxx::__bfloat16_t(__builtin_fminf(__x, __y)); }
3557 constexpr __gnu_cxx::__bfloat16_t
3558 hypot(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3559 { return __gnu_cxx::__bfloat16_t(__builtin_hypotf(__x, __y)); }
3562 ilogb(__gnu_cxx::__bfloat16_t __x)
3563 { return __builtin_ilogbf(__x); }
3565 constexpr __gnu_cxx::__bfloat16_t
3566 lgamma(__gnu_cxx::__bfloat16_t __x)
3567 { return __gnu_cxx::__bfloat16_t(__builtin_lgammaf(__x)); }
3570 llrint(__gnu_cxx::__bfloat16_t __x)
3571 { return __builtin_llrintf(__x); }
3574 llround(__gnu_cxx::__bfloat16_t __x)
3575 { return __builtin_llroundf(__x); }
3577 constexpr __gnu_cxx::__bfloat16_t
3578 log1p(__gnu_cxx::__bfloat16_t __x)
3579 { return __gnu_cxx::__bfloat16_t(__builtin_log1pf(__x)); }
3582 constexpr __gnu_cxx::__bfloat16_t
3583 log2(__gnu_cxx::__bfloat16_t __x)
3584 { return __gnu_cxx::__bfloat16_t(__builtin_log2f(__x)); }
3586 constexpr __gnu_cxx::__bfloat16_t
3587 logb(__gnu_cxx::__bfloat16_t __x)
3588 { return __gnu_cxx::__bfloat16_t(__builtin_logbf(__x)); }
3591 lrint(__gnu_cxx::__bfloat16_t __x)
3592 { return __builtin_lrintf(__x); }
3595 lround(__gnu_cxx::__bfloat16_t __x)
3596 { return __builtin_lroundf(__x); }
3598 constexpr __gnu_cxx::__bfloat16_t
3599 nearbyint(__gnu_cxx::__bfloat16_t __x)
3600 { return __gnu_cxx::__bfloat16_t(__builtin_nearbyintf(__x)); }
3602 constexpr __gnu_cxx::__bfloat16_t
3603 nextafter(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3605#if __cpp_if_consteval >= 202106L
3606 // Can't use if (std::__is_constant_evaluated()) here, as it
3607 // doesn't guarantee optimizing the body away at -O0 and
3608 // nothing defines nextafterf16b.
3609 if consteval { return __builtin_nextafterf16b(__x, __y); }
3611#ifdef __INT16_TYPE__
3612 using __bfloat16_int_type = __INT16_TYPE__;
3614 using __bfloat16_int_type = short int;
3616 __bfloat16_int_type __hx, __hy, __ix, __iy;
3617 __builtin_memcpy(&__hx, &__x, sizeof(__x));
3618 __builtin_memcpy(&__hy, &__y, sizeof(__x));
3619 __ix = __hx & 0x7fff; // |x|
3620 __iy = __hy & 0x7fff; // |y|
3621 if (__ix > 0x7f80 || __iy > 0x7f80) // x or y is NaN
3624 return __y; // x == y, return y
3625 if (__ix == 0) // x == 0
3627 __hy = (__hy & 0x8000) | 1; // return +-__BFLT16_DENORM_MIN__
3628 __builtin_memcpy(&__x, &__hy, sizeof(__x));
3629 __builtin_nextafterf(0.0f, 1.0f); // raise underflow
3632 if (__hx >= 0) // x > 0
3634 if (__hx > __hy) // x > y, x -= ulp
3636 else // x < y, x += ulp
3641 if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp
3643 else // x > y, x += ulp
3646 __hy = __hx & 0x7f80;
3648 __builtin_nextafterf(__FLT_MAX__, __builtin_inff()); // overflow
3649 else if (__hy < 0x0080)
3650 __builtin_nextafterf(__FLT_MIN__, 0.0f); // underflow
3651 __builtin_memcpy(&__x, &__hx, sizeof(__x));
3655 constexpr __gnu_cxx::__bfloat16_t
3656 remainder(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
3657 { return __gnu_cxx::__bfloat16_t(__builtin_remainderf(__x, __y)); }
3659 inline __gnu_cxx::__bfloat16_t
3660 remquo(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, int* __pquo)
3661 { return __gnu_cxx::__bfloat16_t(__builtin_remquof(__x, __y, __pquo)); }
3663 constexpr __gnu_cxx::__bfloat16_t
3664 rint(__gnu_cxx::__bfloat16_t __x)
3665 { return __gnu_cxx::__bfloat16_t(__builtin_rintf(__x)); }
3667 constexpr __gnu_cxx::__bfloat16_t
3668 round(__gnu_cxx::__bfloat16_t __x)
3669 { return __gnu_cxx::__bfloat16_t(__builtin_roundf(__x)); }
3671 constexpr __gnu_cxx::__bfloat16_t
3672 scalbln(__gnu_cxx::__bfloat16_t __x, long __ex)
3673 { return __gnu_cxx::__bfloat16_t(__builtin_scalblnf(__x, __ex)); }
3675 constexpr __gnu_cxx::__bfloat16_t
3676 scalbn(__gnu_cxx::__bfloat16_t __x, int __ex)
3677 { return __gnu_cxx::__bfloat16_t(__builtin_scalbnf(__x, __ex)); }
3679 constexpr __gnu_cxx::__bfloat16_t
3680 tgamma(__gnu_cxx::__bfloat16_t __x)
3681 { return __gnu_cxx::__bfloat16_t(__builtin_tgammaf(__x)); }
3683 constexpr __gnu_cxx::__bfloat16_t
3684 trunc(__gnu_cxx::__bfloat16_t __x)
3685 { return __gnu_cxx::__bfloat16_t(__builtin_truncf(__x)); }
3688#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
3689 template<typename _Tp, typename _Up>
3690 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3691 copysign(_Tp __x, _Up __y)
3693 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3694 return copysign(__type(__x), __type(__y));
3697 template<typename _Tp, typename _Up>
3698 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3699 fdim(_Tp __x, _Up __y)
3701 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3702 return fdim(__type(__x), __type(__y));
3705 template<typename _Tp, typename _Up>
3706 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3707 fmax(_Tp __x, _Up __y)
3709 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3710 return fmax(__type(__x), __type(__y));
3713 template<typename _Tp, typename _Up>
3714 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3715 fmin(_Tp __x, _Up __y)
3717 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3718 return fmin(__type(__x), __type(__y));
3721 template<typename _Tp, typename _Up>
3722 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3723 hypot(_Tp __x, _Up __y)
3725 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3726 return hypot(__type(__x), __type(__y));
3729 template<typename _Tp, typename _Up>
3730 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3731 nextafter(_Tp __x, _Up __y)
3733 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3734 return nextafter(__type(__x), __type(__y));
3737 template<typename _Tp, typename _Up>
3738 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3739 remainder(_Tp __x, _Up __y)
3741 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3742 return remainder(__type(__x), __type(__y));
3745 template<typename _Tp, typename _Up>
3746 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
3747 remquo(_Tp __x, _Up __y, int* __pquo)
3749 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
3750 return remquo(__type(__x), __type(__y), __pquo);
3753 template<typename _Tp, typename _Up, typename _Vp>
3754 constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
3755 fma(_Tp __x, _Up __y, _Vp __z)
3757 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
3758 return fma(__type(__x), __type(__y), __type(__z));
3762#endif // _GLIBCXX_USE_C99_MATH_FUNCS
3765#ifdef __cpp_lib_hypot // C++ >= 17 && HOSTED
3766 // [c.math.hypot3], three-dimensional hypotenuse
3767 template<typename _Tp>
3769 __hypot3(_Tp __x, _Tp __y, _Tp __z)
3771 __x = std::abs(__x);
3772 __y = std::abs(__y);
3773 __z = std::abs(__z);
3774 if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x)
3775 return __a * std::sqrt((__x / __a) * (__x / __a)
3776 + (__y / __a) * (__y / __a)
3777 + (__z / __a) * (__z / __a));
3783 hypot(float __x, float __y, float __z)
3784 { return std::__hypot3<float>(__x, __y, __z); }
3787 hypot(double __x, double __y, double __z)
3788 { return std::__hypot3<double>(__x, __y, __z); }
3791 hypot(long double __x, long double __y, long double __z)
3792 { return std::__hypot3<long double>(__x, __y, __z); }
3794 template<typename _Tp, typename _Up, typename _Vp>
3795 typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
3796 hypot(_Tp __x, _Up __y, _Vp __z)
3798 using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type;
3799 return std::__hypot3<__type>(__x, __y, __z);
3802#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3804 hypot(_Float16 __x, _Float16 __y, _Float16 __z)
3805 { return std::__hypot3<_Float16>(__x, __y, __z); }
3808#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3810 hypot(_Float32 __x, _Float32 __y, _Float32 __z)
3811 { return std::__hypot3<_Float32>(__x, __y, __z); }
3814#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
3816 hypot(_Float64 __x, _Float64 __y, _Float64 __z)
3817 { return std::__hypot3<_Float64>(__x, __y, __z); }
3820#if defined(__STDCPP_FLOAT128_T__) \
3821 && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \
3822 || defined(_GLIBCXX_HAVE_FLOAT128_MATH))
3824 hypot(_Float128 __x, _Float128 __y, _Float128 __z)
3825 { return std::__hypot3<_Float128>(__x, __y, __z); }
3828#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3829 inline __gnu_cxx::__bfloat16_t
3830 hypot(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z)
3831 { return std::__hypot3<__gnu_cxx::__bfloat16_t>(__x, __y, __z); }
3834#endif // __cpp_lib_hypot
3836#ifdef __cpp_lib_interpolate // C++ >= 20
3837 // linear interpolation
3838 template<typename _Fp>
3840 __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept
3842 if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
3843 return __t * __b + (1 - __t) * __a;
3846 return __b; // exact
3848 // Exact at __t=0, monotonic except near __t=1,
3849 // bounded, determinate, and consistent:
3850 const _Fp __x = __a + __t * (__b - __a);
3851 return (__t > 1) == (__b > __a)
3852 ? (__b < __x ? __x : __b)
3853 : (__b > __x ? __x : __b); // monotonic near __t=1
3857 lerp(float __a, float __b, float __t) noexcept
3858 { return std::__lerp(__a, __b, __t); }
3861 lerp(double __a, double __b, double __t) noexcept
3862 { return std::__lerp(__a, __b, __t); }
3864 constexpr long double
3865 lerp(long double __a, long double __b, long double __t) noexcept
3866 { return std::__lerp(__a, __b, __t); }
3868 template<typename _Tp, typename _Up, typename _Vp>
3869 constexpr __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>
3870 lerp(_Tp __x, _Up __y, _Vp __z) noexcept
3872 using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>;
3873 return std::__lerp<__type>(__x, __y, __z);
3876#if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3878 lerp(_Float16 __x, _Float16 __y, _Float16 __z) noexcept
3879 { return std::__lerp<_Float16>(__x, __y, __z); }
3882#if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3884 lerp(_Float32 __x, _Float32 __y, _Float32 __z) noexcept
3885 { return std::__lerp<_Float32>(__x, __y, __z); }
3888#if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
3890 lerp(_Float64 __x, _Float64 __y, _Float64 __z) noexcept
3891 { return std::__lerp<_Float64>(__x, __y, __z); }
3894#if defined(__STDCPP_FLOAT128_T__) \
3895 && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \
3896 || defined(_GLIBCXX_HAVE_FLOAT128_MATH))
3898 lerp(_Float128 __x, _Float128 __y, _Float128 __z) noexcept
3899 { return std::__lerp<_Float128>(__x, __y, __z); }
3902#if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
3903 inline __gnu_cxx::__bfloat16_t
3904 lerp(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z) noexcept
3905 { return std::__lerp<__gnu_cxx::__bfloat16_t>(__x, __y, __z); }
3907#endif // __cpp_lib_interpolate
3909_GLIBCXX_END_NAMESPACE_VERSION
3912#if _GLIBCXX_USE_STD_SPEC_FUNCS
3913# include <bits/specfun.h>