Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/c++/15/cmath
1 // -*- C++ -*- C forwarding header. 2 3 // Copyright (C) 1997-2025 Free Software Foundation, Inc. 4 // 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) 9 // any later version. 10 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. 15 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. 19 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/>. 24 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. 28 * 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 32 * as macros in C). 33 */ 34 35 // 36 // ISO C++ 14882: 26.5 C library 37 // 38 39 #ifndef _GLIBCXX_CMATH 40 #define _GLIBCXX_CMATH 1 41 42 #ifdef _GLIBCXX_SYSHDR 43 #pragma GCC system_header 44 #endif 45 46 #include <bits/requires_hosted.h> 47 48 #include <bits/c++config.h> 49 #include <bits/cpp_type_traits.h> 50 #include <ext/type_traits.h> 51 52 #pragma GCC diagnostic push 53 #pragma GCC diagnostic ignored "-Wpedantic" // include_next 54 #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS 55 #include_next <math.h> 56 #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS 57 #pragma GCC diagnostic pop 58 59 #include <bits/std_abs.h> 60 61 #define __glibcxx_want_hypot 62 #define __glibcxx_want_interpolate 63 #include <bits/version.h> 64 65 // Get rid of those macros defined in <math.h> in lieu of real functions. 66 #undef div 67 #undef acos 68 #undef asin 69 #undef atan 70 #undef atan2 71 #undef ceil 72 #undef cos 73 #undef cosh 74 #undef exp 75 #undef fabs 76 #undef floor 77 #undef fmod 78 #undef frexp 79 #undef ldexp 80 #undef log 81 #undef log10 82 #undef modf 83 #undef pow 84 #undef sin 85 #undef sinh 86 #undef sqrt 87 #undef tan 88 #undef tanh 89 90 extern "C++" 91 { 92 namespace std _GLIBCXX_VISIBILITY(default) 93 { 94 _GLIBCXX_BEGIN_NAMESPACE_VERSION 95 96 using ::acos; 97 98 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 99 inline _GLIBCXX_CONSTEXPR float 100 acos(float __x) 101 { return __builtin_acosf(__x); } 102 103 inline _GLIBCXX_CONSTEXPR long double 104 acos(long double __x) 105 { return __builtin_acosl(__x); } 106 #endif 107 108 template<typename _Tp> 109 inline _GLIBCXX_CONSTEXPR 110 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 111 double>::__type 112 acos(_Tp __x) 113 { return __builtin_acos(__x); } 114 115 using ::asin; 116 117 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 118 inline _GLIBCXX_CONSTEXPR float 119 asin(float __x) 120 { return __builtin_asinf(__x); } 121 122 inline _GLIBCXX_CONSTEXPR long double 123 asin(long double __x) 124 { return __builtin_asinl(__x); } 125 #endif 126 127 template<typename _Tp> 128 inline _GLIBCXX_CONSTEXPR 129 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 130 double>::__type 131 asin(_Tp __x) 132 { return __builtin_asin(__x); } 133 134 using ::atan; 135 136 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 137 inline _GLIBCXX_CONSTEXPR float 138 atan(float __x) 139 { return __builtin_atanf(__x); } 140 141 inline _GLIBCXX_CONSTEXPR long double 142 atan(long double __x) 143 { return __builtin_atanl(__x); } 144 #endif 145 146 template<typename _Tp> 147 inline _GLIBCXX_CONSTEXPR 148 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 149 double>::__type 150 atan(_Tp __x) 151 { return __builtin_atan(__x); } 152 153 using ::atan2; 154 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); } 159 160 inline _GLIBCXX_CONSTEXPR long double 161 atan2(long double __y, long double __x) 162 { return __builtin_atan2l(__y, __x); } 163 #endif 164 165 using ::ceil; 166 167 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 168 inline _GLIBCXX_CONSTEXPR float 169 ceil(float __x) 170 { return __builtin_ceilf(__x); } 171 172 inline _GLIBCXX_CONSTEXPR long double 173 ceil(long double __x) 174 { return __builtin_ceill(__x); } 175 #endif 176 177 template<typename _Tp> 178 inline _GLIBCXX_CONSTEXPR 179 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 180 double>::__type 181 ceil(_Tp __x) 182 { return __builtin_ceil(__x); } 183 184 using ::cos; 185 186 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 187 inline _GLIBCXX_CONSTEXPR float 188 cos(float __x) 189 { return __builtin_cosf(__x); } 190 191 inline _GLIBCXX_CONSTEXPR long double 192 cos(long double __x) 193 { return __builtin_cosl(__x); } 194 #endif 195 196 template<typename _Tp> 197 inline _GLIBCXX_CONSTEXPR 198 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 199 double>::__type 200 cos(_Tp __x) 201 { return __builtin_cos(__x); } 202 203 using ::cosh; 204 205 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 206 inline _GLIBCXX_CONSTEXPR float 207 cosh(float __x) 208 { return __builtin_coshf(__x); } 209 210 inline _GLIBCXX_CONSTEXPR long double 211 cosh(long double __x) 212 { return __builtin_coshl(__x); } 213 #endif 214 215 template<typename _Tp> 216 inline _GLIBCXX_CONSTEXPR 217 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 218 double>::__type 219 cosh(_Tp __x) 220 { return __builtin_cosh(__x); } 221 222 using ::exp; 223 224 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 225 inline _GLIBCXX_CONSTEXPR float 226 exp(float __x) 227 { return __builtin_expf(__x); } 228 229 inline _GLIBCXX_CONSTEXPR long double 230 exp(long double __x) 231 { return __builtin_expl(__x); } 232 #endif 233 234 template<typename _Tp> 235 inline _GLIBCXX_CONSTEXPR 236 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 237 double>::__type 238 exp(_Tp __x) 239 { return __builtin_exp(__x); } 240 241 using ::fabs; 242 243 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 244 inline _GLIBCXX_CONSTEXPR float 245 fabs(float __x) 246 { return __builtin_fabsf(__x); } 247 248 inline _GLIBCXX_CONSTEXPR long double 249 fabs(long double __x) 250 { return __builtin_fabsl(__x); } 251 #endif 252 253 template<typename _Tp> 254 inline _GLIBCXX_CONSTEXPR 255 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 256 double>::__type 257 fabs(_Tp __x) 258 { return __builtin_fabs(__x); } 259 260 using ::floor; 261 262 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 263 inline _GLIBCXX_CONSTEXPR float 264 floor(float __x) 265 { return __builtin_floorf(__x); } 266 267 inline _GLIBCXX_CONSTEXPR long double 268 floor(long double __x) 269 { return __builtin_floorl(__x); } 270 #endif 271 272 template<typename _Tp> 273 inline _GLIBCXX_CONSTEXPR 274 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 275 double>::__type 276 floor(_Tp __x) 277 { return __builtin_floor(__x); } 278 279 using ::fmod; 280 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); } 285 286 inline _GLIBCXX_CONSTEXPR long double 287 fmod(long double __x, long double __y) 288 { return __builtin_fmodl(__x, __y); } 289 #endif 290 291 using ::frexp; 292 293 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 294 inline float 295 frexp(float __x, int* __exp) 296 { return __builtin_frexpf(__x, __exp); } 297 298 inline long double 299 frexp(long double __x, int* __exp) 300 { return __builtin_frexpl(__x, __exp); } 301 #endif 302 303 template<typename _Tp> 304 inline _GLIBCXX_CONSTEXPR 305 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 306 double>::__type 307 frexp(_Tp __x, int* __exp) 308 { return __builtin_frexp(__x, __exp); } 309 310 using ::ldexp; 311 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); } 316 317 inline _GLIBCXX_CONSTEXPR long double 318 ldexp(long double __x, int __exp) 319 { return __builtin_ldexpl(__x, __exp); } 320 #endif 321 322 template<typename _Tp> 323 inline _GLIBCXX_CONSTEXPR 324 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 325 double>::__type 326 ldexp(_Tp __x, int __exp) 327 { return __builtin_ldexp(__x, __exp); } 328 329 using ::log; 330 331 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 332 inline _GLIBCXX_CONSTEXPR float 333 log(float __x) 334 { return __builtin_logf(__x); } 335 336 inline _GLIBCXX_CONSTEXPR long double 337 log(long double __x) 338 { return __builtin_logl(__x); } 339 #endif 340 341 template<typename _Tp> 342 inline _GLIBCXX_CONSTEXPR 343 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 344 double>::__type 345 log(_Tp __x) 346 { return __builtin_log(__x); } 347 348 using ::log10; 349 350 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 351 inline _GLIBCXX_CONSTEXPR float 352 log10(float __x) 353 { return __builtin_log10f(__x); } 354 355 inline _GLIBCXX_CONSTEXPR long double 356 log10(long double __x) 357 { return __builtin_log10l(__x); } 358 #endif 359 360 template<typename _Tp> 361 inline _GLIBCXX_CONSTEXPR 362 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 363 double>::__type 364 log10(_Tp __x) 365 { return __builtin_log10(__x); } 366 367 using ::modf; 368 369 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 370 inline float 371 modf(float __x, float* __iptr) 372 { return __builtin_modff(__x, __iptr); } 373 374 inline long double 375 modf(long double __x, long double* __iptr) 376 { return __builtin_modfl(__x, __iptr); } 377 #endif 378 379 using ::pow; 380 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); } 385 386 inline _GLIBCXX_CONSTEXPR long double 387 pow(long double __x, long double __y) 388 { return __builtin_powl(__x, __y); } 389 390 #if __cplusplus < 201103L 391 // _GLIBCXX_RESOLVE_LIB_DEFECTS 392 // DR 550. What should the return type of pow(float,int) be? 393 inline double 394 pow(double __x, int __i) 395 { return __builtin_powi(__x, __i); } 396 397 inline float 398 pow(float __x, int __n) 399 { return __builtin_powif(__x, __n); } 400 401 inline long double 402 pow(long double __x, int __n) 403 { return __builtin_powil(__x, __n); } 404 #endif 405 #endif 406 407 using ::sin; 408 409 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 410 inline _GLIBCXX_CONSTEXPR float 411 sin(float __x) 412 { return __builtin_sinf(__x); } 413 414 inline _GLIBCXX_CONSTEXPR long double 415 sin(long double __x) 416 { return __builtin_sinl(__x); } 417 #endif 418 419 template<typename _Tp> 420 inline _GLIBCXX_CONSTEXPR 421 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 422 double>::__type 423 sin(_Tp __x) 424 { return __builtin_sin(__x); } 425 426 using ::sinh; 427 428 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 429 inline _GLIBCXX_CONSTEXPR float 430 sinh(float __x) 431 { return __builtin_sinhf(__x); } 432 433 inline _GLIBCXX_CONSTEXPR long double 434 sinh(long double __x) 435 { return __builtin_sinhl(__x); } 436 #endif 437 438 template<typename _Tp> 439 inline _GLIBCXX_CONSTEXPR 440 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 441 double>::__type 442 sinh(_Tp __x) 443 { return __builtin_sinh(__x); } 444 445 using ::sqrt; 446 447 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 448 inline _GLIBCXX_CONSTEXPR float 449 sqrt(float __x) 450 { return __builtin_sqrtf(__x); } 451 452 inline _GLIBCXX_CONSTEXPR long double 453 sqrt(long double __x) 454 { return __builtin_sqrtl(__x); } 455 #endif 456 457 template<typename _Tp> 458 inline _GLIBCXX_CONSTEXPR 459 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 460 double>::__type 461 sqrt(_Tp __x) 462 { return __builtin_sqrt(__x); } 463 464 using ::tan; 465 466 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 467 inline _GLIBCXX_CONSTEXPR float 468 tan(float __x) 469 { return __builtin_tanf(__x); } 470 471 inline _GLIBCXX_CONSTEXPR long double 472 tan(long double __x) 473 { return __builtin_tanl(__x); } 474 #endif 475 476 template<typename _Tp> 477 inline _GLIBCXX_CONSTEXPR 478 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 479 double>::__type 480 tan(_Tp __x) 481 { return __builtin_tan(__x); } 482 483 using ::tanh; 484 485 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 486 inline _GLIBCXX_CONSTEXPR float 487 tanh(float __x) 488 { return __builtin_tanhf(__x); } 489 490 inline _GLIBCXX_CONSTEXPR long double 491 tanh(long double __x) 492 { return __builtin_tanhl(__x); } 493 #endif 494 495 template<typename _Tp> 496 inline _GLIBCXX_CONSTEXPR 497 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 498 double>::__type 499 tanh(_Tp __x) 500 { return __builtin_tanh(__x); } 501 502 #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) 503 constexpr _Float16 504 acos(_Float16 __x) 505 { return _Float16(__builtin_acosf(__x)); } 506 507 constexpr _Float16 508 asin(_Float16 __x) 509 { return _Float16(__builtin_asinf(__x)); } 510 511 constexpr _Float16 512 atan(_Float16 __x) 513 { return _Float16(__builtin_atanf(__x)); } 514 515 constexpr _Float16 516 atan2(_Float16 __y, _Float16 __x) 517 { return _Float16(__builtin_atan2f(__y, __x)); } 518 519 constexpr _Float16 520 ceil(_Float16 __x) 521 { return _Float16(__builtin_ceilf(__x)); } 522 523 constexpr _Float16 524 cos(_Float16 __x) 525 { return _Float16(__builtin_cosf(__x)); } 526 527 constexpr _Float16 528 cosh(_Float16 __x) 529 { return _Float16(__builtin_coshf(__x)); } 530 531 constexpr _Float16 532 exp(_Float16 __x) 533 { return _Float16(__builtin_expf(__x)); } 534 535 constexpr _Float16 536 fabs(_Float16 __x) 537 { return _Float16(__builtin_fabsf(__x)); } 538 539 constexpr _Float16 540 floor(_Float16 __x) 541 { return _Float16(__builtin_floorf(__x)); } 542 543 constexpr _Float16 544 fmod(_Float16 __x, _Float16 __y) 545 { return _Float16(__builtin_fmodf(__x, __y)); } 546 547 inline _Float16 548 frexp(_Float16 __x, int* __exp) 549 { return _Float16(__builtin_frexpf(__x, __exp)); } 550 551 constexpr _Float16 552 ldexp(_Float16 __x, int __exp) 553 { return _Float16(__builtin_ldexpf(__x, __exp)); } 554 555 constexpr _Float16 556 log(_Float16 __x) 557 { return _Float16(__builtin_logf(__x)); } 558 559 constexpr _Float16 560 log10(_Float16 __x) 561 { return _Float16(__builtin_log10f(__x)); } 562 563 inline _Float16 564 modf(_Float16 __x, _Float16* __iptr) 565 { 566 float __i, __ret = __builtin_modff(__x, &__i); 567 *__iptr = _Float16(__i); 568 return _Float16(__ret); 569 } 570 571 constexpr _Float16 572 pow(_Float16 __x, _Float16 __y) 573 { return _Float16(__builtin_powf(__x, __y)); } 574 575 constexpr _Float16 576 sin(_Float16 __x) 577 { return _Float16(__builtin_sinf(__x)); } 578 579 constexpr _Float16 580 sinh(_Float16 __x) 581 { return _Float16(__builtin_sinhf(__x)); } 582 583 constexpr _Float16 584 sqrt(_Float16 __x) 585 { return _Float16(__builtin_sqrtf(__x)); } 586 587 constexpr _Float16 588 tan(_Float16 __x) 589 { return _Float16(__builtin_tanf(__x)); } 590 591 constexpr _Float16 592 tanh(_Float16 __x) 593 { return _Float16(__builtin_tanhf(__x)); } 594 #endif 595 596 #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) 597 constexpr _Float32 598 acos(_Float32 __x) 599 { return __builtin_acosf(__x); } 600 601 constexpr _Float32 602 asin(_Float32 __x) 603 { return __builtin_asinf(__x); } 604 605 constexpr _Float32 606 atan(_Float32 __x) 607 { return __builtin_atanf(__x); } 608 609 constexpr _Float32 610 atan2(_Float32 __y, _Float32 __x) 611 { return __builtin_atan2f(__y, __x); } 612 613 constexpr _Float32 614 ceil(_Float32 __x) 615 { return __builtin_ceilf(__x); } 616 617 constexpr _Float32 618 cos(_Float32 __x) 619 { return __builtin_cosf(__x); } 620 621 constexpr _Float32 622 cosh(_Float32 __x) 623 { return __builtin_coshf(__x); } 624 625 constexpr _Float32 626 exp(_Float32 __x) 627 { return __builtin_expf(__x); } 628 629 constexpr _Float32 630 fabs(_Float32 __x) 631 { return __builtin_fabsf(__x); } 632 633 constexpr _Float32 634 floor(_Float32 __x) 635 { return __builtin_floorf(__x); } 636 637 constexpr _Float32 638 fmod(_Float32 __x, _Float32 __y) 639 { return __builtin_fmodf(__x, __y); } 640 641 inline _Float32 642 frexp(_Float32 __x, int* __exp) 643 { return __builtin_frexpf(__x, __exp); } 644 645 constexpr _Float32 646 ldexp(_Float32 __x, int __exp) 647 { return __builtin_ldexpf(__x, __exp); } 648 649 constexpr _Float32 650 log(_Float32 __x) 651 { return __builtin_logf(__x); } 652 653 constexpr _Float32 654 log10(_Float32 __x) 655 { return __builtin_log10f(__x); } 656 657 inline _Float32 658 modf(_Float32 __x, _Float32* __iptr) 659 { 660 float __i, __ret = __builtin_modff(__x, &__i); 661 *__iptr = __i; 662 return __ret; 663 } 664 665 constexpr _Float32 666 pow(_Float32 __x, _Float32 __y) 667 { return __builtin_powf(__x, __y); } 668 669 constexpr _Float32 670 sin(_Float32 __x) 671 { return __builtin_sinf(__x); } 672 673 constexpr _Float32 674 sinh(_Float32 __x) 675 { return __builtin_sinhf(__x); } 676 677 constexpr _Float32 678 sqrt(_Float32 __x) 679 { return __builtin_sqrtf(__x); } 680 681 constexpr _Float32 682 tan(_Float32 __x) 683 { return __builtin_tanf(__x); } 684 685 constexpr _Float32 686 tanh(_Float32 __x) 687 { return __builtin_tanhf(__x); } 688 #endif 689 690 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) 691 constexpr _Float64 692 acos(_Float64 __x) 693 { return __builtin_acos(__x); } 694 695 constexpr _Float64 696 asin(_Float64 __x) 697 { return __builtin_asin(__x); } 698 699 constexpr _Float64 700 atan(_Float64 __x) 701 { return __builtin_atan(__x); } 702 703 constexpr _Float64 704 atan2(_Float64 __y, _Float64 __x) 705 { return __builtin_atan2(__y, __x); } 706 707 constexpr _Float64 708 ceil(_Float64 __x) 709 { return __builtin_ceil(__x); } 710 711 constexpr _Float64 712 cos(_Float64 __x) 713 { return __builtin_cos(__x); } 714 715 constexpr _Float64 716 cosh(_Float64 __x) 717 { return __builtin_cosh(__x); } 718 719 constexpr _Float64 720 exp(_Float64 __x) 721 { return __builtin_exp(__x); } 722 723 constexpr _Float64 724 fabs(_Float64 __x) 725 { return __builtin_fabs(__x); } 726 727 constexpr _Float64 728 floor(_Float64 __x) 729 { return __builtin_floor(__x); } 730 731 constexpr _Float64 732 fmod(_Float64 __x, _Float64 __y) 733 { return __builtin_fmod(__x, __y); } 734 735 inline _Float64 736 frexp(_Float64 __x, int* __exp) 737 { return __builtin_frexp(__x, __exp); } 738 739 constexpr _Float64 740 ldexp(_Float64 __x, int __exp) 741 { return __builtin_ldexp(__x, __exp); } 742 743 constexpr _Float64 744 log(_Float64 __x) 745 { return __builtin_log(__x); } 746 747 constexpr _Float64 748 log10(_Float64 __x) 749 { return __builtin_log10(__x); } 750 751 inline _Float64 752 modf(_Float64 __x, _Float64* __iptr) 753 { 754 double __i, __ret = __builtin_modf(__x, &__i); 755 *__iptr = __i; 756 return __ret; 757 } 758 759 constexpr _Float64 760 pow(_Float64 __x, _Float64 __y) 761 { return __builtin_pow(__x, __y); } 762 763 constexpr _Float64 764 sin(_Float64 __x) 765 { return __builtin_sin(__x); } 766 767 constexpr _Float64 768 sinh(_Float64 __x) 769 { return __builtin_sinh(__x); } 770 771 constexpr _Float64 772 sqrt(_Float64 __x) 773 { return __builtin_sqrt(__x); } 774 775 constexpr _Float64 776 tan(_Float64 __x) 777 { return __builtin_tan(__x); } 778 779 constexpr _Float64 780 tanh(_Float64 __x) 781 { return __builtin_tanh(__x); } 782 #endif 783 784 #if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) 785 constexpr _Float128 786 acos(_Float128 __x) 787 { return __builtin_acosl(__x); } 788 789 constexpr _Float128 790 asin(_Float128 __x) 791 { return __builtin_asinl(__x); } 792 793 constexpr _Float128 794 atan(_Float128 __x) 795 { return __builtin_atanl(__x); } 796 797 constexpr _Float128 798 atan2(_Float128 __y, _Float128 __x) 799 { return __builtin_atan2l(__y, __x); } 800 801 constexpr _Float128 802 ceil(_Float128 __x) 803 { return __builtin_ceill(__x); } 804 805 constexpr _Float128 806 cos(_Float128 __x) 807 { return __builtin_cosl(__x); } 808 809 constexpr _Float128 810 cosh(_Float128 __x) 811 { return __builtin_coshl(__x); } 812 813 constexpr _Float128 814 exp(_Float128 __x) 815 { return __builtin_expl(__x); } 816 817 constexpr _Float128 818 fabs(_Float128 __x) 819 { return __builtin_fabsl(__x); } 820 821 constexpr _Float128 822 floor(_Float128 __x) 823 { return __builtin_floorl(__x); } 824 825 constexpr _Float128 826 fmod(_Float128 __x, _Float128 __y) 827 { return __builtin_fmodl(__x, __y); } 828 829 inline _Float128 830 frexp(_Float128 __x, int* __exp) 831 { return __builtin_frexpl(__x, __exp); } 832 833 constexpr _Float128 834 ldexp(_Float128 __x, int __exp) 835 { return __builtin_ldexpl(__x, __exp); } 836 837 constexpr _Float128 838 log(_Float128 __x) 839 { return __builtin_logl(__x); } 840 841 constexpr _Float128 842 log10(_Float128 __x) 843 { return __builtin_log10l(__x); } 844 845 inline _Float128 846 modf(_Float128 __x, _Float128* __iptr) 847 { 848 long double __i, __ret = __builtin_modfl(__x, &__i); 849 *__iptr = __i; 850 return __ret; 851 } 852 853 constexpr _Float128 854 pow(_Float128 __x, _Float128 __y) 855 { return __builtin_powl(__x, __y); } 856 857 constexpr _Float128 858 sin(_Float128 __x) 859 { return __builtin_sinl(__x); } 860 861 constexpr _Float128 862 sinh(_Float128 __x) 863 { return __builtin_sinhl(__x); } 864 865 constexpr _Float128 866 sqrt(_Float128 __x) 867 { return __builtin_sqrtl(__x); } 868 869 constexpr _Float128 870 tan(_Float128 __x) 871 { return __builtin_tanl(__x); } 872 873 constexpr _Float128 874 tanh(_Float128 __x) 875 { return __builtin_tanhl(__x); } 876 #elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) 877 constexpr _Float128 878 acos(_Float128 __x) 879 { return __builtin_acosf128(__x); } 880 881 constexpr _Float128 882 asin(_Float128 __x) 883 { return __builtin_asinf128(__x); } 884 885 constexpr _Float128 886 atan(_Float128 __x) 887 { return __builtin_atanf128(__x); } 888 889 constexpr _Float128 890 atan2(_Float128 __y, _Float128 __x) 891 { return __builtin_atan2f128(__y, __x); } 892 893 constexpr _Float128 894 ceil(_Float128 __x) 895 { return __builtin_ceilf128(__x); } 896 897 constexpr _Float128 898 cos(_Float128 __x) 899 { return __builtin_cosf128(__x); } 900 901 constexpr _Float128 902 cosh(_Float128 __x) 903 { return __builtin_coshf128(__x); } 904 905 constexpr _Float128 906 exp(_Float128 __x) 907 { return __builtin_expf128(__x); } 908 909 constexpr _Float128 910 fabs(_Float128 __x) 911 { return __builtin_fabsf128(__x); } 912 913 constexpr _Float128 914 floor(_Float128 __x) 915 { return __builtin_floorf128(__x); } 916 917 constexpr _Float128 918 fmod(_Float128 __x, _Float128 __y) 919 { return __builtin_fmodf128(__x, __y); } 920 921 inline _Float128 922 frexp(_Float128 __x, int* __exp) 923 { return __builtin_frexpf128(__x, __exp); } 924 925 constexpr _Float128 926 ldexp(_Float128 __x, int __exp) 927 { return __builtin_ldexpf128(__x, __exp); } 928 929 constexpr _Float128 930 log(_Float128 __x) 931 { return __builtin_logf128(__x); } 932 933 constexpr _Float128 934 log10(_Float128 __x) 935 { return __builtin_log10f128(__x); } 936 937 inline _Float128 938 modf(_Float128 __x, _Float128* __iptr) 939 { return __builtin_modff128(__x, __iptr); } 940 941 constexpr _Float128 942 pow(_Float128 __x, _Float128 __y) 943 { return __builtin_powf128(__x, __y); } 944 945 constexpr _Float128 946 sin(_Float128 __x) 947 { return __builtin_sinf128(__x); } 948 949 constexpr _Float128 950 sinh(_Float128 __x) 951 { return __builtin_sinhf128(__x); } 952 953 constexpr _Float128 954 sqrt(_Float128 __x) 955 { return __builtin_sqrtf128(__x); } 956 957 constexpr _Float128 958 tan(_Float128 __x) 959 { return __builtin_tanf128(__x); } 960 961 constexpr _Float128 962 tanh(_Float128 __x) 963 { return __builtin_tanhf128(__x); } 964 #endif 965 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)); } 970 971 constexpr __gnu_cxx::__bfloat16_t 972 asin(__gnu_cxx::__bfloat16_t __x) 973 { return __gnu_cxx::__bfloat16_t(__builtin_asinf(__x)); } 974 975 constexpr __gnu_cxx::__bfloat16_t 976 atan(__gnu_cxx::__bfloat16_t __x) 977 { return __gnu_cxx::__bfloat16_t(__builtin_atanf(__x)); } 978 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)); } 982 983 constexpr __gnu_cxx::__bfloat16_t 984 ceil(__gnu_cxx::__bfloat16_t __x) 985 { return __gnu_cxx::__bfloat16_t(__builtin_ceilf(__x)); } 986 987 constexpr __gnu_cxx::__bfloat16_t 988 cos(__gnu_cxx::__bfloat16_t __x) 989 { return __gnu_cxx::__bfloat16_t(__builtin_cosf(__x)); } 990 991 constexpr __gnu_cxx::__bfloat16_t 992 cosh(__gnu_cxx::__bfloat16_t __x) 993 { return __gnu_cxx::__bfloat16_t(__builtin_coshf(__x)); } 994 995 constexpr __gnu_cxx::__bfloat16_t 996 exp(__gnu_cxx::__bfloat16_t __x) 997 { return __gnu_cxx::__bfloat16_t(__builtin_expf(__x)); } 998 999 constexpr __gnu_cxx::__bfloat16_t 1000 fabs(__gnu_cxx::__bfloat16_t __x) 1001 { return __gnu_cxx::__bfloat16_t(__builtin_fabsf(__x)); } 1002 1003 constexpr __gnu_cxx::__bfloat16_t 1004 floor(__gnu_cxx::__bfloat16_t __x) 1005 { return __gnu_cxx::__bfloat16_t(__builtin_floorf(__x)); } 1006 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)); } 1010 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)); } 1014 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)); } 1018 1019 constexpr __gnu_cxx::__bfloat16_t 1020 log(__gnu_cxx::__bfloat16_t __x) 1021 { return __gnu_cxx::__bfloat16_t(__builtin_logf(__x)); } 1022 1023 constexpr __gnu_cxx::__bfloat16_t 1024 log10(__gnu_cxx::__bfloat16_t __x) 1025 { return __gnu_cxx::__bfloat16_t(__builtin_log10f(__x)); } 1026 1027 inline __gnu_cxx::__bfloat16_t 1028 modf(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t* __iptr) 1029 { 1030 float __i, __ret = __builtin_modff(__x, &__i); 1031 *__iptr = __gnu_cxx::__bfloat16_t(__i); 1032 return __gnu_cxx::__bfloat16_t(__ret); 1033 } 1034 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)); } 1038 1039 constexpr __gnu_cxx::__bfloat16_t 1040 sin(__gnu_cxx::__bfloat16_t __x) 1041 { return __gnu_cxx::__bfloat16_t(__builtin_sinf(__x)); } 1042 1043 constexpr __gnu_cxx::__bfloat16_t 1044 sinh(__gnu_cxx::__bfloat16_t __x) 1045 { return __gnu_cxx::__bfloat16_t(__builtin_sinhf(__x)); } 1046 1047 constexpr __gnu_cxx::__bfloat16_t 1048 sqrt(__gnu_cxx::__bfloat16_t __x) 1049 { return __gnu_cxx::__bfloat16_t(__builtin_sqrtf(__x)); } 1050 1051 constexpr __gnu_cxx::__bfloat16_t 1052 tan(__gnu_cxx::__bfloat16_t __x) 1053 { return __gnu_cxx::__bfloat16_t(__builtin_tanf(__x)); } 1054 1055 constexpr __gnu_cxx::__bfloat16_t 1056 tanh(__gnu_cxx::__bfloat16_t __x) 1057 { return __gnu_cxx::__bfloat16_t(__builtin_tanhf(__x)); } 1058 #endif 1059 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) 1064 { 1065 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1066 return atan2(__type(__y), __type(__x)); 1067 } 1068 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) 1073 { 1074 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1075 return fmod(__type(__x), __type(__y)); 1076 } 1077 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) 1082 { 1083 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1084 return pow(__type(__x), __type(__y)); 1085 } 1086 1087 #if _GLIBCXX_USE_C99_MATH 1088 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC 1089 1090 // These are possible macros imported from C99-land. 1091 #undef fpclassify 1092 #undef isfinite 1093 #undef isinf 1094 #undef isnan 1095 #undef isnormal 1096 #undef signbit 1097 #undef isgreater 1098 #undef isgreaterequal 1099 #undef isless 1100 #undef islessequal 1101 #undef islessgreater 1102 #undef isunordered 1103 1104 #if __cplusplus >= 201103L 1105 1106 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1107 constexpr int 1108 fpclassify(float __x) 1109 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 1110 FP_SUBNORMAL, FP_ZERO, __x); } 1111 1112 constexpr int 1113 fpclassify(double __x) 1114 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 1115 FP_SUBNORMAL, FP_ZERO, __x); } 1116 1117 constexpr int 1118 fpclassify(long double __x) 1119 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 1120 FP_SUBNORMAL, FP_ZERO, __x); } 1121 #endif 1122 1123 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1124 template<typename _Tp> 1125 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1126 int>::__type 1127 fpclassify(_Tp __x) 1128 { return __x != 0 ? FP_NORMAL : FP_ZERO; } 1129 #endif 1130 1131 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1132 constexpr bool 1133 isfinite(float __x) 1134 { return __builtin_isfinite(__x); } 1135 1136 constexpr bool 1137 isfinite(double __x) 1138 { return __builtin_isfinite(__x); } 1139 1140 constexpr bool 1141 isfinite(long double __x) 1142 { return __builtin_isfinite(__x); } 1143 #endif 1144 1145 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1146 template<typename _Tp> 1147 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1148 bool>::__type 1149 isfinite(_Tp) 1150 { return true; } 1151 #endif 1152 1153 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1154 constexpr bool 1155 isinf(float __x) 1156 { return __builtin_isinf(__x); } 1157 1158 #if _GLIBCXX_HAVE_OBSOLETE_ISINF \ 1159 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC 1160 using ::isinf; 1161 #else 1162 constexpr bool 1163 isinf(double __x) 1164 { return __builtin_isinf(__x); } 1165 #endif 1166 1167 constexpr bool 1168 isinf(long double __x) 1169 { return __builtin_isinf(__x); } 1170 #endif 1171 1172 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1173 template<typename _Tp> 1174 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1175 bool>::__type 1176 isinf(_Tp) 1177 { return false; } 1178 #endif 1179 1180 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1181 constexpr bool 1182 isnan(float __x) 1183 { return __builtin_isnan(__x); } 1184 1185 #if _GLIBCXX_HAVE_OBSOLETE_ISNAN \ 1186 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC 1187 using ::isnan; 1188 #else 1189 constexpr bool 1190 isnan(double __x) 1191 { return __builtin_isnan(__x); } 1192 #endif 1193 1194 constexpr bool 1195 isnan(long double __x) 1196 { return __builtin_isnan(__x); } 1197 #endif 1198 1199 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1200 template<typename _Tp> 1201 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1202 bool>::__type 1203 isnan(_Tp) 1204 { return false; } 1205 #endif 1206 1207 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1208 constexpr bool 1209 isnormal(float __x) 1210 { return __builtin_isnormal(__x); } 1211 1212 constexpr bool 1213 isnormal(double __x) 1214 { return __builtin_isnormal(__x); } 1215 1216 constexpr bool 1217 isnormal(long double __x) 1218 { return __builtin_isnormal(__x); } 1219 #endif 1220 1221 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1222 template<typename _Tp> 1223 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1224 bool>::__type 1225 isnormal(_Tp __x) 1226 { return __x != 0 ? true : false; } 1227 #endif 1228 1229 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1230 // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic. 1231 constexpr bool 1232 signbit(float __x) 1233 { return __builtin_signbit(__x); } 1234 1235 constexpr bool 1236 signbit(double __x) 1237 { return __builtin_signbit(__x); } 1238 1239 constexpr bool 1240 signbit(long double __x) 1241 { return __builtin_signbit(__x); } 1242 #endif 1243 1244 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1245 template<typename _Tp> 1246 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1247 bool>::__type 1248 signbit(_Tp __x) 1249 { return __x < 0 ? true : false; } 1250 #endif 1251 1252 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1253 constexpr bool 1254 isgreater(float __x, float __y) 1255 { return __builtin_isgreater(__x, __y); } 1256 1257 constexpr bool 1258 isgreater(double __x, double __y) 1259 { return __builtin_isgreater(__x, __y); } 1260 1261 constexpr bool 1262 isgreater(long double __x, long double __y) 1263 { return __builtin_isgreater(__x, __y); } 1264 #endif 1265 1266 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1267 template<typename _Tp, typename _Up> 1268 constexpr typename 1269 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 1270 && __is_arithmetic<_Up>::__value), bool>::__type 1271 isgreater(_Tp __x, _Up __y) 1272 { 1273 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1274 return __builtin_isgreater(__type(__x), __type(__y)); 1275 } 1276 #endif 1277 1278 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1279 constexpr bool 1280 isgreaterequal(float __x, float __y) 1281 { return __builtin_isgreaterequal(__x, __y); } 1282 1283 constexpr bool 1284 isgreaterequal(double __x, double __y) 1285 { return __builtin_isgreaterequal(__x, __y); } 1286 1287 constexpr bool 1288 isgreaterequal(long double __x, long double __y) 1289 { return __builtin_isgreaterequal(__x, __y); } 1290 #endif 1291 1292 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1293 template<typename _Tp, typename _Up> 1294 constexpr typename 1295 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 1296 && __is_arithmetic<_Up>::__value), bool>::__type 1297 isgreaterequal(_Tp __x, _Up __y) 1298 { 1299 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1300 return __builtin_isgreaterequal(__type(__x), __type(__y)); 1301 } 1302 #endif 1303 1304 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1305 constexpr bool 1306 isless(float __x, float __y) 1307 { return __builtin_isless(__x, __y); } 1308 1309 constexpr bool 1310 isless(double __x, double __y) 1311 { return __builtin_isless(__x, __y); } 1312 1313 constexpr bool 1314 isless(long double __x, long double __y) 1315 { return __builtin_isless(__x, __y); } 1316 #endif 1317 1318 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1319 template<typename _Tp, typename _Up> 1320 constexpr typename 1321 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 1322 && __is_arithmetic<_Up>::__value), bool>::__type 1323 isless(_Tp __x, _Up __y) 1324 { 1325 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1326 return __builtin_isless(__type(__x), __type(__y)); 1327 } 1328 #endif 1329 1330 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1331 constexpr bool 1332 islessequal(float __x, float __y) 1333 { return __builtin_islessequal(__x, __y); } 1334 1335 constexpr bool 1336 islessequal(double __x, double __y) 1337 { return __builtin_islessequal(__x, __y); } 1338 1339 constexpr bool 1340 islessequal(long double __x, long double __y) 1341 { return __builtin_islessequal(__x, __y); } 1342 #endif 1343 1344 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1345 template<typename _Tp, typename _Up> 1346 constexpr typename 1347 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 1348 && __is_arithmetic<_Up>::__value), bool>::__type 1349 islessequal(_Tp __x, _Up __y) 1350 { 1351 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1352 return __builtin_islessequal(__type(__x), __type(__y)); 1353 } 1354 #endif 1355 1356 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1357 constexpr bool 1358 islessgreater(float __x, float __y) 1359 { return __builtin_islessgreater(__x, __y); } 1360 1361 constexpr bool 1362 islessgreater(double __x, double __y) 1363 { return __builtin_islessgreater(__x, __y); } 1364 1365 constexpr bool 1366 islessgreater(long double __x, long double __y) 1367 { return __builtin_islessgreater(__x, __y); } 1368 #endif 1369 1370 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1371 template<typename _Tp, typename _Up> 1372 constexpr typename 1373 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 1374 && __is_arithmetic<_Up>::__value), bool>::__type 1375 islessgreater(_Tp __x, _Up __y) 1376 { 1377 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1378 return __builtin_islessgreater(__type(__x), __type(__y)); 1379 } 1380 #endif 1381 1382 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 1383 constexpr bool 1384 isunordered(float __x, float __y) 1385 { return __builtin_isunordered(__x, __y); } 1386 1387 constexpr bool 1388 isunordered(double __x, double __y) 1389 { return __builtin_isunordered(__x, __y); } 1390 1391 constexpr bool 1392 isunordered(long double __x, long double __y) 1393 { return __builtin_isunordered(__x, __y); } 1394 #endif 1395 1396 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 1397 template<typename _Tp, typename _Up> 1398 constexpr typename 1399 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 1400 && __is_arithmetic<_Up>::__value), bool>::__type 1401 isunordered(_Tp __x, _Up __y) 1402 { 1403 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1404 return __builtin_isunordered(__type(__x), __type(__y)); 1405 } 1406 #endif 1407 1408 #else 1409 1410 template<typename _Tp> 1411 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1412 int>::__type 1413 fpclassify(_Tp __f) 1414 { 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)); 1418 } 1419 1420 template<typename _Tp> 1421 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1422 int>::__type 1423 isfinite(_Tp __f) 1424 { 1425 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1426 return __builtin_isfinite(__type(__f)); 1427 } 1428 1429 template<typename _Tp> 1430 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1431 int>::__type 1432 isinf(_Tp __f) 1433 { 1434 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1435 return __builtin_isinf(__type(__f)); 1436 } 1437 1438 template<typename _Tp> 1439 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1440 int>::__type 1441 isnan(_Tp __f) 1442 { 1443 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1444 return __builtin_isnan(__type(__f)); 1445 } 1446 1447 template<typename _Tp> 1448 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1449 int>::__type 1450 isnormal(_Tp __f) 1451 { 1452 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1453 return __builtin_isnormal(__type(__f)); 1454 } 1455 1456 template<typename _Tp> 1457 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1458 int>::__type 1459 signbit(_Tp __f) 1460 { 1461 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1462 return __builtin_signbit(__type(__f)); 1463 } 1464 1465 template<typename _Tp> 1466 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1467 int>::__type 1468 isgreater(_Tp __f1, _Tp __f2) 1469 { 1470 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1471 return __builtin_isgreater(__type(__f1), __type(__f2)); 1472 } 1473 1474 template<typename _Tp> 1475 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1476 int>::__type 1477 isgreaterequal(_Tp __f1, _Tp __f2) 1478 { 1479 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1480 return __builtin_isgreaterequal(__type(__f1), __type(__f2)); 1481 } 1482 1483 template<typename _Tp> 1484 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1485 int>::__type 1486 isless(_Tp __f1, _Tp __f2) 1487 { 1488 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1489 return __builtin_isless(__type(__f1), __type(__f2)); 1490 } 1491 1492 template<typename _Tp> 1493 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1494 int>::__type 1495 islessequal(_Tp __f1, _Tp __f2) 1496 { 1497 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1498 return __builtin_islessequal(__type(__f1), __type(__f2)); 1499 } 1500 1501 template<typename _Tp> 1502 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1503 int>::__type 1504 islessgreater(_Tp __f1, _Tp __f2) 1505 { 1506 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1507 return __builtin_islessgreater(__type(__f1), __type(__f2)); 1508 } 1509 1510 template<typename _Tp> 1511 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 1512 int>::__type 1513 isunordered(_Tp __f1, _Tp __f2) 1514 { 1515 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 1516 return __builtin_isunordered(__type(__f1), __type(__f2)); 1517 } 1518 1519 #endif // C++11 1520 1521 #ifdef __STDCPP_FLOAT16_T__ 1522 constexpr int 1523 fpclassify(_Float16 __x) 1524 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 1525 FP_SUBNORMAL, FP_ZERO, __x); } 1526 1527 constexpr bool 1528 isfinite(_Float16 __x) 1529 { return __builtin_isfinite(__x); } 1530 1531 constexpr bool 1532 isinf(_Float16 __x) 1533 { return __builtin_isinf(__x); } 1534 1535 constexpr bool 1536 isnan(_Float16 __x) 1537 { return __builtin_isnan(__x); } 1538 1539 constexpr bool 1540 isnormal(_Float16 __x) 1541 { return __builtin_isnormal(__x); } 1542 1543 constexpr bool 1544 signbit(_Float16 __x) 1545 { return __builtin_signbit(__x); } 1546 1547 constexpr bool 1548 isgreater(_Float16 __x, _Float16 __y) 1549 { return __builtin_isgreater(__x, __y); } 1550 1551 constexpr bool 1552 isgreaterequal(_Float16 __x, _Float16 __y) 1553 { return __builtin_isgreaterequal(__x, __y); } 1554 1555 constexpr bool 1556 isless(_Float16 __x, _Float16 __y) 1557 { return __builtin_isless(__x, __y); } 1558 1559 constexpr bool 1560 islessequal(_Float16 __x, _Float16 __y) 1561 { return __builtin_islessequal(__x, __y); } 1562 1563 constexpr bool 1564 islessgreater(_Float16 __x, _Float16 __y) 1565 { return __builtin_islessgreater(__x, __y); } 1566 1567 constexpr bool 1568 isunordered(_Float16 __x, _Float16 __y) 1569 { return __builtin_isunordered(__x, __y); } 1570 #endif 1571 1572 #ifdef __STDCPP_FLOAT32_T__ 1573 constexpr int 1574 fpclassify(_Float32 __x) 1575 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 1576 FP_SUBNORMAL, FP_ZERO, __x); } 1577 1578 constexpr bool 1579 isfinite(_Float32 __x) 1580 { return __builtin_isfinite(__x); } 1581 1582 constexpr bool 1583 isinf(_Float32 __x) 1584 { return __builtin_isinf(__x); } 1585 1586 constexpr bool 1587 isnan(_Float32 __x) 1588 { return __builtin_isnan(__x); } 1589 1590 constexpr bool 1591 isnormal(_Float32 __x) 1592 { return __builtin_isnormal(__x); } 1593 1594 constexpr bool 1595 signbit(_Float32 __x) 1596 { return __builtin_signbit(__x); } 1597 1598 constexpr bool 1599 isgreater(_Float32 __x, _Float32 __y) 1600 { return __builtin_isgreater(__x, __y); } 1601 1602 constexpr bool 1603 isgreaterequal(_Float32 __x, _Float32 __y) 1604 { return __builtin_isgreaterequal(__x, __y); } 1605 1606 constexpr bool 1607 isless(_Float32 __x, _Float32 __y) 1608 { return __builtin_isless(__x, __y); } 1609 1610 constexpr bool 1611 islessequal(_Float32 __x, _Float32 __y) 1612 { return __builtin_islessequal(__x, __y); } 1613 1614 constexpr bool 1615 islessgreater(_Float32 __x, _Float32 __y) 1616 { return __builtin_islessgreater(__x, __y); } 1617 1618 constexpr bool 1619 isunordered(_Float32 __x, _Float32 __y) 1620 { return __builtin_isunordered(__x, __y); } 1621 #endif 1622 1623 #ifdef __STDCPP_FLOAT64_T__ 1624 constexpr int 1625 fpclassify(_Float64 __x) 1626 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 1627 FP_SUBNORMAL, FP_ZERO, __x); } 1628 1629 constexpr bool 1630 isfinite(_Float64 __x) 1631 { return __builtin_isfinite(__x); } 1632 1633 constexpr bool 1634 isinf(_Float64 __x) 1635 { return __builtin_isinf(__x); } 1636 1637 constexpr bool 1638 isnan(_Float64 __x) 1639 { return __builtin_isnan(__x); } 1640 1641 constexpr bool 1642 isnormal(_Float64 __x) 1643 { return __builtin_isnormal(__x); } 1644 1645 constexpr bool 1646 signbit(_Float64 __x) 1647 { return __builtin_signbit(__x); } 1648 1649 constexpr bool 1650 isgreater(_Float64 __x, _Float64 __y) 1651 { return __builtin_isgreater(__x, __y); } 1652 1653 constexpr bool 1654 isgreaterequal(_Float64 __x, _Float64 __y) 1655 { return __builtin_isgreaterequal(__x, __y); } 1656 1657 constexpr bool 1658 isless(_Float64 __x, _Float64 __y) 1659 { return __builtin_isless(__x, __y); } 1660 1661 constexpr bool 1662 islessequal(_Float64 __x, _Float64 __y) 1663 { return __builtin_islessequal(__x, __y); } 1664 1665 constexpr bool 1666 islessgreater(_Float64 __x, _Float64 __y) 1667 { return __builtin_islessgreater(__x, __y); } 1668 1669 constexpr bool 1670 isunordered(_Float64 __x, _Float64 __y) 1671 { return __builtin_isunordered(__x, __y); } 1672 #endif 1673 1674 #ifdef __STDCPP_FLOAT128_T__ 1675 constexpr int 1676 fpclassify(_Float128 __x) 1677 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 1678 FP_SUBNORMAL, FP_ZERO, __x); } 1679 1680 constexpr bool 1681 isfinite(_Float128 __x) 1682 { return __builtin_isfinite(__x); } 1683 1684 constexpr bool 1685 isinf(_Float128 __x) 1686 { return __builtin_isinf(__x); } 1687 1688 constexpr bool 1689 isnan(_Float128 __x) 1690 { return __builtin_isnan(__x); } 1691 1692 constexpr bool 1693 isnormal(_Float128 __x) 1694 { return __builtin_isnormal(__x); } 1695 1696 constexpr bool 1697 signbit(_Float128 __x) 1698 { return __builtin_signbit(__x); } 1699 1700 constexpr bool 1701 isgreater(_Float128 __x, _Float128 __y) 1702 { return __builtin_isgreater(__x, __y); } 1703 1704 constexpr bool 1705 isgreaterequal(_Float128 __x, _Float128 __y) 1706 { return __builtin_isgreaterequal(__x, __y); } 1707 1708 constexpr bool 1709 isless(_Float128 __x, _Float128 __y) 1710 { return __builtin_isless(__x, __y); } 1711 1712 constexpr bool 1713 islessequal(_Float128 __x, _Float128 __y) 1714 { return __builtin_islessequal(__x, __y); } 1715 1716 constexpr bool 1717 islessgreater(_Float128 __x, _Float128 __y) 1718 { return __builtin_islessgreater(__x, __y); } 1719 1720 constexpr bool 1721 isunordered(_Float128 __x, _Float128 __y) 1722 { return __builtin_isunordered(__x, __y); } 1723 #endif 1724 1725 #ifdef __STDCPP_BFLOAT16_T__ 1726 constexpr int 1727 fpclassify(__gnu_cxx::__bfloat16_t __x) 1728 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 1729 FP_SUBNORMAL, FP_ZERO, __x); } 1730 1731 constexpr bool 1732 isfinite(__gnu_cxx::__bfloat16_t __x) 1733 { return __builtin_isfinite(__x); } 1734 1735 constexpr bool 1736 isinf(__gnu_cxx::__bfloat16_t __x) 1737 { return __builtin_isinf(__x); } 1738 1739 constexpr bool 1740 isnan(__gnu_cxx::__bfloat16_t __x) 1741 { return __builtin_isnan(__x); } 1742 1743 constexpr bool 1744 isnormal(__gnu_cxx::__bfloat16_t __x) 1745 { return __builtin_isnormal(__x); } 1746 1747 constexpr bool 1748 signbit(__gnu_cxx::__bfloat16_t __x) 1749 { return __builtin_signbit(__x); } 1750 1751 constexpr bool 1752 isgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) 1753 { return __builtin_isgreater(__x, __y); } 1754 1755 constexpr bool 1756 isgreaterequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) 1757 { return __builtin_isgreaterequal(__x, __y); } 1758 1759 constexpr bool 1760 isless(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) 1761 { return __builtin_isless(__x, __y); } 1762 1763 constexpr bool 1764 islessequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) 1765 { return __builtin_islessequal(__x, __y); } 1766 1767 constexpr bool 1768 islessgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) 1769 { return __builtin_islessgreater(__x, __y); } 1770 1771 constexpr bool 1772 isunordered(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) 1773 { return __builtin_isunordered(__x, __y); } 1774 #endif 1775 1776 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */ 1777 #endif /* _GLIBCXX_USE_C99_MATH */ 1778 1779 #if __cplusplus >= 201103L 1780 1781 #undef acosf 1782 #undef acosl 1783 #undef asinf 1784 #undef asinl 1785 #undef atanf 1786 #undef atanl 1787 #undef atan2f 1788 #undef atan2l 1789 #undef ceilf 1790 #undef ceill 1791 #undef cosf 1792 #undef cosl 1793 #undef coshf 1794 #undef coshl 1795 #undef expf 1796 #undef expl 1797 #undef fabsf 1798 #undef fabsl 1799 #undef floorf 1800 #undef floorl 1801 #undef fmodf 1802 #undef fmodl 1803 #undef frexpf 1804 #undef frexpl 1805 #undef ldexpf 1806 #undef ldexpl 1807 #undef logf 1808 #undef logl 1809 #undef log10f 1810 #undef log10l 1811 #undef modff 1812 #undef modfl 1813 #undef powf 1814 #undef powl 1815 #undef sinf 1816 #undef sinl 1817 #undef sinhf 1818 #undef sinhl 1819 #undef sqrtf 1820 #undef sqrtl 1821 #undef tanf 1822 #undef tanl 1823 #undef tanhf 1824 #undef tanhl 1825 1826 #ifdef _GLIBCXX_HAVE_ACOSF 1827 using ::acosf; 1828 #endif 1829 #ifdef _GLIBCXX_HAVE_ACOSL 1830 using ::acosl; 1831 #endif 1832 1833 #ifdef _GLIBCXX_HAVE_ASINF 1834 using ::asinf; 1835 #endif 1836 #ifdef _GLIBCXX_HAVE_ASINL 1837 using ::asinl; 1838 #endif 1839 1840 #ifdef _GLIBCXX_HAVE_ATANF 1841 using ::atanf; 1842 #endif 1843 #ifdef _GLIBCXX_HAVE_ATANL 1844 using ::atanl; 1845 #endif 1846 1847 #ifdef _GLIBCXX_HAVE_ATAN2F 1848 using ::atan2f; 1849 #endif 1850 #ifdef _GLIBCXX_HAVE_ATAN2L 1851 using ::atan2l; 1852 #endif 1853 1854 #ifdef _GLIBCXX_HAVE_CEILF 1855 using ::ceilf; 1856 #endif 1857 #ifdef _GLIBCXX_HAVE_CEILL 1858 using ::ceill; 1859 #endif 1860 1861 #ifdef _GLIBCXX_HAVE_COSF 1862 using ::cosf; 1863 #endif 1864 #ifdef _GLIBCXX_HAVE_COSL 1865 using ::cosl; 1866 #endif 1867 1868 #ifdef _GLIBCXX_HAVE_COSHF 1869 using ::coshf; 1870 #endif 1871 #ifdef _GLIBCXX_HAVE_COSHL 1872 using ::coshl; 1873 #endif 1874 1875 #ifdef _GLIBCXX_HAVE_EXPF 1876 using ::expf; 1877 #endif 1878 #ifdef _GLIBCXX_HAVE_EXPL 1879 using ::expl; 1880 #endif 1881 1882 #ifdef _GLIBCXX_HAVE_FABSF 1883 using ::fabsf; 1884 #endif 1885 #ifdef _GLIBCXX_HAVE_FABSL 1886 using ::fabsl; 1887 #endif 1888 1889 #ifdef _GLIBCXX_HAVE_FLOORF 1890 using ::floorf; 1891 #endif 1892 #ifdef _GLIBCXX_HAVE_FLOORL 1893 using ::floorl; 1894 #endif 1895 1896 #ifdef _GLIBCXX_HAVE_FMODF 1897 using ::fmodf; 1898 #endif 1899 #ifdef _GLIBCXX_HAVE_FMODL 1900 using ::fmodl; 1901 #endif 1902 1903 #ifdef _GLIBCXX_HAVE_FREXPF 1904 using ::frexpf; 1905 #endif 1906 #ifdef _GLIBCXX_HAVE_FREXPL 1907 using ::frexpl; 1908 #endif 1909 1910 #ifdef _GLIBCXX_HAVE_LDEXPF 1911 using ::ldexpf; 1912 #endif 1913 #ifdef _GLIBCXX_HAVE_LDEXPL 1914 using ::ldexpl; 1915 #endif 1916 1917 #ifdef _GLIBCXX_HAVE_LOGF 1918 using ::logf; 1919 #endif 1920 #ifdef _GLIBCXX_HAVE_LOGL 1921 using ::logl; 1922 #endif 1923 1924 #ifdef _GLIBCXX_HAVE_LOG10F 1925 using ::log10f; 1926 #endif 1927 #ifdef _GLIBCXX_HAVE_LOG10L 1928 using ::log10l; 1929 #endif 1930 1931 #ifdef _GLIBCXX_HAVE_MODFF 1932 using ::modff; 1933 #endif 1934 #ifdef _GLIBCXX_HAVE_MODFL 1935 using ::modfl; 1936 #endif 1937 1938 #ifdef _GLIBCXX_HAVE_POWF 1939 using ::powf; 1940 #endif 1941 #ifdef _GLIBCXX_HAVE_POWL 1942 using ::powl; 1943 #endif 1944 1945 #ifdef _GLIBCXX_HAVE_SINF 1946 using ::sinf; 1947 #endif 1948 #ifdef _GLIBCXX_HAVE_SINL 1949 using ::sinl; 1950 #endif 1951 1952 #ifdef _GLIBCXX_HAVE_SINHF 1953 using ::sinhf; 1954 #endif 1955 #ifdef _GLIBCXX_HAVE_SINHL 1956 using ::sinhl; 1957 #endif 1958 1959 #ifdef _GLIBCXX_HAVE_SQRTF 1960 using ::sqrtf; 1961 #endif 1962 #ifdef _GLIBCXX_HAVE_SQRTL 1963 using ::sqrtl; 1964 #endif 1965 1966 #ifdef _GLIBCXX_HAVE_TANF 1967 using ::tanf; 1968 #endif 1969 #ifdef _GLIBCXX_HAVE_TANL 1970 using ::tanl; 1971 #endif 1972 1973 #ifdef _GLIBCXX_HAVE_TANHF 1974 using ::tanhf; 1975 #endif 1976 #ifdef _GLIBCXX_HAVE_TANHL 1977 using ::tanhl; 1978 #endif 1979 1980 #ifdef _GLIBCXX_USE_C99_MATH_FUNCS 1981 1982 #undef acosh 1983 #undef acoshf 1984 #undef acoshl 1985 #undef asinh 1986 #undef asinhf 1987 #undef asinhl 1988 #undef atanh 1989 #undef atanhf 1990 #undef atanhl 1991 #undef cbrt 1992 #undef cbrtf 1993 #undef cbrtl 1994 #undef copysign 1995 #undef copysignf 1996 #undef copysignl 1997 #undef erf 1998 #undef erff 1999 #undef erfl 2000 #undef erfc 2001 #undef erfcf 2002 #undef erfcl 2003 #undef exp2 2004 #undef exp2f 2005 #undef exp2l 2006 #undef expm1 2007 #undef expm1f 2008 #undef expm1l 2009 #undef fdim 2010 #undef fdimf 2011 #undef fdiml 2012 #undef fma 2013 #undef fmaf 2014 #undef fmal 2015 #undef fmax 2016 #undef fmaxf 2017 #undef fmaxl 2018 #undef fmin 2019 #undef fminf 2020 #undef fminl 2021 #undef hypot 2022 #undef hypotf 2023 #undef hypotl 2024 #undef ilogb 2025 #undef ilogbf 2026 #undef ilogbl 2027 #undef lgamma 2028 #undef lgammaf 2029 #undef lgammal 2030 #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS 2031 #undef llrint 2032 #undef llrintf 2033 #undef llrintl 2034 #undef llround 2035 #undef llroundf 2036 #undef llroundl 2037 #endif 2038 #undef log1p 2039 #undef log1pf 2040 #undef log1pl 2041 #undef log2 2042 #undef log2f 2043 #undef log2l 2044 #undef logb 2045 #undef logbf 2046 #undef logbl 2047 #undef lrint 2048 #undef lrintf 2049 #undef lrintl 2050 #undef lround 2051 #undef lroundf 2052 #undef lroundl 2053 #undef nan 2054 #undef nanf 2055 #undef nanl 2056 #undef nearbyint 2057 #undef nearbyintf 2058 #undef nearbyintl 2059 #undef nextafter 2060 #undef nextafterf 2061 #undef nextafterl 2062 #undef nexttoward 2063 #undef nexttowardf 2064 #undef nexttowardl 2065 #undef remainder 2066 #undef remainderf 2067 #undef remainderl 2068 #undef remquo 2069 #undef remquof 2070 #undef remquol 2071 #undef rint 2072 #undef rintf 2073 #undef rintl 2074 #undef round 2075 #undef roundf 2076 #undef roundl 2077 #undef scalbln 2078 #undef scalblnf 2079 #undef scalblnl 2080 #undef scalbn 2081 #undef scalbnf 2082 #undef scalbnl 2083 #undef tgamma 2084 #undef tgammaf 2085 #undef tgammal 2086 #undef trunc 2087 #undef truncf 2088 #undef truncl 2089 2090 #ifdef _GLIBCXX_HAVE_C99_FLT_EVAL_TYPES 2091 // types 2092 using ::double_t; 2093 using ::float_t; 2094 #endif 2095 2096 // functions 2097 using ::acosh; 2098 using ::acoshf; 2099 using ::acoshl; 2100 2101 using ::asinh; 2102 using ::asinhf; 2103 using ::asinhl; 2104 2105 using ::atanh; 2106 using ::atanhf; 2107 using ::atanhl; 2108 2109 using ::cbrt; 2110 using ::cbrtf; 2111 using ::cbrtl; 2112 2113 using ::copysign; 2114 using ::copysignf; 2115 using ::copysignl; 2116 2117 using ::erf; 2118 using ::erff; 2119 using ::erfl; 2120 2121 using ::erfc; 2122 using ::erfcf; 2123 using ::erfcl; 2124 2125 using ::exp2; 2126 using ::exp2f; 2127 using ::exp2l; 2128 2129 using ::expm1; 2130 using ::expm1f; 2131 using ::expm1l; 2132 2133 using ::fdim; 2134 using ::fdimf; 2135 using ::fdiml; 2136 2137 using ::fma; 2138 using ::fmaf; 2139 using ::fmal; 2140 2141 using ::fmax; 2142 using ::fmaxf; 2143 using ::fmaxl; 2144 2145 using ::fmin; 2146 using ::fminf; 2147 using ::fminl; 2148 2149 using ::hypot; 2150 using ::hypotf; 2151 using ::hypotl; 2152 2153 using ::ilogb; 2154 using ::ilogbf; 2155 using ::ilogbl; 2156 2157 using ::lgamma; 2158 using ::lgammaf; 2159 using ::lgammal; 2160 2161 #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS 2162 using ::llrint; 2163 using ::llrintf; 2164 using ::llrintl; 2165 2166 using ::llround; 2167 using ::llroundf; 2168 using ::llroundl; 2169 #endif 2170 2171 using ::log1p; 2172 using ::log1pf; 2173 using ::log1pl; 2174 2175 using ::log2; 2176 using ::log2f; 2177 using ::log2l; 2178 2179 using ::logb; 2180 using ::logbf; 2181 using ::logbl; 2182 2183 using ::lrint; 2184 using ::lrintf; 2185 using ::lrintl; 2186 2187 using ::lround; 2188 using ::lroundf; 2189 using ::lroundl; 2190 2191 using ::nan; 2192 using ::nanf; 2193 using ::nanl; 2194 2195 using ::nearbyint; 2196 using ::nearbyintf; 2197 using ::nearbyintl; 2198 2199 using ::nextafter; 2200 using ::nextafterf; 2201 using ::nextafterl; 2202 2203 using ::nexttoward; 2204 using ::nexttowardf; 2205 using ::nexttowardl; 2206 2207 using ::remainder; 2208 using ::remainderf; 2209 using ::remainderl; 2210 2211 using ::remquo; 2212 using ::remquof; 2213 using ::remquol; 2214 2215 using ::rint; 2216 using ::rintf; 2217 using ::rintl; 2218 2219 using ::round; 2220 using ::roundf; 2221 using ::roundl; 2222 2223 using ::scalbln; 2224 using ::scalblnf; 2225 using ::scalblnl; 2226 2227 using ::scalbn; 2228 using ::scalbnf; 2229 using ::scalbnl; 2230 2231 using ::tgamma; 2232 using ::tgammaf; 2233 using ::tgammal; 2234 2235 using ::trunc; 2236 using ::truncf; 2237 using ::truncl; 2238 2239 /// Additional overloads. 2240 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2241 constexpr float 2242 acosh(float __x) 2243 { return __builtin_acoshf(__x); } 2244 2245 constexpr long double 2246 acosh(long double __x) 2247 { return __builtin_acoshl(__x); } 2248 #endif 2249 2250 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2251 template<typename _Tp> 2252 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2253 double>::__type 2254 acosh(_Tp __x) 2255 { return __builtin_acosh(__x); } 2256 #endif 2257 2258 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2259 constexpr float 2260 asinh(float __x) 2261 { return __builtin_asinhf(__x); } 2262 2263 constexpr long double 2264 asinh(long double __x) 2265 { return __builtin_asinhl(__x); } 2266 #endif 2267 2268 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2269 template<typename _Tp> 2270 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2271 double>::__type 2272 asinh(_Tp __x) 2273 { return __builtin_asinh(__x); } 2274 #endif 2275 2276 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2277 constexpr float 2278 atanh(float __x) 2279 { return __builtin_atanhf(__x); } 2280 2281 constexpr long double 2282 atanh(long double __x) 2283 { return __builtin_atanhl(__x); } 2284 #endif 2285 2286 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2287 template<typename _Tp> 2288 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2289 double>::__type 2290 atanh(_Tp __x) 2291 { return __builtin_atanh(__x); } 2292 #endif 2293 2294 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2295 constexpr float 2296 cbrt(float __x) 2297 { return __builtin_cbrtf(__x); } 2298 2299 constexpr long double 2300 cbrt(long double __x) 2301 { return __builtin_cbrtl(__x); } 2302 #endif 2303 2304 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2305 template<typename _Tp> 2306 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2307 double>::__type 2308 cbrt(_Tp __x) 2309 { return __builtin_cbrt(__x); } 2310 #endif 2311 2312 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2313 constexpr float 2314 copysign(float __x, float __y) 2315 { return __builtin_copysignf(__x, __y); } 2316 2317 constexpr long double 2318 copysign(long double __x, long double __y) 2319 { return __builtin_copysignl(__x, __y); } 2320 #endif 2321 2322 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2323 constexpr float 2324 erf(float __x) 2325 { return __builtin_erff(__x); } 2326 2327 constexpr long double 2328 erf(long double __x) 2329 { return __builtin_erfl(__x); } 2330 #endif 2331 2332 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2333 template<typename _Tp> 2334 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2335 double>::__type 2336 erf(_Tp __x) 2337 { return __builtin_erf(__x); } 2338 #endif 2339 2340 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2341 constexpr float 2342 erfc(float __x) 2343 { return __builtin_erfcf(__x); } 2344 2345 constexpr long double 2346 erfc(long double __x) 2347 { return __builtin_erfcl(__x); } 2348 #endif 2349 2350 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2351 template<typename _Tp> 2352 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2353 double>::__type 2354 erfc(_Tp __x) 2355 { return __builtin_erfc(__x); } 2356 #endif 2357 2358 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2359 constexpr float 2360 exp2(float __x) 2361 { return __builtin_exp2f(__x); } 2362 2363 constexpr long double 2364 exp2(long double __x) 2365 { return __builtin_exp2l(__x); } 2366 #endif 2367 2368 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2369 template<typename _Tp> 2370 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2371 double>::__type 2372 exp2(_Tp __x) 2373 { return __builtin_exp2(__x); } 2374 #endif 2375 2376 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2377 constexpr float 2378 expm1(float __x) 2379 { return __builtin_expm1f(__x); } 2380 2381 constexpr long double 2382 expm1(long double __x) 2383 { return __builtin_expm1l(__x); } 2384 #endif 2385 2386 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2387 template<typename _Tp> 2388 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2389 double>::__type 2390 expm1(_Tp __x) 2391 { return __builtin_expm1(__x); } 2392 #endif 2393 2394 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2395 constexpr float 2396 fdim(float __x, float __y) 2397 { return __builtin_fdimf(__x, __y); } 2398 2399 constexpr long double 2400 fdim(long double __x, long double __y) 2401 { return __builtin_fdiml(__x, __y); } 2402 #endif 2403 2404 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2405 constexpr float 2406 fma(float __x, float __y, float __z) 2407 { return __builtin_fmaf(__x, __y, __z); } 2408 2409 constexpr long double 2410 fma(long double __x, long double __y, long double __z) 2411 { return __builtin_fmal(__x, __y, __z); } 2412 #endif 2413 2414 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2415 constexpr float 2416 fmax(float __x, float __y) 2417 { return __builtin_fmaxf(__x, __y); } 2418 2419 constexpr long double 2420 fmax(long double __x, long double __y) 2421 { return __builtin_fmaxl(__x, __y); } 2422 #endif 2423 2424 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2425 constexpr float 2426 fmin(float __x, float __y) 2427 { return __builtin_fminf(__x, __y); } 2428 2429 constexpr long double 2430 fmin(long double __x, long double __y) 2431 { return __builtin_fminl(__x, __y); } 2432 #endif 2433 2434 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2435 constexpr float 2436 hypot(float __x, float __y) 2437 { return __builtin_hypotf(__x, __y); } 2438 2439 constexpr long double 2440 hypot(long double __x, long double __y) 2441 { return __builtin_hypotl(__x, __y); } 2442 #endif 2443 2444 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2445 constexpr int 2446 ilogb(float __x) 2447 { return __builtin_ilogbf(__x); } 2448 2449 constexpr int 2450 ilogb(long double __x) 2451 { return __builtin_ilogbl(__x); } 2452 #endif 2453 2454 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2455 template<typename _Tp> 2456 constexpr 2457 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2458 int>::__type 2459 ilogb(_Tp __x) 2460 { return __builtin_ilogb(__x); } 2461 #endif 2462 2463 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2464 constexpr float 2465 lgamma(float __x) 2466 { return __builtin_lgammaf(__x); } 2467 2468 constexpr long double 2469 lgamma(long double __x) 2470 { return __builtin_lgammal(__x); } 2471 #endif 2472 2473 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2474 template<typename _Tp> 2475 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2476 double>::__type 2477 lgamma(_Tp __x) 2478 { return __builtin_lgamma(__x); } 2479 #endif 2480 2481 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2482 constexpr long long 2483 llrint(float __x) 2484 { return __builtin_llrintf(__x); } 2485 2486 constexpr long long 2487 llrint(long double __x) 2488 { return __builtin_llrintl(__x); } 2489 #endif 2490 2491 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2492 template<typename _Tp> 2493 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2494 long long>::__type 2495 llrint(_Tp __x) 2496 { return __builtin_llrint(__x); } 2497 #endif 2498 2499 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2500 constexpr long long 2501 llround(float __x) 2502 { return __builtin_llroundf(__x); } 2503 2504 constexpr long long 2505 llround(long double __x) 2506 { return __builtin_llroundl(__x); } 2507 #endif 2508 2509 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2510 template<typename _Tp> 2511 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2512 long long>::__type 2513 llround(_Tp __x) 2514 { return __builtin_llround(__x); } 2515 #endif 2516 2517 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2518 constexpr float 2519 log1p(float __x) 2520 { return __builtin_log1pf(__x); } 2521 2522 constexpr long double 2523 log1p(long double __x) 2524 { return __builtin_log1pl(__x); } 2525 #endif 2526 2527 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2528 template<typename _Tp> 2529 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2530 double>::__type 2531 log1p(_Tp __x) 2532 { return __builtin_log1p(__x); } 2533 #endif 2534 2535 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2536 // DR 568. 2537 constexpr float 2538 log2(float __x) 2539 { return __builtin_log2f(__x); } 2540 2541 constexpr long double 2542 log2(long double __x) 2543 { return __builtin_log2l(__x); } 2544 #endif 2545 2546 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2547 template<typename _Tp> 2548 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2549 double>::__type 2550 log2(_Tp __x) 2551 { return __builtin_log2(__x); } 2552 #endif 2553 2554 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2555 constexpr float 2556 logb(float __x) 2557 { return __builtin_logbf(__x); } 2558 2559 constexpr long double 2560 logb(long double __x) 2561 { return __builtin_logbl(__x); } 2562 #endif 2563 2564 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2565 template<typename _Tp> 2566 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2567 double>::__type 2568 logb(_Tp __x) 2569 { return __builtin_logb(__x); } 2570 #endif 2571 2572 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2573 constexpr long 2574 lrint(float __x) 2575 { return __builtin_lrintf(__x); } 2576 2577 constexpr long 2578 lrint(long double __x) 2579 { return __builtin_lrintl(__x); } 2580 #endif 2581 2582 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2583 template<typename _Tp> 2584 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2585 long>::__type 2586 lrint(_Tp __x) 2587 { return __builtin_lrint(__x); } 2588 #endif 2589 2590 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2591 constexpr long 2592 lround(float __x) 2593 { return __builtin_lroundf(__x); } 2594 2595 constexpr long 2596 lround(long double __x) 2597 { return __builtin_lroundl(__x); } 2598 #endif 2599 2600 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2601 template<typename _Tp> 2602 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2603 long>::__type 2604 lround(_Tp __x) 2605 { return __builtin_lround(__x); } 2606 #endif 2607 2608 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2609 constexpr float 2610 nearbyint(float __x) 2611 { return __builtin_nearbyintf(__x); } 2612 2613 constexpr long double 2614 nearbyint(long double __x) 2615 { return __builtin_nearbyintl(__x); } 2616 #endif 2617 2618 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2619 template<typename _Tp> 2620 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2621 double>::__type 2622 nearbyint(_Tp __x) 2623 { return __builtin_nearbyint(__x); } 2624 #endif 2625 2626 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2627 constexpr float 2628 nextafter(float __x, float __y) 2629 { return __builtin_nextafterf(__x, __y); } 2630 2631 constexpr long double 2632 nextafter(long double __x, long double __y) 2633 { return __builtin_nextafterl(__x, __y); } 2634 #endif 2635 2636 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2637 constexpr float 2638 nexttoward(float __x, long double __y) 2639 { return __builtin_nexttowardf(__x, __y); } 2640 2641 constexpr long double 2642 nexttoward(long double __x, long double __y) 2643 { return __builtin_nexttowardl(__x, __y); } 2644 #endif 2645 2646 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2647 template<typename _Tp> 2648 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2649 double>::__type 2650 nexttoward(_Tp __x, long double __y) 2651 { return __builtin_nexttoward(__x, __y); } 2652 #endif 2653 2654 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2655 constexpr float 2656 remainder(float __x, float __y) 2657 { return __builtin_remainderf(__x, __y); } 2658 2659 constexpr long double 2660 remainder(long double __x, long double __y) 2661 { return __builtin_remainderl(__x, __y); } 2662 #endif 2663 2664 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2665 inline float 2666 remquo(float __x, float __y, int* __pquo) 2667 { return __builtin_remquof(__x, __y, __pquo); } 2668 2669 inline long double 2670 remquo(long double __x, long double __y, int* __pquo) 2671 { return __builtin_remquol(__x, __y, __pquo); } 2672 #endif 2673 2674 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2675 constexpr float 2676 rint(float __x) 2677 { return __builtin_rintf(__x); } 2678 2679 constexpr long double 2680 rint(long double __x) 2681 { return __builtin_rintl(__x); } 2682 #endif 2683 2684 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2685 template<typename _Tp> 2686 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2687 double>::__type 2688 rint(_Tp __x) 2689 { return __builtin_rint(__x); } 2690 #endif 2691 2692 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2693 constexpr float 2694 round(float __x) 2695 { return __builtin_roundf(__x); } 2696 2697 constexpr long double 2698 round(long double __x) 2699 { return __builtin_roundl(__x); } 2700 #endif 2701 2702 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2703 template<typename _Tp> 2704 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2705 double>::__type 2706 round(_Tp __x) 2707 { return __builtin_round(__x); } 2708 #endif 2709 2710 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2711 constexpr float 2712 scalbln(float __x, long __ex) 2713 { return __builtin_scalblnf(__x, __ex); } 2714 2715 constexpr long double 2716 scalbln(long double __x, long __ex) 2717 { return __builtin_scalblnl(__x, __ex); } 2718 #endif 2719 2720 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2721 template<typename _Tp> 2722 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2723 double>::__type 2724 scalbln(_Tp __x, long __ex) 2725 { return __builtin_scalbln(__x, __ex); } 2726 #endif 2727 2728 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2729 constexpr float 2730 scalbn(float __x, int __ex) 2731 { return __builtin_scalbnf(__x, __ex); } 2732 2733 constexpr long double 2734 scalbn(long double __x, int __ex) 2735 { return __builtin_scalbnl(__x, __ex); } 2736 #endif 2737 2738 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2739 template<typename _Tp> 2740 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2741 double>::__type 2742 scalbn(_Tp __x, int __ex) 2743 { return __builtin_scalbn(__x, __ex); } 2744 #endif 2745 2746 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2747 constexpr float 2748 tgamma(float __x) 2749 { return __builtin_tgammaf(__x); } 2750 2751 constexpr long double 2752 tgamma(long double __x) 2753 { return __builtin_tgammal(__x); } 2754 #endif 2755 2756 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2757 template<typename _Tp> 2758 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2759 double>::__type 2760 tgamma(_Tp __x) 2761 { return __builtin_tgamma(__x); } 2762 #endif 2763 2764 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP 2765 constexpr float 2766 trunc(float __x) 2767 { return __builtin_truncf(__x); } 2768 2769 constexpr long double 2770 trunc(long double __x) 2771 { return __builtin_truncl(__x); } 2772 #endif 2773 2774 #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT 2775 template<typename _Tp> 2776 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 2777 double>::__type 2778 trunc(_Tp __x) 2779 { return __builtin_trunc(__x); } 2780 #endif 2781 2782 #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) 2783 constexpr _Float16 2784 acosh(_Float16 __x) 2785 { return _Float16(__builtin_acoshf(__x)); } 2786 2787 constexpr _Float16 2788 asinh(_Float16 __x) 2789 { return _Float16(__builtin_asinhf(__x)); } 2790 2791 constexpr _Float16 2792 atanh(_Float16 __x) 2793 { return _Float16(__builtin_atanhf(__x)); } 2794 2795 constexpr _Float16 2796 cbrt(_Float16 __x) 2797 { return _Float16(__builtin_cbrtf(__x)); } 2798 2799 constexpr _Float16 2800 copysign(_Float16 __x, _Float16 __y) 2801 { return __builtin_copysignf16(__x, __y); } 2802 2803 constexpr _Float16 2804 erf(_Float16 __x) 2805 { return _Float16(__builtin_erff(__x)); } 2806 2807 constexpr _Float16 2808 erfc(_Float16 __x) 2809 { return _Float16(__builtin_erfcf(__x)); } 2810 2811 constexpr _Float16 2812 exp2(_Float16 __x) 2813 { return _Float16(__builtin_exp2f(__x)); } 2814 2815 constexpr _Float16 2816 expm1(_Float16 __x) 2817 { return _Float16(__builtin_expm1f(__x)); } 2818 2819 constexpr _Float16 2820 fdim(_Float16 __x, _Float16 __y) 2821 { return _Float16(__builtin_fdimf(__x, __y)); } 2822 2823 constexpr _Float16 2824 fma(_Float16 __x, _Float16 __y, _Float16 __z) 2825 { return _Float16(__builtin_fmaf(__x, __y, __z)); } 2826 2827 constexpr _Float16 2828 fmax(_Float16 __x, _Float16 __y) 2829 { return _Float16(__builtin_fmaxf(__x, __y)); } 2830 2831 constexpr _Float16 2832 fmin(_Float16 __x, _Float16 __y) 2833 { return _Float16(__builtin_fminf(__x, __y)); } 2834 2835 constexpr _Float16 2836 hypot(_Float16 __x, _Float16 __y) 2837 { return _Float16(__builtin_hypotf(__x, __y)); } 2838 2839 constexpr int 2840 ilogb(_Float16 __x) 2841 { return __builtin_ilogbf(__x); } 2842 2843 constexpr _Float16 2844 lgamma(_Float16 __x) 2845 { return _Float16(__builtin_lgammaf(__x)); } 2846 2847 constexpr long long 2848 llrint(_Float16 __x) 2849 { return __builtin_llrintf(__x); } 2850 2851 constexpr long long 2852 llround(_Float16 __x) 2853 { return __builtin_llroundf(__x); } 2854 2855 constexpr _Float16 2856 log1p(_Float16 __x) 2857 { return _Float16(__builtin_log1pf(__x)); } 2858 2859 // DR 568. 2860 constexpr _Float16 2861 log2(_Float16 __x) 2862 { return _Float16(__builtin_log2f(__x)); } 2863 2864 constexpr _Float16 2865 logb(_Float16 __x) 2866 { return _Float16(__builtin_logbf(__x)); } 2867 2868 constexpr long 2869 lrint(_Float16 __x) 2870 { return __builtin_lrintf(__x); } 2871 2872 constexpr long 2873 lround(_Float16 __x) 2874 { return __builtin_lroundf(__x); } 2875 2876 constexpr _Float16 2877 nearbyint(_Float16 __x) 2878 { return _Float16(__builtin_nearbyintf(__x)); } 2879 2880 constexpr _Float16 2881 nextafter(_Float16 __x, _Float16 __y) 2882 { 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); } 2888 #endif 2889 #ifdef __INT16_TYPE__ 2890 using __float16_int_type = __INT16_TYPE__; 2891 #else 2892 using __float16_int_type = short int; 2893 #endif 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 2900 return __x + __y; 2901 if (__x == __y) 2902 return __y; // x == y, return y 2903 if (__ix == 0) // x == 0 2904 { 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 2908 return __x; 2909 } 2910 if (__hx >= 0) // x > 0 2911 { 2912 if (__hx > __hy) // x > y, x -= ulp 2913 --__hx; 2914 else // x < y, x += ulp 2915 ++__hx; 2916 } 2917 else // x < 0 2918 { 2919 if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp 2920 --__hx; 2921 else // x > y, x += ulp 2922 ++__hx; 2923 } 2924 __hy = __hx & 0x7c00; 2925 if (__hy >= 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)); 2930 return __x; 2931 } 2932 2933 constexpr _Float16 2934 remainder(_Float16 __x, _Float16 __y) 2935 { return _Float16(__builtin_remainderf(__x, __y)); } 2936 2937 inline _Float16 2938 remquo(_Float16 __x, _Float16 __y, int* __pquo) 2939 { return _Float16(__builtin_remquof(__x, __y, __pquo)); } 2940 2941 constexpr _Float16 2942 rint(_Float16 __x) 2943 { return _Float16(__builtin_rintf(__x)); } 2944 2945 constexpr _Float16 2946 round(_Float16 __x) 2947 { return _Float16(__builtin_roundf(__x)); } 2948 2949 constexpr _Float16 2950 scalbln(_Float16 __x, long __ex) 2951 { return _Float16(__builtin_scalblnf(__x, __ex)); } 2952 2953 constexpr _Float16 2954 scalbn(_Float16 __x, int __ex) 2955 { return _Float16(__builtin_scalbnf(__x, __ex)); } 2956 2957 constexpr _Float16 2958 tgamma(_Float16 __x) 2959 { return _Float16(__builtin_tgammaf(__x)); } 2960 2961 constexpr _Float16 2962 trunc(_Float16 __x) 2963 { return _Float16(__builtin_truncf(__x)); } 2964 #endif 2965 2966 #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) 2967 constexpr _Float32 2968 acosh(_Float32 __x) 2969 { return __builtin_acoshf(__x); } 2970 2971 constexpr _Float32 2972 asinh(_Float32 __x) 2973 { return __builtin_asinhf(__x); } 2974 2975 constexpr _Float32 2976 atanh(_Float32 __x) 2977 { return __builtin_atanhf(__x); } 2978 2979 constexpr _Float32 2980 cbrt(_Float32 __x) 2981 { return __builtin_cbrtf(__x); } 2982 2983 constexpr _Float32 2984 copysign(_Float32 __x, _Float32 __y) 2985 { return __builtin_copysignf(__x, __y); } 2986 2987 constexpr _Float32 2988 erf(_Float32 __x) 2989 { return __builtin_erff(__x); } 2990 2991 constexpr _Float32 2992 erfc(_Float32 __x) 2993 { return __builtin_erfcf(__x); } 2994 2995 constexpr _Float32 2996 exp2(_Float32 __x) 2997 { return __builtin_exp2f(__x); } 2998 2999 constexpr _Float32 3000 expm1(_Float32 __x) 3001 { return __builtin_expm1f(__x); } 3002 3003 constexpr _Float32 3004 fdim(_Float32 __x, _Float32 __y) 3005 { return __builtin_fdimf(__x, __y); } 3006 3007 constexpr _Float32 3008 fma(_Float32 __x, _Float32 __y, _Float32 __z) 3009 { return __builtin_fmaf(__x, __y, __z); } 3010 3011 constexpr _Float32 3012 fmax(_Float32 __x, _Float32 __y) 3013 { return __builtin_fmaxf(__x, __y); } 3014 3015 constexpr _Float32 3016 fmin(_Float32 __x, _Float32 __y) 3017 { return __builtin_fminf(__x, __y); } 3018 3019 constexpr _Float32 3020 hypot(_Float32 __x, _Float32 __y) 3021 { return __builtin_hypotf(__x, __y); } 3022 3023 constexpr int 3024 ilogb(_Float32 __x) 3025 { return __builtin_ilogbf(__x); } 3026 3027 constexpr _Float32 3028 lgamma(_Float32 __x) 3029 { return __builtin_lgammaf(__x); } 3030 3031 constexpr long long 3032 llrint(_Float32 __x) 3033 { return __builtin_llrintf(__x); } 3034 3035 constexpr long long 3036 llround(_Float32 __x) 3037 { return __builtin_llroundf(__x); } 3038 3039 constexpr _Float32 3040 log1p(_Float32 __x) 3041 { return __builtin_log1pf(__x); } 3042 3043 // DR 568. 3044 constexpr _Float32 3045 log2(_Float32 __x) 3046 { return __builtin_log2f(__x); } 3047 3048 constexpr _Float32 3049 logb(_Float32 __x) 3050 { return __builtin_logbf(__x); } 3051 3052 constexpr long 3053 lrint(_Float32 __x) 3054 { return __builtin_lrintf(__x); } 3055 3056 constexpr long 3057 lround(_Float32 __x) 3058 { return __builtin_lroundf(__x); } 3059 3060 constexpr _Float32 3061 nearbyint(_Float32 __x) 3062 { return __builtin_nearbyintf(__x); } 3063 3064 constexpr _Float32 3065 nextafter(_Float32 __x, _Float32 __y) 3066 { return __builtin_nextafterf(__x, __y); } 3067 3068 constexpr _Float32 3069 remainder(_Float32 __x, _Float32 __y) 3070 { return __builtin_remainderf(__x, __y); } 3071 3072 inline _Float32 3073 remquo(_Float32 __x, _Float32 __y, int* __pquo) 3074 { return __builtin_remquof(__x, __y, __pquo); } 3075 3076 constexpr _Float32 3077 rint(_Float32 __x) 3078 { return __builtin_rintf(__x); } 3079 3080 constexpr _Float32 3081 round(_Float32 __x) 3082 { return __builtin_roundf(__x); } 3083 3084 constexpr _Float32 3085 scalbln(_Float32 __x, long __ex) 3086 { return __builtin_scalblnf(__x, __ex); } 3087 3088 constexpr _Float32 3089 scalbn(_Float32 __x, int __ex) 3090 { return __builtin_scalbnf(__x, __ex); } 3091 3092 constexpr _Float32 3093 tgamma(_Float32 __x) 3094 { return __builtin_tgammaf(__x); } 3095 3096 constexpr _Float32 3097 trunc(_Float32 __x) 3098 { return __builtin_truncf(__x); } 3099 #endif 3100 3101 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) 3102 constexpr _Float64 3103 acosh(_Float64 __x) 3104 { return __builtin_acosh(__x); } 3105 3106 constexpr _Float64 3107 asinh(_Float64 __x) 3108 { return __builtin_asinh(__x); } 3109 3110 constexpr _Float64 3111 atanh(_Float64 __x) 3112 { return __builtin_atanh(__x); } 3113 3114 constexpr _Float64 3115 cbrt(_Float64 __x) 3116 { return __builtin_cbrt(__x); } 3117 3118 constexpr _Float64 3119 copysign(_Float64 __x, _Float64 __y) 3120 { return __builtin_copysign(__x, __y); } 3121 3122 constexpr _Float64 3123 erf(_Float64 __x) 3124 { return __builtin_erf(__x); } 3125 3126 constexpr _Float64 3127 erfc(_Float64 __x) 3128 { return __builtin_erfc(__x); } 3129 3130 constexpr _Float64 3131 exp2(_Float64 __x) 3132 { return __builtin_exp2(__x); } 3133 3134 constexpr _Float64 3135 expm1(_Float64 __x) 3136 { return __builtin_expm1(__x); } 3137 3138 constexpr _Float64 3139 fdim(_Float64 __x, _Float64 __y) 3140 { return __builtin_fdim(__x, __y); } 3141 3142 constexpr _Float64 3143 fma(_Float64 __x, _Float64 __y, _Float64 __z) 3144 { return __builtin_fma(__x, __y, __z); } 3145 3146 constexpr _Float64 3147 fmax(_Float64 __x, _Float64 __y) 3148 { return __builtin_fmax(__x, __y); } 3149 3150 constexpr _Float64 3151 fmin(_Float64 __x, _Float64 __y) 3152 { return __builtin_fmin(__x, __y); } 3153 3154 constexpr _Float64 3155 hypot(_Float64 __x, _Float64 __y) 3156 { return __builtin_hypot(__x, __y); } 3157 3158 constexpr int 3159 ilogb(_Float64 __x) 3160 { return __builtin_ilogb(__x); } 3161 3162 constexpr _Float64 3163 lgamma(_Float64 __x) 3164 { return __builtin_lgamma(__x); } 3165 3166 constexpr long long 3167 llrint(_Float64 __x) 3168 { return __builtin_llrint(__x); } 3169 3170 constexpr long long 3171 llround(_Float64 __x) 3172 { return __builtin_llround(__x); } 3173 3174 constexpr _Float64 3175 log1p(_Float64 __x) 3176 { return __builtin_log1p(__x); } 3177 3178 // DR 568. 3179 constexpr _Float64 3180 log2(_Float64 __x) 3181 { return __builtin_log2(__x); } 3182 3183 constexpr _Float64 3184 logb(_Float64 __x) 3185 { return __builtin_logb(__x); } 3186 3187 constexpr long 3188 lrint(_Float64 __x) 3189 { return __builtin_lrint(__x); } 3190 3191 constexpr long 3192 lround(_Float64 __x) 3193 { return __builtin_lround(__x); } 3194 3195 constexpr _Float64 3196 nearbyint(_Float64 __x) 3197 { return __builtin_nearbyint(__x); } 3198 3199 constexpr _Float64 3200 nextafter(_Float64 __x, _Float64 __y) 3201 { return __builtin_nextafter(__x, __y); } 3202 3203 constexpr _Float64 3204 remainder(_Float64 __x, _Float64 __y) 3205 { return __builtin_remainder(__x, __y); } 3206 3207 inline _Float64 3208 remquo(_Float64 __x, _Float64 __y, int* __pquo) 3209 { return __builtin_remquo(__x, __y, __pquo); } 3210 3211 constexpr _Float64 3212 rint(_Float64 __x) 3213 { return __builtin_rint(__x); } 3214 3215 constexpr _Float64 3216 round(_Float64 __x) 3217 { return __builtin_round(__x); } 3218 3219 constexpr _Float64 3220 scalbln(_Float64 __x, long __ex) 3221 { return __builtin_scalbln(__x, __ex); } 3222 3223 constexpr _Float64 3224 scalbn(_Float64 __x, int __ex) 3225 { return __builtin_scalbn(__x, __ex); } 3226 3227 constexpr _Float64 3228 tgamma(_Float64 __x) 3229 { return __builtin_tgamma(__x); } 3230 3231 constexpr _Float64 3232 trunc(_Float64 __x) 3233 { return __builtin_trunc(__x); } 3234 #endif 3235 3236 #if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) 3237 constexpr _Float128 3238 acosh(_Float128 __x) 3239 { return __builtin_acoshl(__x); } 3240 3241 constexpr _Float128 3242 asinh(_Float128 __x) 3243 { return __builtin_asinhl(__x); } 3244 3245 constexpr _Float128 3246 atanh(_Float128 __x) 3247 { return __builtin_atanhl(__x); } 3248 3249 constexpr _Float128 3250 cbrt(_Float128 __x) 3251 { return __builtin_cbrtl(__x); } 3252 3253 constexpr _Float128 3254 copysign(_Float128 __x, _Float128 __y) 3255 { return __builtin_copysignl(__x, __y); } 3256 3257 constexpr _Float128 3258 erf(_Float128 __x) 3259 { return __builtin_erfl(__x); } 3260 3261 constexpr _Float128 3262 erfc(_Float128 __x) 3263 { return __builtin_erfcl(__x); } 3264 3265 constexpr _Float128 3266 exp2(_Float128 __x) 3267 { return __builtin_exp2l(__x); } 3268 3269 constexpr _Float128 3270 expm1(_Float128 __x) 3271 { return __builtin_expm1l(__x); } 3272 3273 constexpr _Float128 3274 fdim(_Float128 __x, _Float128 __y) 3275 { return __builtin_fdiml(__x, __y); } 3276 3277 constexpr _Float128 3278 fma(_Float128 __x, _Float128 __y, _Float128 __z) 3279 { return __builtin_fmal(__x, __y, __z); } 3280 3281 constexpr _Float128 3282 fmax(_Float128 __x, _Float128 __y) 3283 { return __builtin_fmaxl(__x, __y); } 3284 3285 constexpr _Float128 3286 fmin(_Float128 __x, _Float128 __y) 3287 { return __builtin_fminl(__x, __y); } 3288 3289 constexpr _Float128 3290 hypot(_Float128 __x, _Float128 __y) 3291 { return __builtin_hypotl(__x, __y); } 3292 3293 constexpr int 3294 ilogb(_Float128 __x) 3295 { return __builtin_ilogbl(__x); } 3296 3297 constexpr _Float128 3298 lgamma(_Float128 __x) 3299 { return __builtin_lgammal(__x); } 3300 3301 constexpr long long 3302 llrint(_Float128 __x) 3303 { return __builtin_llrintl(__x); } 3304 3305 constexpr long long 3306 llround(_Float128 __x) 3307 { return __builtin_llroundl(__x); } 3308 3309 constexpr _Float128 3310 log1p(_Float128 __x) 3311 { return __builtin_log1pl(__x); } 3312 3313 // DR 568. 3314 constexpr _Float128 3315 log2(_Float128 __x) 3316 { return __builtin_log2l(__x); } 3317 3318 constexpr _Float128 3319 logb(_Float128 __x) 3320 { return __builtin_logbl(__x); } 3321 3322 constexpr long 3323 lrint(_Float128 __x) 3324 { return __builtin_lrintl(__x); } 3325 3326 constexpr long 3327 lround(_Float128 __x) 3328 { return __builtin_lroundl(__x); } 3329 3330 constexpr _Float128 3331 nearbyint(_Float128 __x) 3332 { return __builtin_nearbyintl(__x); } 3333 3334 constexpr _Float128 3335 nextafter(_Float128 __x, _Float128 __y) 3336 { return __builtin_nextafterl(__x, __y); } 3337 3338 constexpr _Float128 3339 remainder(_Float128 __x, _Float128 __y) 3340 { return __builtin_remainderl(__x, __y); } 3341 3342 inline _Float128 3343 remquo(_Float128 __x, _Float128 __y, int* __pquo) 3344 { return __builtin_remquol(__x, __y, __pquo); } 3345 3346 constexpr _Float128 3347 rint(_Float128 __x) 3348 { return __builtin_rintl(__x); } 3349 3350 constexpr _Float128 3351 round(_Float128 __x) 3352 { return __builtin_roundl(__x); } 3353 3354 constexpr _Float128 3355 scalbln(_Float128 __x, long __ex) 3356 { return __builtin_scalblnl(__x, __ex); } 3357 3358 constexpr _Float128 3359 scalbn(_Float128 __x, int __ex) 3360 { return __builtin_scalbnl(__x, __ex); } 3361 3362 constexpr _Float128 3363 tgamma(_Float128 __x) 3364 { return __builtin_tgammal(__x); } 3365 3366 constexpr _Float128 3367 trunc(_Float128 __x) 3368 { return __builtin_truncl(__x); } 3369 #elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH) 3370 constexpr _Float128 3371 acosh(_Float128 __x) 3372 { return __builtin_acoshf128(__x); } 3373 3374 constexpr _Float128 3375 asinh(_Float128 __x) 3376 { return __builtin_asinhf128(__x); } 3377 3378 constexpr _Float128 3379 atanh(_Float128 __x) 3380 { return __builtin_atanhf128(__x); } 3381 3382 constexpr _Float128 3383 cbrt(_Float128 __x) 3384 { return __builtin_cbrtf128(__x); } 3385 3386 constexpr _Float128 3387 copysign(_Float128 __x, _Float128 __y) 3388 { return __builtin_copysignf128(__x, __y); } 3389 3390 constexpr _Float128 3391 erf(_Float128 __x) 3392 { return __builtin_erff128(__x); } 3393 3394 constexpr _Float128 3395 erfc(_Float128 __x) 3396 { return __builtin_erfcf128(__x); } 3397 3398 constexpr _Float128 3399 exp2(_Float128 __x) 3400 { return __builtin_exp2f128(__x); } 3401 3402 constexpr _Float128 3403 expm1(_Float128 __x) 3404 { return __builtin_expm1f128(__x); } 3405 3406 constexpr _Float128 3407 fdim(_Float128 __x, _Float128 __y) 3408 { return __builtin_fdimf128(__x, __y); } 3409 3410 constexpr _Float128 3411 fma(_Float128 __x, _Float128 __y, _Float128 __z) 3412 { return __builtin_fmaf128(__x, __y, __z); } 3413 3414 constexpr _Float128 3415 fmax(_Float128 __x, _Float128 __y) 3416 { return __builtin_fmaxf128(__x, __y); } 3417 3418 constexpr _Float128 3419 fmin(_Float128 __x, _Float128 __y) 3420 { return __builtin_fminf128(__x, __y); } 3421 3422 constexpr _Float128 3423 hypot(_Float128 __x, _Float128 __y) 3424 { return __builtin_hypotf128(__x, __y); } 3425 3426 constexpr int 3427 ilogb(_Float128 __x) 3428 { return __builtin_ilogbf128(__x); } 3429 3430 constexpr _Float128 3431 lgamma(_Float128 __x) 3432 { return __builtin_lgammaf128(__x); } 3433 3434 constexpr long long 3435 llrint(_Float128 __x) 3436 { return __builtin_llrintf128(__x); } 3437 3438 constexpr long long 3439 llround(_Float128 __x) 3440 { return __builtin_llroundf128(__x); } 3441 3442 constexpr _Float128 3443 log1p(_Float128 __x) 3444 { return __builtin_log1pf128(__x); } 3445 3446 // DR 568. 3447 constexpr _Float128 3448 log2(_Float128 __x) 3449 { return __builtin_log2f128(__x); } 3450 3451 constexpr _Float128 3452 logb(_Float128 __x) 3453 { return __builtin_logbf128(__x); } 3454 3455 constexpr long 3456 lrint(_Float128 __x) 3457 { return __builtin_lrintf128(__x); } 3458 3459 constexpr long 3460 lround(_Float128 __x) 3461 { return __builtin_lroundf128(__x); } 3462 3463 constexpr _Float128 3464 nearbyint(_Float128 __x) 3465 { return __builtin_nearbyintf128(__x); } 3466 3467 constexpr _Float128 3468 nextafter(_Float128 __x, _Float128 __y) 3469 { return __builtin_nextafterf128(__x, __y); } 3470 3471 constexpr _Float128 3472 remainder(_Float128 __x, _Float128 __y) 3473 { return __builtin_remainderf128(__x, __y); } 3474 3475 inline _Float128 3476 remquo(_Float128 __x, _Float128 __y, int* __pquo) 3477 { return __builtin_remquof128(__x, __y, __pquo); } 3478 3479 constexpr _Float128 3480 rint(_Float128 __x) 3481 { return __builtin_rintf128(__x); } 3482 3483 constexpr _Float128 3484 round(_Float128 __x) 3485 { return __builtin_roundf128(__x); } 3486 3487 constexpr _Float128 3488 scalbln(_Float128 __x, long __ex) 3489 { return __builtin_scalblnf128(__x, __ex); } 3490 3491 constexpr _Float128 3492 scalbn(_Float128 __x, int __ex) 3493 { return __builtin_scalbnf128(__x, __ex); } 3494 3495 constexpr _Float128 3496 tgamma(_Float128 __x) 3497 { return __builtin_tgammaf128(__x); } 3498 3499 constexpr _Float128 3500 trunc(_Float128 __x) 3501 { return __builtin_truncf128(__x); } 3502 #endif 3503 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)); } 3508 3509 constexpr __gnu_cxx::__bfloat16_t 3510 asinh(__gnu_cxx::__bfloat16_t __x) 3511 { return __gnu_cxx::__bfloat16_t(__builtin_asinhf(__x)); } 3512 3513 constexpr __gnu_cxx::__bfloat16_t 3514 atanh(__gnu_cxx::__bfloat16_t __x) 3515 { return __gnu_cxx::__bfloat16_t(__builtin_atanhf(__x)); } 3516 3517 constexpr __gnu_cxx::__bfloat16_t 3518 cbrt(__gnu_cxx::__bfloat16_t __x) 3519 { return __gnu_cxx::__bfloat16_t(__builtin_cbrtf(__x)); } 3520 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)); } 3524 3525 constexpr __gnu_cxx::__bfloat16_t 3526 erf(__gnu_cxx::__bfloat16_t __x) 3527 { return __gnu_cxx::__bfloat16_t(__builtin_erff(__x)); } 3528 3529 constexpr __gnu_cxx::__bfloat16_t 3530 erfc(__gnu_cxx::__bfloat16_t __x) 3531 { return __gnu_cxx::__bfloat16_t(__builtin_erfcf(__x)); } 3532 3533 constexpr __gnu_cxx::__bfloat16_t 3534 exp2(__gnu_cxx::__bfloat16_t __x) 3535 { return __gnu_cxx::__bfloat16_t(__builtin_exp2f(__x)); } 3536 3537 constexpr __gnu_cxx::__bfloat16_t 3538 expm1(__gnu_cxx::__bfloat16_t __x) 3539 { return __gnu_cxx::__bfloat16_t(__builtin_expm1f(__x)); } 3540 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)); } 3544 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)); } 3548 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)); } 3552 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)); } 3556 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)); } 3560 3561 constexpr int 3562 ilogb(__gnu_cxx::__bfloat16_t __x) 3563 { return __builtin_ilogbf(__x); } 3564 3565 constexpr __gnu_cxx::__bfloat16_t 3566 lgamma(__gnu_cxx::__bfloat16_t __x) 3567 { return __gnu_cxx::__bfloat16_t(__builtin_lgammaf(__x)); } 3568 3569 constexpr long long 3570 llrint(__gnu_cxx::__bfloat16_t __x) 3571 { return __builtin_llrintf(__x); } 3572 3573 constexpr long long 3574 llround(__gnu_cxx::__bfloat16_t __x) 3575 { return __builtin_llroundf(__x); } 3576 3577 constexpr __gnu_cxx::__bfloat16_t 3578 log1p(__gnu_cxx::__bfloat16_t __x) 3579 { return __gnu_cxx::__bfloat16_t(__builtin_log1pf(__x)); } 3580 3581 // DR 568. 3582 constexpr __gnu_cxx::__bfloat16_t 3583 log2(__gnu_cxx::__bfloat16_t __x) 3584 { return __gnu_cxx::__bfloat16_t(__builtin_log2f(__x)); } 3585 3586 constexpr __gnu_cxx::__bfloat16_t 3587 logb(__gnu_cxx::__bfloat16_t __x) 3588 { return __gnu_cxx::__bfloat16_t(__builtin_logbf(__x)); } 3589 3590 constexpr long 3591 lrint(__gnu_cxx::__bfloat16_t __x) 3592 { return __builtin_lrintf(__x); } 3593 3594 constexpr long 3595 lround(__gnu_cxx::__bfloat16_t __x) 3596 { return __builtin_lroundf(__x); } 3597 3598 constexpr __gnu_cxx::__bfloat16_t 3599 nearbyint(__gnu_cxx::__bfloat16_t __x) 3600 { return __gnu_cxx::__bfloat16_t(__builtin_nearbyintf(__x)); } 3601 3602 constexpr __gnu_cxx::__bfloat16_t 3603 nextafter(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y) 3604 { 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); } 3610 #endif 3611 #ifdef __INT16_TYPE__ 3612 using __bfloat16_int_type = __INT16_TYPE__; 3613 #else 3614 using __bfloat16_int_type = short int; 3615 #endif 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 3622 return __x + __y; 3623 if (__x == __y) 3624 return __y; // x == y, return y 3625 if (__ix == 0) // x == 0 3626 { 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 3630 return __x; 3631 } 3632 if (__hx >= 0) // x > 0 3633 { 3634 if (__hx > __hy) // x > y, x -= ulp 3635 --__hx; 3636 else // x < y, x += ulp 3637 ++__hx; 3638 } 3639 else // x < 0 3640 { 3641 if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp 3642 --__hx; 3643 else // x > y, x += ulp 3644 ++__hx; 3645 } 3646 __hy = __hx & 0x7f80; 3647 if (__hy >= 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)); 3652 return __x; 3653 } 3654 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)); } 3658 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)); } 3662 3663 constexpr __gnu_cxx::__bfloat16_t 3664 rint(__gnu_cxx::__bfloat16_t __x) 3665 { return __gnu_cxx::__bfloat16_t(__builtin_rintf(__x)); } 3666 3667 constexpr __gnu_cxx::__bfloat16_t 3668 round(__gnu_cxx::__bfloat16_t __x) 3669 { return __gnu_cxx::__bfloat16_t(__builtin_roundf(__x)); } 3670 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)); } 3674 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)); } 3678 3679 constexpr __gnu_cxx::__bfloat16_t 3680 tgamma(__gnu_cxx::__bfloat16_t __x) 3681 { return __gnu_cxx::__bfloat16_t(__builtin_tgammaf(__x)); } 3682 3683 constexpr __gnu_cxx::__bfloat16_t 3684 trunc(__gnu_cxx::__bfloat16_t __x) 3685 { return __gnu_cxx::__bfloat16_t(__builtin_truncf(__x)); } 3686 #endif 3687 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) 3692 { 3693 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 3694 return copysign(__type(__x), __type(__y)); 3695 } 3696 3697 template<typename _Tp, typename _Up> 3698 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 3699 fdim(_Tp __x, _Up __y) 3700 { 3701 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 3702 return fdim(__type(__x), __type(__y)); 3703 } 3704 3705 template<typename _Tp, typename _Up> 3706 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 3707 fmax(_Tp __x, _Up __y) 3708 { 3709 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 3710 return fmax(__type(__x), __type(__y)); 3711 } 3712 3713 template<typename _Tp, typename _Up> 3714 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 3715 fmin(_Tp __x, _Up __y) 3716 { 3717 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 3718 return fmin(__type(__x), __type(__y)); 3719 } 3720 3721 template<typename _Tp, typename _Up> 3722 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 3723 hypot(_Tp __x, _Up __y) 3724 { 3725 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 3726 return hypot(__type(__x), __type(__y)); 3727 } 3728 3729 template<typename _Tp, typename _Up> 3730 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 3731 nextafter(_Tp __x, _Up __y) 3732 { 3733 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 3734 return nextafter(__type(__x), __type(__y)); 3735 } 3736 3737 template<typename _Tp, typename _Up> 3738 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 3739 remainder(_Tp __x, _Up __y) 3740 { 3741 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 3742 return remainder(__type(__x), __type(__y)); 3743 } 3744 3745 template<typename _Tp, typename _Up> 3746 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 3747 remquo(_Tp __x, _Up __y, int* __pquo) 3748 { 3749 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 3750 return remquo(__type(__x), __type(__y), __pquo); 3751 } 3752 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) 3756 { 3757 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; 3758 return fma(__type(__x), __type(__y), __type(__z)); 3759 } 3760 #endif 3761 3762 #endif // _GLIBCXX_USE_C99_MATH_FUNCS 3763 #endif // C++11 3764 3765 #ifdef __cpp_lib_hypot // C++ >= 17 && HOSTED 3766 // [c.math.hypot3], three-dimensional hypotenuse 3767 template<typename _Tp> 3768 inline _Tp 3769 __hypot3(_Tp __x, _Tp __y, _Tp __z) 3770 { 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)); 3778 else 3779 return {}; 3780 } 3781 3782 inline float 3783 hypot(float __x, float __y, float __z) 3784 { return std::__hypot3<float>(__x, __y, __z); } 3785 3786 inline double 3787 hypot(double __x, double __y, double __z) 3788 { return std::__hypot3<double>(__x, __y, __z); } 3789 3790 inline long double 3791 hypot(long double __x, long double __y, long double __z) 3792 { return std::__hypot3<long double>(__x, __y, __z); } 3793 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) 3797 { 3798 using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type; 3799 return std::__hypot3<__type>(__x, __y, __z); 3800 } 3801 3802 #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) 3803 inline _Float16 3804 hypot(_Float16 __x, _Float16 __y, _Float16 __z) 3805 { return std::__hypot3<_Float16>(__x, __y, __z); } 3806 #endif 3807 3808 #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) 3809 inline _Float32 3810 hypot(_Float32 __x, _Float32 __y, _Float32 __z) 3811 { return std::__hypot3<_Float32>(__x, __y, __z); } 3812 #endif 3813 3814 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) 3815 inline _Float64 3816 hypot(_Float64 __x, _Float64 __y, _Float64 __z) 3817 { return std::__hypot3<_Float64>(__x, __y, __z); } 3818 #endif 3819 3820 #if defined(__STDCPP_FLOAT128_T__) \ 3821 && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ 3822 || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) 3823 inline _Float128 3824 hypot(_Float128 __x, _Float128 __y, _Float128 __z) 3825 { return std::__hypot3<_Float128>(__x, __y, __z); } 3826 #endif 3827 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); } 3832 #endif 3833 3834 #endif // __cpp_lib_hypot 3835 3836 #ifdef __cpp_lib_interpolate // C++ >= 20 3837 // linear interpolation 3838 template<typename _Fp> 3839 constexpr _Fp 3840 __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept 3841 { 3842 if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0)) 3843 return __t * __b + (1 - __t) * __a; 3844 3845 if (__t == 1) 3846 return __b; // exact 3847 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 3854 } 3855 3856 constexpr float 3857 lerp(float __a, float __b, float __t) noexcept 3858 { return std::__lerp(__a, __b, __t); } 3859 3860 constexpr double 3861 lerp(double __a, double __b, double __t) noexcept 3862 { return std::__lerp(__a, __b, __t); } 3863 3864 constexpr long double 3865 lerp(long double __a, long double __b, long double __t) noexcept 3866 { return std::__lerp(__a, __b, __t); } 3867 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 3871 { 3872 using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>; 3873 return std::__lerp<__type>(__x, __y, __z); 3874 } 3875 3876 #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) 3877 inline _Float16 3878 lerp(_Float16 __x, _Float16 __y, _Float16 __z) noexcept 3879 { return std::__lerp<_Float16>(__x, __y, __z); } 3880 #endif 3881 3882 #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32) 3883 inline _Float32 3884 lerp(_Float32 __x, _Float32 __y, _Float32 __z) noexcept 3885 { return std::__lerp<_Float32>(__x, __y, __z); } 3886 #endif 3887 3888 #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64) 3889 inline _Float64 3890 lerp(_Float64 __x, _Float64 __y, _Float64 __z) noexcept 3891 { return std::__lerp<_Float64>(__x, __y, __z); } 3892 #endif 3893 3894 #if defined(__STDCPP_FLOAT128_T__) \ 3895 && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \ 3896 || defined(_GLIBCXX_HAVE_FLOAT128_MATH)) 3897 inline _Float128 3898 lerp(_Float128 __x, _Float128 __y, _Float128 __z) noexcept 3899 { return std::__lerp<_Float128>(__x, __y, __z); } 3900 #endif 3901 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); } 3906 #endif 3907 #endif // __cpp_lib_interpolate 3908 3909 _GLIBCXX_END_NAMESPACE_VERSION 3910 } // namespace 3911 3912 #if _GLIBCXX_USE_STD_SPEC_FUNCS 3913 # include <bits/specfun.h> 3914 #endif 3915 3916 } // extern "C++" 3917 3918 #endif