libstdc++
|
00001 // -*- C++ -*- C forwarding header. 00002 00003 // Copyright (C) 1997-2019 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /** @file include/cmath 00026 * This is a Standard C++ Library file. You should @c \#include this file 00027 * in your programs, rather than any of the @a *.h implementation files. 00028 * 00029 * This is the C++ version of the Standard C Library header @c math.h, 00030 * and its contents are (mostly) the same as that header, but are all 00031 * contained in the namespace @c std (except for names which are defined 00032 * as macros in C). 00033 */ 00034 00035 // 00036 // ISO C++ 14882: 26.5 C library 00037 // 00038 00039 #pragma GCC system_header 00040 00041 #include <bits/c++config.h> 00042 #include <bits/cpp_type_traits.h> 00043 #include <ext/type_traits.h> 00044 #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS 00045 #include_next <math.h> 00046 #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS 00047 #include <bits/std_abs.h> 00048 00049 #ifndef _GLIBCXX_CMATH 00050 #define _GLIBCXX_CMATH 1 00051 00052 // Get rid of those macros defined in <math.h> in lieu of real functions. 00053 #undef div 00054 #undef acos 00055 #undef asin 00056 #undef atan 00057 #undef atan2 00058 #undef ceil 00059 #undef cos 00060 #undef cosh 00061 #undef exp 00062 #undef fabs 00063 #undef floor 00064 #undef fmod 00065 #undef frexp 00066 #undef ldexp 00067 #undef log 00068 #undef log10 00069 #undef modf 00070 #undef pow 00071 #undef sin 00072 #undef sinh 00073 #undef sqrt 00074 #undef tan 00075 #undef tanh 00076 00077 extern "C++" 00078 { 00079 namespace std _GLIBCXX_VISIBILITY(default) 00080 { 00081 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00082 00083 using ::acos; 00084 00085 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00086 inline _GLIBCXX_CONSTEXPR float 00087 acos(float __x) 00088 { return __builtin_acosf(__x); } 00089 00090 inline _GLIBCXX_CONSTEXPR long double 00091 acos(long double __x) 00092 { return __builtin_acosl(__x); } 00093 #endif 00094 00095 template<typename _Tp> 00096 inline _GLIBCXX_CONSTEXPR 00097 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00098 double>::__type 00099 acos(_Tp __x) 00100 { return __builtin_acos(__x); } 00101 00102 using ::asin; 00103 00104 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00105 inline _GLIBCXX_CONSTEXPR float 00106 asin(float __x) 00107 { return __builtin_asinf(__x); } 00108 00109 inline _GLIBCXX_CONSTEXPR long double 00110 asin(long double __x) 00111 { return __builtin_asinl(__x); } 00112 #endif 00113 00114 template<typename _Tp> 00115 inline _GLIBCXX_CONSTEXPR 00116 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00117 double>::__type 00118 asin(_Tp __x) 00119 { return __builtin_asin(__x); } 00120 00121 using ::atan; 00122 00123 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00124 inline _GLIBCXX_CONSTEXPR float 00125 atan(float __x) 00126 { return __builtin_atanf(__x); } 00127 00128 inline _GLIBCXX_CONSTEXPR long double 00129 atan(long double __x) 00130 { return __builtin_atanl(__x); } 00131 #endif 00132 00133 template<typename _Tp> 00134 inline _GLIBCXX_CONSTEXPR 00135 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00136 double>::__type 00137 atan(_Tp __x) 00138 { return __builtin_atan(__x); } 00139 00140 using ::atan2; 00141 00142 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00143 inline _GLIBCXX_CONSTEXPR float 00144 atan2(float __y, float __x) 00145 { return __builtin_atan2f(__y, __x); } 00146 00147 inline _GLIBCXX_CONSTEXPR long double 00148 atan2(long double __y, long double __x) 00149 { return __builtin_atan2l(__y, __x); } 00150 #endif 00151 00152 template<typename _Tp, typename _Up> 00153 inline _GLIBCXX_CONSTEXPR 00154 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 00155 atan2(_Tp __y, _Up __x) 00156 { 00157 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 00158 return atan2(__type(__y), __type(__x)); 00159 } 00160 00161 using ::ceil; 00162 00163 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00164 inline _GLIBCXX_CONSTEXPR float 00165 ceil(float __x) 00166 { return __builtin_ceilf(__x); } 00167 00168 inline _GLIBCXX_CONSTEXPR long double 00169 ceil(long double __x) 00170 { return __builtin_ceill(__x); } 00171 #endif 00172 00173 template<typename _Tp> 00174 inline _GLIBCXX_CONSTEXPR 00175 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00176 double>::__type 00177 ceil(_Tp __x) 00178 { return __builtin_ceil(__x); } 00179 00180 using ::cos; 00181 00182 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00183 inline _GLIBCXX_CONSTEXPR float 00184 cos(float __x) 00185 { return __builtin_cosf(__x); } 00186 00187 inline _GLIBCXX_CONSTEXPR long double 00188 cos(long double __x) 00189 { return __builtin_cosl(__x); } 00190 #endif 00191 00192 template<typename _Tp> 00193 inline _GLIBCXX_CONSTEXPR 00194 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00195 double>::__type 00196 cos(_Tp __x) 00197 { return __builtin_cos(__x); } 00198 00199 using ::cosh; 00200 00201 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00202 inline _GLIBCXX_CONSTEXPR float 00203 cosh(float __x) 00204 { return __builtin_coshf(__x); } 00205 00206 inline _GLIBCXX_CONSTEXPR long double 00207 cosh(long double __x) 00208 { return __builtin_coshl(__x); } 00209 #endif 00210 00211 template<typename _Tp> 00212 inline _GLIBCXX_CONSTEXPR 00213 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00214 double>::__type 00215 cosh(_Tp __x) 00216 { return __builtin_cosh(__x); } 00217 00218 using ::exp; 00219 00220 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00221 inline _GLIBCXX_CONSTEXPR float 00222 exp(float __x) 00223 { return __builtin_expf(__x); } 00224 00225 inline _GLIBCXX_CONSTEXPR long double 00226 exp(long double __x) 00227 { return __builtin_expl(__x); } 00228 #endif 00229 00230 template<typename _Tp> 00231 inline _GLIBCXX_CONSTEXPR 00232 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00233 double>::__type 00234 exp(_Tp __x) 00235 { return __builtin_exp(__x); } 00236 00237 using ::fabs; 00238 00239 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00240 inline _GLIBCXX_CONSTEXPR float 00241 fabs(float __x) 00242 { return __builtin_fabsf(__x); } 00243 00244 inline _GLIBCXX_CONSTEXPR long double 00245 fabs(long double __x) 00246 { return __builtin_fabsl(__x); } 00247 #endif 00248 00249 template<typename _Tp> 00250 inline _GLIBCXX_CONSTEXPR 00251 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00252 double>::__type 00253 fabs(_Tp __x) 00254 { return __builtin_fabs(__x); } 00255 00256 using ::floor; 00257 00258 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00259 inline _GLIBCXX_CONSTEXPR float 00260 floor(float __x) 00261 { return __builtin_floorf(__x); } 00262 00263 inline _GLIBCXX_CONSTEXPR long double 00264 floor(long double __x) 00265 { return __builtin_floorl(__x); } 00266 #endif 00267 00268 template<typename _Tp> 00269 inline _GLIBCXX_CONSTEXPR 00270 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00271 double>::__type 00272 floor(_Tp __x) 00273 { return __builtin_floor(__x); } 00274 00275 using ::fmod; 00276 00277 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00278 inline _GLIBCXX_CONSTEXPR float 00279 fmod(float __x, float __y) 00280 { return __builtin_fmodf(__x, __y); } 00281 00282 inline _GLIBCXX_CONSTEXPR long double 00283 fmod(long double __x, long double __y) 00284 { return __builtin_fmodl(__x, __y); } 00285 #endif 00286 00287 template<typename _Tp, typename _Up> 00288 inline _GLIBCXX_CONSTEXPR 00289 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 00290 fmod(_Tp __x, _Up __y) 00291 { 00292 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 00293 return fmod(__type(__x), __type(__y)); 00294 } 00295 00296 using ::frexp; 00297 00298 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00299 inline float 00300 frexp(float __x, int* __exp) 00301 { return __builtin_frexpf(__x, __exp); } 00302 00303 inline long double 00304 frexp(long double __x, int* __exp) 00305 { return __builtin_frexpl(__x, __exp); } 00306 #endif 00307 00308 template<typename _Tp> 00309 inline _GLIBCXX_CONSTEXPR 00310 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00311 double>::__type 00312 frexp(_Tp __x, int* __exp) 00313 { return __builtin_frexp(__x, __exp); } 00314 00315 using ::ldexp; 00316 00317 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00318 inline _GLIBCXX_CONSTEXPR float 00319 ldexp(float __x, int __exp) 00320 { return __builtin_ldexpf(__x, __exp); } 00321 00322 inline _GLIBCXX_CONSTEXPR long double 00323 ldexp(long double __x, int __exp) 00324 { return __builtin_ldexpl(__x, __exp); } 00325 #endif 00326 00327 template<typename _Tp> 00328 inline _GLIBCXX_CONSTEXPR 00329 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00330 double>::__type 00331 ldexp(_Tp __x, int __exp) 00332 { return __builtin_ldexp(__x, __exp); } 00333 00334 using ::log; 00335 00336 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00337 inline _GLIBCXX_CONSTEXPR float 00338 log(float __x) 00339 { return __builtin_logf(__x); } 00340 00341 inline _GLIBCXX_CONSTEXPR long double 00342 log(long double __x) 00343 { return __builtin_logl(__x); } 00344 #endif 00345 00346 template<typename _Tp> 00347 inline _GLIBCXX_CONSTEXPR 00348 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00349 double>::__type 00350 log(_Tp __x) 00351 { return __builtin_log(__x); } 00352 00353 using ::log10; 00354 00355 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00356 inline _GLIBCXX_CONSTEXPR float 00357 log10(float __x) 00358 { return __builtin_log10f(__x); } 00359 00360 inline _GLIBCXX_CONSTEXPR long double 00361 log10(long double __x) 00362 { return __builtin_log10l(__x); } 00363 #endif 00364 00365 template<typename _Tp> 00366 inline _GLIBCXX_CONSTEXPR 00367 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00368 double>::__type 00369 log10(_Tp __x) 00370 { return __builtin_log10(__x); } 00371 00372 using ::modf; 00373 00374 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00375 inline float 00376 modf(float __x, float* __iptr) 00377 { return __builtin_modff(__x, __iptr); } 00378 00379 inline long double 00380 modf(long double __x, long double* __iptr) 00381 { return __builtin_modfl(__x, __iptr); } 00382 #endif 00383 00384 using ::pow; 00385 00386 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00387 inline _GLIBCXX_CONSTEXPR float 00388 pow(float __x, float __y) 00389 { return __builtin_powf(__x, __y); } 00390 00391 inline _GLIBCXX_CONSTEXPR long double 00392 pow(long double __x, long double __y) 00393 { return __builtin_powl(__x, __y); } 00394 00395 #if __cplusplus < 201103L 00396 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00397 // DR 550. What should the return type of pow(float,int) be? 00398 inline double 00399 pow(double __x, int __i) 00400 { return __builtin_powi(__x, __i); } 00401 00402 inline float 00403 pow(float __x, int __n) 00404 { return __builtin_powif(__x, __n); } 00405 00406 inline long double 00407 pow(long double __x, int __n) 00408 { return __builtin_powil(__x, __n); } 00409 #endif 00410 #endif 00411 00412 template<typename _Tp, typename _Up> 00413 inline _GLIBCXX_CONSTEXPR 00414 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 00415 pow(_Tp __x, _Up __y) 00416 { 00417 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 00418 return pow(__type(__x), __type(__y)); 00419 } 00420 00421 using ::sin; 00422 00423 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00424 inline _GLIBCXX_CONSTEXPR float 00425 sin(float __x) 00426 { return __builtin_sinf(__x); } 00427 00428 inline _GLIBCXX_CONSTEXPR long double 00429 sin(long double __x) 00430 { return __builtin_sinl(__x); } 00431 #endif 00432 00433 template<typename _Tp> 00434 inline _GLIBCXX_CONSTEXPR 00435 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00436 double>::__type 00437 sin(_Tp __x) 00438 { return __builtin_sin(__x); } 00439 00440 using ::sinh; 00441 00442 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00443 inline _GLIBCXX_CONSTEXPR float 00444 sinh(float __x) 00445 { return __builtin_sinhf(__x); } 00446 00447 inline _GLIBCXX_CONSTEXPR long double 00448 sinh(long double __x) 00449 { return __builtin_sinhl(__x); } 00450 #endif 00451 00452 template<typename _Tp> 00453 inline _GLIBCXX_CONSTEXPR 00454 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00455 double>::__type 00456 sinh(_Tp __x) 00457 { return __builtin_sinh(__x); } 00458 00459 using ::sqrt; 00460 00461 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00462 inline _GLIBCXX_CONSTEXPR float 00463 sqrt(float __x) 00464 { return __builtin_sqrtf(__x); } 00465 00466 inline _GLIBCXX_CONSTEXPR long double 00467 sqrt(long double __x) 00468 { return __builtin_sqrtl(__x); } 00469 #endif 00470 00471 template<typename _Tp> 00472 inline _GLIBCXX_CONSTEXPR 00473 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00474 double>::__type 00475 sqrt(_Tp __x) 00476 { return __builtin_sqrt(__x); } 00477 00478 using ::tan; 00479 00480 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00481 inline _GLIBCXX_CONSTEXPR float 00482 tan(float __x) 00483 { return __builtin_tanf(__x); } 00484 00485 inline _GLIBCXX_CONSTEXPR long double 00486 tan(long double __x) 00487 { return __builtin_tanl(__x); } 00488 #endif 00489 00490 template<typename _Tp> 00491 inline _GLIBCXX_CONSTEXPR 00492 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00493 double>::__type 00494 tan(_Tp __x) 00495 { return __builtin_tan(__x); } 00496 00497 using ::tanh; 00498 00499 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 00500 inline _GLIBCXX_CONSTEXPR float 00501 tanh(float __x) 00502 { return __builtin_tanhf(__x); } 00503 00504 inline _GLIBCXX_CONSTEXPR long double 00505 tanh(long double __x) 00506 { return __builtin_tanhl(__x); } 00507 #endif 00508 00509 template<typename _Tp> 00510 inline _GLIBCXX_CONSTEXPR 00511 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00512 double>::__type 00513 tanh(_Tp __x) 00514 { return __builtin_tanh(__x); } 00515 00516 #if _GLIBCXX_USE_C99_MATH 00517 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC 00518 00519 // These are possible macros imported from C99-land. 00520 #undef fpclassify 00521 #undef isfinite 00522 #undef isinf 00523 #undef isnan 00524 #undef isnormal 00525 #undef signbit 00526 #undef isgreater 00527 #undef isgreaterequal 00528 #undef isless 00529 #undef islessequal 00530 #undef islessgreater 00531 #undef isunordered 00532 00533 #if __cplusplus >= 201103L 00534 00535 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00536 constexpr int 00537 fpclassify(float __x) 00538 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 00539 FP_SUBNORMAL, FP_ZERO, __x); } 00540 00541 constexpr int 00542 fpclassify(double __x) 00543 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 00544 FP_SUBNORMAL, FP_ZERO, __x); } 00545 00546 constexpr int 00547 fpclassify(long double __x) 00548 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 00549 FP_SUBNORMAL, FP_ZERO, __x); } 00550 #endif 00551 00552 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00553 template<typename _Tp> 00554 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00555 int>::__type 00556 fpclassify(_Tp __x) 00557 { return __x != 0 ? FP_NORMAL : FP_ZERO; } 00558 #endif 00559 00560 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00561 constexpr bool 00562 isfinite(float __x) 00563 { return __builtin_isfinite(__x); } 00564 00565 constexpr bool 00566 isfinite(double __x) 00567 { return __builtin_isfinite(__x); } 00568 00569 constexpr bool 00570 isfinite(long double __x) 00571 { return __builtin_isfinite(__x); } 00572 #endif 00573 00574 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00575 template<typename _Tp> 00576 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00577 bool>::__type 00578 isfinite(_Tp __x) 00579 { return true; } 00580 #endif 00581 00582 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00583 constexpr bool 00584 isinf(float __x) 00585 { return __builtin_isinf(__x); } 00586 00587 #if _GLIBCXX_HAVE_OBSOLETE_ISINF \ 00588 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC 00589 using ::isinf; 00590 #else 00591 constexpr bool 00592 isinf(double __x) 00593 { return __builtin_isinf(__x); } 00594 #endif 00595 00596 constexpr bool 00597 isinf(long double __x) 00598 { return __builtin_isinf(__x); } 00599 #endif 00600 00601 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00602 template<typename _Tp> 00603 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00604 bool>::__type 00605 isinf(_Tp __x) 00606 { return false; } 00607 #endif 00608 00609 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00610 constexpr bool 00611 isnan(float __x) 00612 { return __builtin_isnan(__x); } 00613 00614 #if _GLIBCXX_HAVE_OBSOLETE_ISNAN \ 00615 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC 00616 using ::isnan; 00617 #else 00618 constexpr bool 00619 isnan(double __x) 00620 { return __builtin_isnan(__x); } 00621 #endif 00622 00623 constexpr bool 00624 isnan(long double __x) 00625 { return __builtin_isnan(__x); } 00626 #endif 00627 00628 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00629 template<typename _Tp> 00630 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00631 bool>::__type 00632 isnan(_Tp __x) 00633 { return false; } 00634 #endif 00635 00636 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00637 constexpr bool 00638 isnormal(float __x) 00639 { return __builtin_isnormal(__x); } 00640 00641 constexpr bool 00642 isnormal(double __x) 00643 { return __builtin_isnormal(__x); } 00644 00645 constexpr bool 00646 isnormal(long double __x) 00647 { return __builtin_isnormal(__x); } 00648 #endif 00649 00650 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00651 template<typename _Tp> 00652 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00653 bool>::__type 00654 isnormal(_Tp __x) 00655 { return __x != 0 ? true : false; } 00656 #endif 00657 00658 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00659 // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic. 00660 constexpr bool 00661 signbit(float __x) 00662 { return __builtin_signbit(__x); } 00663 00664 constexpr bool 00665 signbit(double __x) 00666 { return __builtin_signbit(__x); } 00667 00668 constexpr bool 00669 signbit(long double __x) 00670 { return __builtin_signbit(__x); } 00671 #endif 00672 00673 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00674 template<typename _Tp> 00675 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 00676 bool>::__type 00677 signbit(_Tp __x) 00678 { return __x < 0 ? true : false; } 00679 #endif 00680 00681 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00682 constexpr bool 00683 isgreater(float __x, float __y) 00684 { return __builtin_isgreater(__x, __y); } 00685 00686 constexpr bool 00687 isgreater(double __x, double __y) 00688 { return __builtin_isgreater(__x, __y); } 00689 00690 constexpr bool 00691 isgreater(long double __x, long double __y) 00692 { return __builtin_isgreater(__x, __y); } 00693 #endif 00694 00695 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00696 template<typename _Tp, typename _Up> 00697 constexpr typename 00698 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 00699 && __is_arithmetic<_Up>::__value), bool>::__type 00700 isgreater(_Tp __x, _Up __y) 00701 { 00702 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 00703 return __builtin_isgreater(__type(__x), __type(__y)); 00704 } 00705 #endif 00706 00707 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00708 constexpr bool 00709 isgreaterequal(float __x, float __y) 00710 { return __builtin_isgreaterequal(__x, __y); } 00711 00712 constexpr bool 00713 isgreaterequal(double __x, double __y) 00714 { return __builtin_isgreaterequal(__x, __y); } 00715 00716 constexpr bool 00717 isgreaterequal(long double __x, long double __y) 00718 { return __builtin_isgreaterequal(__x, __y); } 00719 #endif 00720 00721 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00722 template<typename _Tp, typename _Up> 00723 constexpr typename 00724 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 00725 && __is_arithmetic<_Up>::__value), bool>::__type 00726 isgreaterequal(_Tp __x, _Up __y) 00727 { 00728 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 00729 return __builtin_isgreaterequal(__type(__x), __type(__y)); 00730 } 00731 #endif 00732 00733 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00734 constexpr bool 00735 isless(float __x, float __y) 00736 { return __builtin_isless(__x, __y); } 00737 00738 constexpr bool 00739 isless(double __x, double __y) 00740 { return __builtin_isless(__x, __y); } 00741 00742 constexpr bool 00743 isless(long double __x, long double __y) 00744 { return __builtin_isless(__x, __y); } 00745 #endif 00746 00747 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00748 template<typename _Tp, typename _Up> 00749 constexpr typename 00750 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 00751 && __is_arithmetic<_Up>::__value), bool>::__type 00752 isless(_Tp __x, _Up __y) 00753 { 00754 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 00755 return __builtin_isless(__type(__x), __type(__y)); 00756 } 00757 #endif 00758 00759 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00760 constexpr bool 00761 islessequal(float __x, float __y) 00762 { return __builtin_islessequal(__x, __y); } 00763 00764 constexpr bool 00765 islessequal(double __x, double __y) 00766 { return __builtin_islessequal(__x, __y); } 00767 00768 constexpr bool 00769 islessequal(long double __x, long double __y) 00770 { return __builtin_islessequal(__x, __y); } 00771 #endif 00772 00773 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00774 template<typename _Tp, typename _Up> 00775 constexpr typename 00776 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 00777 && __is_arithmetic<_Up>::__value), bool>::__type 00778 islessequal(_Tp __x, _Up __y) 00779 { 00780 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 00781 return __builtin_islessequal(__type(__x), __type(__y)); 00782 } 00783 #endif 00784 00785 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00786 constexpr bool 00787 islessgreater(float __x, float __y) 00788 { return __builtin_islessgreater(__x, __y); } 00789 00790 constexpr bool 00791 islessgreater(double __x, double __y) 00792 { return __builtin_islessgreater(__x, __y); } 00793 00794 constexpr bool 00795 islessgreater(long double __x, long double __y) 00796 { return __builtin_islessgreater(__x, __y); } 00797 #endif 00798 00799 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00800 template<typename _Tp, typename _Up> 00801 constexpr typename 00802 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 00803 && __is_arithmetic<_Up>::__value), bool>::__type 00804 islessgreater(_Tp __x, _Up __y) 00805 { 00806 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 00807 return __builtin_islessgreater(__type(__x), __type(__y)); 00808 } 00809 #endif 00810 00811 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 00812 constexpr bool 00813 isunordered(float __x, float __y) 00814 { return __builtin_isunordered(__x, __y); } 00815 00816 constexpr bool 00817 isunordered(double __x, double __y) 00818 { return __builtin_isunordered(__x, __y); } 00819 00820 constexpr bool 00821 isunordered(long double __x, long double __y) 00822 { return __builtin_isunordered(__x, __y); } 00823 #endif 00824 00825 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 00826 template<typename _Tp, typename _Up> 00827 constexpr typename 00828 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 00829 && __is_arithmetic<_Up>::__value), bool>::__type 00830 isunordered(_Tp __x, _Up __y) 00831 { 00832 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 00833 return __builtin_isunordered(__type(__x), __type(__y)); 00834 } 00835 #endif 00836 00837 #else 00838 00839 template<typename _Tp> 00840 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00841 int>::__type 00842 fpclassify(_Tp __f) 00843 { 00844 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00845 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 00846 FP_SUBNORMAL, FP_ZERO, __type(__f)); 00847 } 00848 00849 template<typename _Tp> 00850 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00851 int>::__type 00852 isfinite(_Tp __f) 00853 { 00854 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00855 return __builtin_isfinite(__type(__f)); 00856 } 00857 00858 template<typename _Tp> 00859 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00860 int>::__type 00861 isinf(_Tp __f) 00862 { 00863 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00864 return __builtin_isinf(__type(__f)); 00865 } 00866 00867 template<typename _Tp> 00868 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00869 int>::__type 00870 isnan(_Tp __f) 00871 { 00872 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00873 return __builtin_isnan(__type(__f)); 00874 } 00875 00876 template<typename _Tp> 00877 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00878 int>::__type 00879 isnormal(_Tp __f) 00880 { 00881 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00882 return __builtin_isnormal(__type(__f)); 00883 } 00884 00885 template<typename _Tp> 00886 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00887 int>::__type 00888 signbit(_Tp __f) 00889 { 00890 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00891 return __builtin_signbit(__type(__f)); 00892 } 00893 00894 template<typename _Tp> 00895 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00896 int>::__type 00897 isgreater(_Tp __f1, _Tp __f2) 00898 { 00899 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00900 return __builtin_isgreater(__type(__f1), __type(__f2)); 00901 } 00902 00903 template<typename _Tp> 00904 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00905 int>::__type 00906 isgreaterequal(_Tp __f1, _Tp __f2) 00907 { 00908 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00909 return __builtin_isgreaterequal(__type(__f1), __type(__f2)); 00910 } 00911 00912 template<typename _Tp> 00913 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00914 int>::__type 00915 isless(_Tp __f1, _Tp __f2) 00916 { 00917 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00918 return __builtin_isless(__type(__f1), __type(__f2)); 00919 } 00920 00921 template<typename _Tp> 00922 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00923 int>::__type 00924 islessequal(_Tp __f1, _Tp __f2) 00925 { 00926 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00927 return __builtin_islessequal(__type(__f1), __type(__f2)); 00928 } 00929 00930 template<typename _Tp> 00931 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00932 int>::__type 00933 islessgreater(_Tp __f1, _Tp __f2) 00934 { 00935 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00936 return __builtin_islessgreater(__type(__f1), __type(__f2)); 00937 } 00938 00939 template<typename _Tp> 00940 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 00941 int>::__type 00942 isunordered(_Tp __f1, _Tp __f2) 00943 { 00944 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 00945 return __builtin_isunordered(__type(__f1), __type(__f2)); 00946 } 00947 00948 #endif // C++11 00949 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */ 00950 #endif /* _GLIBCXX_USE_C99_MATH */ 00951 00952 #if __cplusplus >= 201103L 00953 00954 #ifdef _GLIBCXX_USE_C99_MATH_TR1 00955 00956 #undef acosh 00957 #undef acoshf 00958 #undef acoshl 00959 #undef asinh 00960 #undef asinhf 00961 #undef asinhl 00962 #undef atanh 00963 #undef atanhf 00964 #undef atanhl 00965 #undef cbrt 00966 #undef cbrtf 00967 #undef cbrtl 00968 #undef copysign 00969 #undef copysignf 00970 #undef copysignl 00971 #undef erf 00972 #undef erff 00973 #undef erfl 00974 #undef erfc 00975 #undef erfcf 00976 #undef erfcl 00977 #undef exp2 00978 #undef exp2f 00979 #undef exp2l 00980 #undef expm1 00981 #undef expm1f 00982 #undef expm1l 00983 #undef fdim 00984 #undef fdimf 00985 #undef fdiml 00986 #undef fma 00987 #undef fmaf 00988 #undef fmal 00989 #undef fmax 00990 #undef fmaxf 00991 #undef fmaxl 00992 #undef fmin 00993 #undef fminf 00994 #undef fminl 00995 #undef hypot 00996 #undef hypotf 00997 #undef hypotl 00998 #undef ilogb 00999 #undef ilogbf 01000 #undef ilogbl 01001 #undef lgamma 01002 #undef lgammaf 01003 #undef lgammal 01004 #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS 01005 #undef llrint 01006 #undef llrintf 01007 #undef llrintl 01008 #undef llround 01009 #undef llroundf 01010 #undef llroundl 01011 #endif 01012 #undef log1p 01013 #undef log1pf 01014 #undef log1pl 01015 #undef log2 01016 #undef log2f 01017 #undef log2l 01018 #undef logb 01019 #undef logbf 01020 #undef logbl 01021 #undef lrint 01022 #undef lrintf 01023 #undef lrintl 01024 #undef lround 01025 #undef lroundf 01026 #undef lroundl 01027 #undef nan 01028 #undef nanf 01029 #undef nanl 01030 #undef nearbyint 01031 #undef nearbyintf 01032 #undef nearbyintl 01033 #undef nextafter 01034 #undef nextafterf 01035 #undef nextafterl 01036 #undef nexttoward 01037 #undef nexttowardf 01038 #undef nexttowardl 01039 #undef remainder 01040 #undef remainderf 01041 #undef remainderl 01042 #undef remquo 01043 #undef remquof 01044 #undef remquol 01045 #undef rint 01046 #undef rintf 01047 #undef rintl 01048 #undef round 01049 #undef roundf 01050 #undef roundl 01051 #undef scalbln 01052 #undef scalblnf 01053 #undef scalblnl 01054 #undef scalbn 01055 #undef scalbnf 01056 #undef scalbnl 01057 #undef tgamma 01058 #undef tgammaf 01059 #undef tgammal 01060 #undef trunc 01061 #undef truncf 01062 #undef truncl 01063 01064 // types 01065 using ::double_t; 01066 using ::float_t; 01067 01068 // functions 01069 using ::acosh; 01070 using ::acoshf; 01071 using ::acoshl; 01072 01073 using ::asinh; 01074 using ::asinhf; 01075 using ::asinhl; 01076 01077 using ::atanh; 01078 using ::atanhf; 01079 using ::atanhl; 01080 01081 using ::cbrt; 01082 using ::cbrtf; 01083 using ::cbrtl; 01084 01085 using ::copysign; 01086 using ::copysignf; 01087 using ::copysignl; 01088 01089 using ::erf; 01090 using ::erff; 01091 using ::erfl; 01092 01093 using ::erfc; 01094 using ::erfcf; 01095 using ::erfcl; 01096 01097 using ::exp2; 01098 using ::exp2f; 01099 using ::exp2l; 01100 01101 using ::expm1; 01102 using ::expm1f; 01103 using ::expm1l; 01104 01105 using ::fdim; 01106 using ::fdimf; 01107 using ::fdiml; 01108 01109 using ::fma; 01110 using ::fmaf; 01111 using ::fmal; 01112 01113 using ::fmax; 01114 using ::fmaxf; 01115 using ::fmaxl; 01116 01117 using ::fmin; 01118 using ::fminf; 01119 using ::fminl; 01120 01121 using ::hypot; 01122 using ::hypotf; 01123 using ::hypotl; 01124 01125 using ::ilogb; 01126 using ::ilogbf; 01127 using ::ilogbl; 01128 01129 using ::lgamma; 01130 using ::lgammaf; 01131 using ::lgammal; 01132 01133 #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS 01134 using ::llrint; 01135 using ::llrintf; 01136 using ::llrintl; 01137 01138 using ::llround; 01139 using ::llroundf; 01140 using ::llroundl; 01141 #endif 01142 01143 using ::log1p; 01144 using ::log1pf; 01145 using ::log1pl; 01146 01147 using ::log2; 01148 using ::log2f; 01149 using ::log2l; 01150 01151 using ::logb; 01152 using ::logbf; 01153 using ::logbl; 01154 01155 using ::lrint; 01156 using ::lrintf; 01157 using ::lrintl; 01158 01159 using ::lround; 01160 using ::lroundf; 01161 using ::lroundl; 01162 01163 using ::nan; 01164 using ::nanf; 01165 using ::nanl; 01166 01167 using ::nearbyint; 01168 using ::nearbyintf; 01169 using ::nearbyintl; 01170 01171 using ::nextafter; 01172 using ::nextafterf; 01173 using ::nextafterl; 01174 01175 using ::nexttoward; 01176 using ::nexttowardf; 01177 using ::nexttowardl; 01178 01179 using ::remainder; 01180 using ::remainderf; 01181 using ::remainderl; 01182 01183 using ::remquo; 01184 using ::remquof; 01185 using ::remquol; 01186 01187 using ::rint; 01188 using ::rintf; 01189 using ::rintl; 01190 01191 using ::round; 01192 using ::roundf; 01193 using ::roundl; 01194 01195 using ::scalbln; 01196 using ::scalblnf; 01197 using ::scalblnl; 01198 01199 using ::scalbn; 01200 using ::scalbnf; 01201 using ::scalbnl; 01202 01203 using ::tgamma; 01204 using ::tgammaf; 01205 using ::tgammal; 01206 01207 using ::trunc; 01208 using ::truncf; 01209 using ::truncl; 01210 01211 /// Additional overloads. 01212 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01213 constexpr float 01214 acosh(float __x) 01215 { return __builtin_acoshf(__x); } 01216 01217 constexpr long double 01218 acosh(long double __x) 01219 { return __builtin_acoshl(__x); } 01220 #endif 01221 01222 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01223 template<typename _Tp> 01224 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01225 double>::__type 01226 acosh(_Tp __x) 01227 { return __builtin_acosh(__x); } 01228 #endif 01229 01230 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01231 constexpr float 01232 asinh(float __x) 01233 { return __builtin_asinhf(__x); } 01234 01235 constexpr long double 01236 asinh(long double __x) 01237 { return __builtin_asinhl(__x); } 01238 #endif 01239 01240 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01241 template<typename _Tp> 01242 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01243 double>::__type 01244 asinh(_Tp __x) 01245 { return __builtin_asinh(__x); } 01246 #endif 01247 01248 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01249 constexpr float 01250 atanh(float __x) 01251 { return __builtin_atanhf(__x); } 01252 01253 constexpr long double 01254 atanh(long double __x) 01255 { return __builtin_atanhl(__x); } 01256 #endif 01257 01258 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01259 template<typename _Tp> 01260 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01261 double>::__type 01262 atanh(_Tp __x) 01263 { return __builtin_atanh(__x); } 01264 #endif 01265 01266 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01267 constexpr float 01268 cbrt(float __x) 01269 { return __builtin_cbrtf(__x); } 01270 01271 constexpr long double 01272 cbrt(long double __x) 01273 { return __builtin_cbrtl(__x); } 01274 #endif 01275 01276 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01277 template<typename _Tp> 01278 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01279 double>::__type 01280 cbrt(_Tp __x) 01281 { return __builtin_cbrt(__x); } 01282 #endif 01283 01284 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01285 constexpr float 01286 copysign(float __x, float __y) 01287 { return __builtin_copysignf(__x, __y); } 01288 01289 constexpr long double 01290 copysign(long double __x, long double __y) 01291 { return __builtin_copysignl(__x, __y); } 01292 #endif 01293 01294 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01295 template<typename _Tp, typename _Up> 01296 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 01297 copysign(_Tp __x, _Up __y) 01298 { 01299 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 01300 return copysign(__type(__x), __type(__y)); 01301 } 01302 #endif 01303 01304 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01305 constexpr float 01306 erf(float __x) 01307 { return __builtin_erff(__x); } 01308 01309 constexpr long double 01310 erf(long double __x) 01311 { return __builtin_erfl(__x); } 01312 #endif 01313 01314 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01315 template<typename _Tp> 01316 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01317 double>::__type 01318 erf(_Tp __x) 01319 { return __builtin_erf(__x); } 01320 #endif 01321 01322 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01323 constexpr float 01324 erfc(float __x) 01325 { return __builtin_erfcf(__x); } 01326 01327 constexpr long double 01328 erfc(long double __x) 01329 { return __builtin_erfcl(__x); } 01330 #endif 01331 01332 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01333 template<typename _Tp> 01334 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01335 double>::__type 01336 erfc(_Tp __x) 01337 { return __builtin_erfc(__x); } 01338 #endif 01339 01340 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01341 constexpr float 01342 exp2(float __x) 01343 { return __builtin_exp2f(__x); } 01344 01345 constexpr long double 01346 exp2(long double __x) 01347 { return __builtin_exp2l(__x); } 01348 #endif 01349 01350 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01351 template<typename _Tp> 01352 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01353 double>::__type 01354 exp2(_Tp __x) 01355 { return __builtin_exp2(__x); } 01356 #endif 01357 01358 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01359 constexpr float 01360 expm1(float __x) 01361 { return __builtin_expm1f(__x); } 01362 01363 constexpr long double 01364 expm1(long double __x) 01365 { return __builtin_expm1l(__x); } 01366 #endif 01367 01368 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01369 template<typename _Tp> 01370 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01371 double>::__type 01372 expm1(_Tp __x) 01373 { return __builtin_expm1(__x); } 01374 #endif 01375 01376 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01377 constexpr float 01378 fdim(float __x, float __y) 01379 { return __builtin_fdimf(__x, __y); } 01380 01381 constexpr long double 01382 fdim(long double __x, long double __y) 01383 { return __builtin_fdiml(__x, __y); } 01384 #endif 01385 01386 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01387 template<typename _Tp, typename _Up> 01388 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 01389 fdim(_Tp __x, _Up __y) 01390 { 01391 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 01392 return fdim(__type(__x), __type(__y)); 01393 } 01394 #endif 01395 01396 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01397 constexpr float 01398 fma(float __x, float __y, float __z) 01399 { return __builtin_fmaf(__x, __y, __z); } 01400 01401 constexpr long double 01402 fma(long double __x, long double __y, long double __z) 01403 { return __builtin_fmal(__x, __y, __z); } 01404 #endif 01405 01406 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01407 template<typename _Tp, typename _Up, typename _Vp> 01408 constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type 01409 fma(_Tp __x, _Up __y, _Vp __z) 01410 { 01411 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; 01412 return fma(__type(__x), __type(__y), __type(__z)); 01413 } 01414 #endif 01415 01416 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01417 constexpr float 01418 fmax(float __x, float __y) 01419 { return __builtin_fmaxf(__x, __y); } 01420 01421 constexpr long double 01422 fmax(long double __x, long double __y) 01423 { return __builtin_fmaxl(__x, __y); } 01424 #endif 01425 01426 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01427 template<typename _Tp, typename _Up> 01428 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 01429 fmax(_Tp __x, _Up __y) 01430 { 01431 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 01432 return fmax(__type(__x), __type(__y)); 01433 } 01434 #endif 01435 01436 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01437 constexpr float 01438 fmin(float __x, float __y) 01439 { return __builtin_fminf(__x, __y); } 01440 01441 constexpr long double 01442 fmin(long double __x, long double __y) 01443 { return __builtin_fminl(__x, __y); } 01444 #endif 01445 01446 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01447 template<typename _Tp, typename _Up> 01448 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 01449 fmin(_Tp __x, _Up __y) 01450 { 01451 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 01452 return fmin(__type(__x), __type(__y)); 01453 } 01454 #endif 01455 01456 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01457 constexpr float 01458 hypot(float __x, float __y) 01459 { return __builtin_hypotf(__x, __y); } 01460 01461 constexpr long double 01462 hypot(long double __x, long double __y) 01463 { return __builtin_hypotl(__x, __y); } 01464 #endif 01465 01466 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01467 template<typename _Tp, typename _Up> 01468 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 01469 hypot(_Tp __x, _Up __y) 01470 { 01471 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 01472 return hypot(__type(__x), __type(__y)); 01473 } 01474 #endif 01475 01476 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01477 constexpr int 01478 ilogb(float __x) 01479 { return __builtin_ilogbf(__x); } 01480 01481 constexpr int 01482 ilogb(long double __x) 01483 { return __builtin_ilogbl(__x); } 01484 #endif 01485 01486 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01487 template<typename _Tp> 01488 constexpr 01489 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01490 int>::__type 01491 ilogb(_Tp __x) 01492 { return __builtin_ilogb(__x); } 01493 #endif 01494 01495 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01496 constexpr float 01497 lgamma(float __x) 01498 { return __builtin_lgammaf(__x); } 01499 01500 constexpr long double 01501 lgamma(long double __x) 01502 { return __builtin_lgammal(__x); } 01503 #endif 01504 01505 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01506 template<typename _Tp> 01507 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01508 double>::__type 01509 lgamma(_Tp __x) 01510 { return __builtin_lgamma(__x); } 01511 #endif 01512 01513 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01514 constexpr long long 01515 llrint(float __x) 01516 { return __builtin_llrintf(__x); } 01517 01518 constexpr long long 01519 llrint(long double __x) 01520 { return __builtin_llrintl(__x); } 01521 #endif 01522 01523 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01524 template<typename _Tp> 01525 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01526 long long>::__type 01527 llrint(_Tp __x) 01528 { return __builtin_llrint(__x); } 01529 #endif 01530 01531 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01532 constexpr long long 01533 llround(float __x) 01534 { return __builtin_llroundf(__x); } 01535 01536 constexpr long long 01537 llround(long double __x) 01538 { return __builtin_llroundl(__x); } 01539 #endif 01540 01541 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01542 template<typename _Tp> 01543 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01544 long long>::__type 01545 llround(_Tp __x) 01546 { return __builtin_llround(__x); } 01547 #endif 01548 01549 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01550 constexpr float 01551 log1p(float __x) 01552 { return __builtin_log1pf(__x); } 01553 01554 constexpr long double 01555 log1p(long double __x) 01556 { return __builtin_log1pl(__x); } 01557 #endif 01558 01559 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01560 template<typename _Tp> 01561 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01562 double>::__type 01563 log1p(_Tp __x) 01564 { return __builtin_log1p(__x); } 01565 #endif 01566 01567 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01568 // DR 568. 01569 constexpr float 01570 log2(float __x) 01571 { return __builtin_log2f(__x); } 01572 01573 constexpr long double 01574 log2(long double __x) 01575 { return __builtin_log2l(__x); } 01576 #endif 01577 01578 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01579 template<typename _Tp> 01580 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01581 double>::__type 01582 log2(_Tp __x) 01583 { return __builtin_log2(__x); } 01584 #endif 01585 01586 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01587 constexpr float 01588 logb(float __x) 01589 { return __builtin_logbf(__x); } 01590 01591 constexpr long double 01592 logb(long double __x) 01593 { return __builtin_logbl(__x); } 01594 #endif 01595 01596 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01597 template<typename _Tp> 01598 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01599 double>::__type 01600 logb(_Tp __x) 01601 { return __builtin_logb(__x); } 01602 #endif 01603 01604 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01605 constexpr long 01606 lrint(float __x) 01607 { return __builtin_lrintf(__x); } 01608 01609 constexpr long 01610 lrint(long double __x) 01611 { return __builtin_lrintl(__x); } 01612 #endif 01613 01614 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01615 template<typename _Tp> 01616 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01617 long>::__type 01618 lrint(_Tp __x) 01619 { return __builtin_lrint(__x); } 01620 #endif 01621 01622 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01623 constexpr long 01624 lround(float __x) 01625 { return __builtin_lroundf(__x); } 01626 01627 constexpr long 01628 lround(long double __x) 01629 { return __builtin_lroundl(__x); } 01630 #endif 01631 01632 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01633 template<typename _Tp> 01634 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01635 long>::__type 01636 lround(_Tp __x) 01637 { return __builtin_lround(__x); } 01638 #endif 01639 01640 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01641 constexpr float 01642 nearbyint(float __x) 01643 { return __builtin_nearbyintf(__x); } 01644 01645 constexpr long double 01646 nearbyint(long double __x) 01647 { return __builtin_nearbyintl(__x); } 01648 #endif 01649 01650 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01651 template<typename _Tp> 01652 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01653 double>::__type 01654 nearbyint(_Tp __x) 01655 { return __builtin_nearbyint(__x); } 01656 #endif 01657 01658 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01659 constexpr float 01660 nextafter(float __x, float __y) 01661 { return __builtin_nextafterf(__x, __y); } 01662 01663 constexpr long double 01664 nextafter(long double __x, long double __y) 01665 { return __builtin_nextafterl(__x, __y); } 01666 #endif 01667 01668 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01669 template<typename _Tp, typename _Up> 01670 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 01671 nextafter(_Tp __x, _Up __y) 01672 { 01673 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 01674 return nextafter(__type(__x), __type(__y)); 01675 } 01676 #endif 01677 01678 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01679 constexpr float 01680 nexttoward(float __x, long double __y) 01681 { return __builtin_nexttowardf(__x, __y); } 01682 01683 constexpr long double 01684 nexttoward(long double __x, long double __y) 01685 { return __builtin_nexttowardl(__x, __y); } 01686 #endif 01687 01688 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01689 template<typename _Tp> 01690 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01691 double>::__type 01692 nexttoward(_Tp __x, long double __y) 01693 { return __builtin_nexttoward(__x, __y); } 01694 #endif 01695 01696 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01697 constexpr float 01698 remainder(float __x, float __y) 01699 { return __builtin_remainderf(__x, __y); } 01700 01701 constexpr long double 01702 remainder(long double __x, long double __y) 01703 { return __builtin_remainderl(__x, __y); } 01704 #endif 01705 01706 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01707 template<typename _Tp, typename _Up> 01708 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 01709 remainder(_Tp __x, _Up __y) 01710 { 01711 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 01712 return remainder(__type(__x), __type(__y)); 01713 } 01714 #endif 01715 01716 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01717 inline float 01718 remquo(float __x, float __y, int* __pquo) 01719 { return __builtin_remquof(__x, __y, __pquo); } 01720 01721 inline long double 01722 remquo(long double __x, long double __y, int* __pquo) 01723 { return __builtin_remquol(__x, __y, __pquo); } 01724 #endif 01725 01726 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01727 template<typename _Tp, typename _Up> 01728 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 01729 remquo(_Tp __x, _Up __y, int* __pquo) 01730 { 01731 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 01732 return remquo(__type(__x), __type(__y), __pquo); 01733 } 01734 #endif 01735 01736 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01737 constexpr float 01738 rint(float __x) 01739 { return __builtin_rintf(__x); } 01740 01741 constexpr long double 01742 rint(long double __x) 01743 { return __builtin_rintl(__x); } 01744 #endif 01745 01746 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01747 template<typename _Tp> 01748 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01749 double>::__type 01750 rint(_Tp __x) 01751 { return __builtin_rint(__x); } 01752 #endif 01753 01754 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01755 constexpr float 01756 round(float __x) 01757 { return __builtin_roundf(__x); } 01758 01759 constexpr long double 01760 round(long double __x) 01761 { return __builtin_roundl(__x); } 01762 #endif 01763 01764 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01765 template<typename _Tp> 01766 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01767 double>::__type 01768 round(_Tp __x) 01769 { return __builtin_round(__x); } 01770 #endif 01771 01772 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01773 constexpr float 01774 scalbln(float __x, long __ex) 01775 { return __builtin_scalblnf(__x, __ex); } 01776 01777 constexpr long double 01778 scalbln(long double __x, long __ex) 01779 { return __builtin_scalblnl(__x, __ex); } 01780 #endif 01781 01782 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01783 template<typename _Tp> 01784 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01785 double>::__type 01786 scalbln(_Tp __x, long __ex) 01787 { return __builtin_scalbln(__x, __ex); } 01788 #endif 01789 01790 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01791 constexpr float 01792 scalbn(float __x, int __ex) 01793 { return __builtin_scalbnf(__x, __ex); } 01794 01795 constexpr long double 01796 scalbn(long double __x, int __ex) 01797 { return __builtin_scalbnl(__x, __ex); } 01798 #endif 01799 01800 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01801 template<typename _Tp> 01802 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01803 double>::__type 01804 scalbn(_Tp __x, int __ex) 01805 { return __builtin_scalbn(__x, __ex); } 01806 #endif 01807 01808 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01809 constexpr float 01810 tgamma(float __x) 01811 { return __builtin_tgammaf(__x); } 01812 01813 constexpr long double 01814 tgamma(long double __x) 01815 { return __builtin_tgammal(__x); } 01816 #endif 01817 01818 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01819 template<typename _Tp> 01820 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01821 double>::__type 01822 tgamma(_Tp __x) 01823 { return __builtin_tgamma(__x); } 01824 #endif 01825 01826 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 01827 constexpr float 01828 trunc(float __x) 01829 { return __builtin_truncf(__x); } 01830 01831 constexpr long double 01832 trunc(long double __x) 01833 { return __builtin_truncl(__x); } 01834 #endif 01835 01836 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 01837 template<typename _Tp> 01838 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 01839 double>::__type 01840 trunc(_Tp __x) 01841 { return __builtin_trunc(__x); } 01842 #endif 01843 01844 #endif // _GLIBCXX_USE_C99_MATH_TR1 01845 #endif // C++11 01846 01847 #if __cplusplus > 201402L 01848 01849 // [c.math.hypot3], three-dimensional hypotenuse 01850 #define __cpp_lib_hypot 201603 01851 01852 template<typename _Tp> 01853 inline _Tp 01854 __hypot3(_Tp __x, _Tp __y, _Tp __z) 01855 { 01856 __x = std::abs(__x); 01857 __y = std::abs(__y); 01858 __z = std::abs(__z); 01859 if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x) 01860 return __a * std::sqrt((__x / __a) * (__x / __a) 01861 + (__y / __a) * (__y / __a) 01862 + (__z / __a) * (__z / __a)); 01863 else 01864 return {}; 01865 } 01866 01867 inline float 01868 hypot(float __x, float __y, float __z) 01869 { return std::__hypot3<float>(__x, __y, __z); } 01870 01871 inline double 01872 hypot(double __x, double __y, double __z) 01873 { return std::__hypot3<double>(__x, __y, __z); } 01874 01875 inline long double 01876 hypot(long double __x, long double __y, long double __z) 01877 { return std::__hypot3<long double>(__x, __y, __z); } 01878 01879 template<typename _Tp, typename _Up, typename _Vp> 01880 typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type 01881 hypot(_Tp __x, _Up __y, _Vp __z) 01882 { 01883 using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type; 01884 return std::__hypot3<__type>(__x, __y, __z); 01885 } 01886 #endif // C++17 01887 01888 #if __cplusplus > 201703L 01889 // linear interpolation 01890 # define __cpp_lib_interpolate 201902L 01891 01892 template<typename _Fp> 01893 constexpr _Fp 01894 __lerp(_Fp __a, _Fp __b, _Fp __t) 01895 { 01896 if (__a <= 0 && __b >= 0 || __a >= 0 && __b <= 0) 01897 return __t * __b + (1 - __t) * __a; 01898 01899 if (__t == 1) 01900 return __b; // exact 01901 01902 // Exact at __t=0, monotonic except near __t=1, 01903 // bounded, determinate, and consistent: 01904 const _Fp __x = __a + __t * (__b - __a); 01905 return __t > 1 == __b > __a 01906 ? (__b < __x ? __x : __b) 01907 : (__b > __x ? __x : __b); // monotonic near __t=1 01908 } 01909 01910 constexpr float 01911 lerp(float __a, float __b, float __t) 01912 { return std::__lerp(__a, __b, __t); } 01913 01914 constexpr double 01915 lerp(double __a, double __b, double __t) 01916 { return std::__lerp(__a, __b, __t); } 01917 01918 constexpr long double 01919 lerp(long double __a, long double __b, long double __t) 01920 { return std::__lerp(__a, __b, __t); } 01921 #endif // C++20 01922 01923 _GLIBCXX_END_NAMESPACE_VERSION 01924 } // namespace 01925 01926 #if _GLIBCXX_USE_STD_SPEC_FUNCS 01927 # include <bits/specfun.h> 01928 #endif 01929 01930 } // extern "C++" 01931 01932 #endif