1 // -*- C++ -*- C forwarding header. 2 3 // Copyright (C) 1997-2013 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 #pragma GCC system_header 40 41 #include <bits/c++config.h> 42 #include <bits/cpp_type_traits.h> 43 #include <ext/type_traits.h> 44 #include <math.h> 45 46 #ifndef _GLIBCXX_CMATH 47 #define _GLIBCXX_CMATH 1 48 49 // Get rid of those macros defined in <math.h> in lieu of real functions. 50 #undef abs 51 #undef div 52 #undef acos 53 #undef asin 54 #undef atan 55 #undef atan2 56 #undef ceil 57 #undef cos 58 #undef cosh 59 #undef exp 60 #undef fabs 61 #undef floor 62 #undef fmod 63 #undef frexp 64 #undef ldexp 65 #undef log 66 #undef log10 67 #undef modf 68 #undef pow 69 #undef sin 70 #undef sinh 71 #undef sqrt 72 #undef tan 73 #undef tanh 74 75 namespace std _GLIBCXX_VISIBILITY(default) 76 { 77 _GLIBCXX_BEGIN_NAMESPACE_VERSION 78 79 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 80 inline _GLIBCXX_CONSTEXPR double 81 abs(double __x) 82 { return __builtin_fabs(__x); } 83 #endif 84 85 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 86 inline _GLIBCXX_CONSTEXPR float 87 abs(float __x) 88 { return __builtin_fabsf(__x); } 89 90 inline _GLIBCXX_CONSTEXPR long double 91 abs(long double __x) 92 { return __builtin_fabsl(__x); } 93 #endif 94 95 template<typename _Tp> 96 inline _GLIBCXX_CONSTEXPR 97 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 98 double>::__type 99 abs(_Tp __x) 100 { return __builtin_fabs(__x); } 101 102 using ::acos; 103 104 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 105 inline _GLIBCXX_CONSTEXPR float 106 acos(float __x) 107 { return __builtin_acosf(__x); } 108 109 inline _GLIBCXX_CONSTEXPR long double 110 acos(long double __x) 111 { return __builtin_acosl(__x); } 112 #endif 113 114 template<typename _Tp> 115 inline _GLIBCXX_CONSTEXPR 116 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 117 double>::__type 118 acos(_Tp __x) 119 { return __builtin_acos(__x); } 120 121 using ::asin; 122 123 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 124 inline _GLIBCXX_CONSTEXPR float 125 asin(float __x) 126 { return __builtin_asinf(__x); } 127 128 inline _GLIBCXX_CONSTEXPR long double 129 asin(long double __x) 130 { return __builtin_asinl(__x); } 131 #endif 132 133 template<typename _Tp> 134 inline _GLIBCXX_CONSTEXPR 135 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 136 double>::__type 137 asin(_Tp __x) 138 { return __builtin_asin(__x); } 139 140 using ::atan; 141 142 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 143 inline _GLIBCXX_CONSTEXPR float 144 atan(float __x) 145 { return __builtin_atanf(__x); } 146 147 inline _GLIBCXX_CONSTEXPR long double 148 atan(long double __x) 149 { return __builtin_atanl(__x); } 150 #endif 151 152 template<typename _Tp> 153 inline _GLIBCXX_CONSTEXPR 154 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 155 double>::__type 156 atan(_Tp __x) 157 { return __builtin_atan(__x); } 158 159 using ::atan2; 160 161 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 162 inline _GLIBCXX_CONSTEXPR float 163 atan2(float __y, float __x) 164 { return __builtin_atan2f(__y, __x); } 165 166 inline _GLIBCXX_CONSTEXPR long double 167 atan2(long double __y, long double __x) 168 { return __builtin_atan2l(__y, __x); } 169 #endif 170 171 template<typename _Tp, typename _Up> 172 inline _GLIBCXX_CONSTEXPR 173 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 174 atan2(_Tp __y, _Up __x) 175 { 176 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 177 return atan2(__type(__y), __type(__x)); 178 } 179 180 using ::ceil; 181 182 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 183 inline _GLIBCXX_CONSTEXPR float 184 ceil(float __x) 185 { return __builtin_ceilf(__x); } 186 187 inline _GLIBCXX_CONSTEXPR long double 188 ceil(long double __x) 189 { return __builtin_ceill(__x); } 190 #endif 191 192 template<typename _Tp> 193 inline _GLIBCXX_CONSTEXPR 194 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 195 double>::__type 196 ceil(_Tp __x) 197 { return __builtin_ceil(__x); } 198 199 using ::cos; 200 201 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 202 inline _GLIBCXX_CONSTEXPR float 203 cos(float __x) 204 { return __builtin_cosf(__x); } 205 206 inline _GLIBCXX_CONSTEXPR long double 207 cos(long double __x) 208 { return __builtin_cosl(__x); } 209 #endif 210 211 template<typename _Tp> 212 inline _GLIBCXX_CONSTEXPR 213 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 214 double>::__type 215 cos(_Tp __x) 216 { return __builtin_cos(__x); } 217 218 using ::cosh; 219 220 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 221 inline _GLIBCXX_CONSTEXPR float 222 cosh(float __x) 223 { return __builtin_coshf(__x); } 224 225 inline _GLIBCXX_CONSTEXPR long double 226 cosh(long double __x) 227 { return __builtin_coshl(__x); } 228 #endif 229 230 template<typename _Tp> 231 inline _GLIBCXX_CONSTEXPR 232 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 233 double>::__type 234 cosh(_Tp __x) 235 { return __builtin_cosh(__x); } 236 237 using ::exp; 238 239 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 240 inline _GLIBCXX_CONSTEXPR float 241 exp(float __x) 242 { return __builtin_expf(__x); } 243 244 inline _GLIBCXX_CONSTEXPR long double 245 exp(long double __x) 246 { return __builtin_expl(__x); } 247 #endif 248 249 template<typename _Tp> 250 inline _GLIBCXX_CONSTEXPR 251 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 252 double>::__type 253 exp(_Tp __x) 254 { return __builtin_exp(__x); } 255 256 using ::fabs; 257 258 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 259 inline _GLIBCXX_CONSTEXPR float 260 fabs(float __x) 261 { return __builtin_fabsf(__x); } 262 263 inline _GLIBCXX_CONSTEXPR long double 264 fabs(long double __x) 265 { return __builtin_fabsl(__x); } 266 #endif 267 268 template<typename _Tp> 269 inline _GLIBCXX_CONSTEXPR 270 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 271 double>::__type 272 fabs(_Tp __x) 273 { return __builtin_fabs(__x); } 274 275 using ::floor; 276 277 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 278 inline _GLIBCXX_CONSTEXPR float 279 floor(float __x) 280 { return __builtin_floorf(__x); } 281 282 inline _GLIBCXX_CONSTEXPR long double 283 floor(long double __x) 284 { return __builtin_floorl(__x); } 285 #endif 286 287 template<typename _Tp> 288 inline _GLIBCXX_CONSTEXPR 289 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 290 double>::__type 291 floor(_Tp __x) 292 { return __builtin_floor(__x); } 293 294 using ::fmod; 295 296 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 297 inline _GLIBCXX_CONSTEXPR float 298 fmod(float __x, float __y) 299 { return __builtin_fmodf(__x, __y); } 300 301 inline _GLIBCXX_CONSTEXPR long double 302 fmod(long double __x, long double __y) 303 { return __builtin_fmodl(__x, __y); } 304 #endif 305 306 template<typename _Tp, typename _Up> 307 inline _GLIBCXX_CONSTEXPR 308 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 309 fmod(_Tp __x, _Up __y) 310 { 311 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 312 return fmod(__type(__x), __type(__y)); 313 } 314 315 using ::frexp; 316 317 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 318 inline float 319 frexp(float __x, int* __exp) 320 { return __builtin_frexpf(__x, __exp); } 321 322 inline long double 323 frexp(long double __x, int* __exp) 324 { return __builtin_frexpl(__x, __exp); } 325 #endif 326 327 template<typename _Tp> 328 inline _GLIBCXX_CONSTEXPR 329 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 330 double>::__type 331 frexp(_Tp __x, int* __exp) 332 { return __builtin_frexp(__x, __exp); } 333 334 using ::ldexp; 335 336 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 337 inline _GLIBCXX_CONSTEXPR float 338 ldexp(float __x, int __exp) 339 { return __builtin_ldexpf(__x, __exp); } 340 341 inline _GLIBCXX_CONSTEXPR long double 342 ldexp(long double __x, int __exp) 343 { return __builtin_ldexpl(__x, __exp); } 344 #endif 345 346 template<typename _Tp> 347 inline _GLIBCXX_CONSTEXPR 348 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 349 double>::__type 350 ldexp(_Tp __x, int __exp) 351 { return __builtin_ldexp(__x, __exp); } 352 353 using ::log; 354 355 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 356 inline _GLIBCXX_CONSTEXPR float 357 log(float __x) 358 { return __builtin_logf(__x); } 359 360 inline _GLIBCXX_CONSTEXPR long double 361 log(long double __x) 362 { return __builtin_logl(__x); } 363 #endif 364 365 template<typename _Tp> 366 inline _GLIBCXX_CONSTEXPR 367 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 368 double>::__type 369 log(_Tp __x) 370 { return __builtin_log(__x); } 371 372 using ::log10; 373 374 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 375 inline _GLIBCXX_CONSTEXPR float 376 log10(float __x) 377 { return __builtin_log10f(__x); } 378 379 inline _GLIBCXX_CONSTEXPR long double 380 log10(long double __x) 381 { return __builtin_log10l(__x); } 382 #endif 383 384 template<typename _Tp> 385 inline _GLIBCXX_CONSTEXPR 386 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 387 double>::__type 388 log10(_Tp __x) 389 { return __builtin_log10(__x); } 390 391 using ::modf; 392 393 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 394 inline float 395 modf(float __x, float* __iptr) 396 { return __builtin_modff(__x, __iptr); } 397 398 inline long double 399 modf(long double __x, long double* __iptr) 400 { return __builtin_modfl(__x, __iptr); } 401 #endif 402 403 using ::pow; 404 405 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 406 inline _GLIBCXX_CONSTEXPR float 407 pow(float __x, float __y) 408 { return __builtin_powf(__x, __y); } 409 410 inline _GLIBCXX_CONSTEXPR long double 411 pow(long double __x, long double __y) 412 { return __builtin_powl(__x, __y); } 413 414 #if __cplusplus < 201103L 415 // _GLIBCXX_RESOLVE_LIB_DEFECTS 416 // DR 550. What should the return type of pow(float,int) be? 417 inline double 418 pow(double __x, int __i) 419 { return __builtin_powi(__x, __i); } 420 421 inline float 422 pow(float __x, int __n) 423 { return __builtin_powif(__x, __n); } 424 425 inline long double 426 pow(long double __x, int __n) 427 { return __builtin_powil(__x, __n); } 428 #endif 429 #endif 430 431 template<typename _Tp, typename _Up> 432 inline _GLIBCXX_CONSTEXPR 433 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 434 pow(_Tp __x, _Up __y) 435 { 436 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 437 return pow(__type(__x), __type(__y)); 438 } 439 440 using ::sin; 441 442 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 443 inline _GLIBCXX_CONSTEXPR float 444 sin(float __x) 445 { return __builtin_sinf(__x); } 446 447 inline _GLIBCXX_CONSTEXPR long double 448 sin(long double __x) 449 { return __builtin_sinl(__x); } 450 #endif 451 452 template<typename _Tp> 453 inline _GLIBCXX_CONSTEXPR 454 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 455 double>::__type 456 sin(_Tp __x) 457 { return __builtin_sin(__x); } 458 459 using ::sinh; 460 461 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 462 inline _GLIBCXX_CONSTEXPR float 463 sinh(float __x) 464 { return __builtin_sinhf(__x); } 465 466 inline _GLIBCXX_CONSTEXPR long double 467 sinh(long double __x) 468 { return __builtin_sinhl(__x); } 469 #endif 470 471 template<typename _Tp> 472 inline _GLIBCXX_CONSTEXPR 473 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 474 double>::__type 475 sinh(_Tp __x) 476 { return __builtin_sinh(__x); } 477 478 using ::sqrt; 479 480 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 481 inline _GLIBCXX_CONSTEXPR float 482 sqrt(float __x) 483 { return __builtin_sqrtf(__x); } 484 485 inline _GLIBCXX_CONSTEXPR long double 486 sqrt(long double __x) 487 { return __builtin_sqrtl(__x); } 488 #endif 489 490 template<typename _Tp> 491 inline _GLIBCXX_CONSTEXPR 492 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 493 double>::__type 494 sqrt(_Tp __x) 495 { return __builtin_sqrt(__x); } 496 497 using ::tan; 498 499 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 500 inline _GLIBCXX_CONSTEXPR float 501 tan(float __x) 502 { return __builtin_tanf(__x); } 503 504 inline _GLIBCXX_CONSTEXPR long double 505 tan(long double __x) 506 { return __builtin_tanl(__x); } 507 #endif 508 509 template<typename _Tp> 510 inline _GLIBCXX_CONSTEXPR 511 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 512 double>::__type 513 tan(_Tp __x) 514 { return __builtin_tan(__x); } 515 516 using ::tanh; 517 518 #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO 519 inline _GLIBCXX_CONSTEXPR float 520 tanh(float __x) 521 { return __builtin_tanhf(__x); } 522 523 inline _GLIBCXX_CONSTEXPR long double 524 tanh(long double __x) 525 { return __builtin_tanhl(__x); } 526 #endif 527 528 template<typename _Tp> 529 inline _GLIBCXX_CONSTEXPR 530 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 531 double>::__type 532 tanh(_Tp __x) 533 { return __builtin_tanh(__x); } 534 535 _GLIBCXX_END_NAMESPACE_VERSION 536 } // namespace 537 538 #if _GLIBCXX_USE_C99_MATH 539 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC 540 541 // These are possible macros imported from C99-land. 542 #undef fpclassify 543 #undef isfinite 544 #undef isinf 545 #undef isnan 546 #undef isnormal 547 #undef signbit 548 #undef isgreater 549 #undef isgreaterequal 550 #undef isless 551 #undef islessequal 552 #undef islessgreater 553 #undef isunordered 554 555 namespace std _GLIBCXX_VISIBILITY(default) 556 { 557 _GLIBCXX_BEGIN_NAMESPACE_VERSION 558 559 #if __cplusplus >= 201103L 560 constexpr int 561 fpclassify(float __x) 562 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 563 FP_SUBNORMAL, FP_ZERO, __x); } 564 565 constexpr int 566 fpclassify(double __x) 567 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 568 FP_SUBNORMAL, FP_ZERO, __x); } 569 570 constexpr int 571 fpclassify(long double __x) 572 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 573 FP_SUBNORMAL, FP_ZERO, __x); } 574 575 template<typename _Tp> 576 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 577 int>::__type 578 fpclassify(_Tp __x) 579 { return __x != 0 ? FP_NORMAL : FP_ZERO; } 580 581 constexpr bool 582 isfinite(float __x) 583 { return __builtin_isfinite(__x); } 584 585 constexpr bool 586 isfinite(double __x) 587 { return __builtin_isfinite(__x); } 588 589 constexpr bool 590 isfinite(long double __x) 591 { return __builtin_isfinite(__x); } 592 593 template<typename _Tp> 594 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 595 bool>::__type 596 isfinite(_Tp __x) 597 { return true; } 598 599 constexpr bool 600 isinf(float __x) 601 { return __builtin_isinf(__x); } 602 603 constexpr bool 604 isinf(double __x) 605 { return __builtin_isinf(__x); } 606 607 constexpr bool 608 isinf(long double __x) 609 { return __builtin_isinf(__x); } 610 611 template<typename _Tp> 612 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 613 bool>::__type 614 isinf(_Tp __x) 615 { return false; } 616 617 constexpr bool 618 isnan(float __x) 619 { return __builtin_isnan(__x); } 620 621 constexpr bool 622 isnan(double __x) 623 { return __builtin_isnan(__x); } 624 625 constexpr bool 626 isnan(long double __x) 627 { return __builtin_isnan(__x); } 628 629 template<typename _Tp> 630 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 631 bool>::__type 632 isnan(_Tp __x) 633 { return false; } 634 635 constexpr bool 636 isnormal(float __x) 637 { return __builtin_isnormal(__x); } 638 639 constexpr bool 640 isnormal(double __x) 641 { return __builtin_isnormal(__x); } 642 643 constexpr bool 644 isnormal(long double __x) 645 { return __builtin_isnormal(__x); } 646 647 template<typename _Tp> 648 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 649 bool>::__type 650 isnormal(_Tp __x) 651 { return __x != 0 ? true : false; } 652 653 constexpr bool 654 signbit(float __x) 655 { return __builtin_signbit(__x); } 656 657 constexpr bool 658 signbit(double __x) 659 { return __builtin_signbit(__x); } 660 661 constexpr bool 662 signbit(long double __x) 663 { return __builtin_signbit(__x); } 664 665 template<typename _Tp> 666 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 667 bool>::__type 668 signbit(_Tp __x) 669 { return __x < 0 ? true : false; } 670 671 constexpr bool 672 isgreater(float __x, float __y) 673 { return __builtin_isgreater(__x, __y); } 674 675 constexpr bool 676 isgreater(double __x, double __y) 677 { return __builtin_isgreater(__x, __y); } 678 679 constexpr bool 680 isgreater(long double __x, long double __y) 681 { return __builtin_isgreater(__x, __y); } 682 683 template<typename _Tp, typename _Up> 684 constexpr typename 685 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 686 && __is_arithmetic<_Up>::__value), bool>::__type 687 isgreater(_Tp __x, _Up __y) 688 { 689 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 690 return __builtin_isgreater(__type(__x), __type(__y)); 691 } 692 693 constexpr bool 694 isgreaterequal(float __x, float __y) 695 { return __builtin_isgreaterequal(__x, __y); } 696 697 constexpr bool 698 isgreaterequal(double __x, double __y) 699 { return __builtin_isgreaterequal(__x, __y); } 700 701 constexpr bool 702 isgreaterequal(long double __x, long double __y) 703 { return __builtin_isgreaterequal(__x, __y); } 704 705 template<typename _Tp, typename _Up> 706 constexpr typename 707 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 708 && __is_arithmetic<_Up>::__value), bool>::__type 709 isgreaterequal(_Tp __x, _Up __y) 710 { 711 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 712 return __builtin_isgreaterequal(__type(__x), __type(__y)); 713 } 714 715 constexpr bool 716 isless(float __x, float __y) 717 { return __builtin_isless(__x, __y); } 718 719 constexpr bool 720 isless(double __x, double __y) 721 { return __builtin_isless(__x, __y); } 722 723 constexpr bool 724 isless(long double __x, long double __y) 725 { return __builtin_isless(__x, __y); } 726 727 template<typename _Tp, typename _Up> 728 constexpr typename 729 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 730 && __is_arithmetic<_Up>::__value), bool>::__type 731 isless(_Tp __x, _Up __y) 732 { 733 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 734 return __builtin_isless(__type(__x), __type(__y)); 735 } 736 737 constexpr bool 738 islessequal(float __x, float __y) 739 { return __builtin_islessequal(__x, __y); } 740 741 constexpr bool 742 islessequal(double __x, double __y) 743 { return __builtin_islessequal(__x, __y); } 744 745 constexpr bool 746 islessequal(long double __x, long double __y) 747 { return __builtin_islessequal(__x, __y); } 748 749 template<typename _Tp, typename _Up> 750 constexpr typename 751 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 752 && __is_arithmetic<_Up>::__value), bool>::__type 753 islessequal(_Tp __x, _Up __y) 754 { 755 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 756 return __builtin_islessequal(__type(__x), __type(__y)); 757 } 758 759 constexpr bool 760 islessgreater(float __x, float __y) 761 { return __builtin_islessgreater(__x, __y); } 762 763 constexpr bool 764 islessgreater(double __x, double __y) 765 { return __builtin_islessgreater(__x, __y); } 766 767 constexpr bool 768 islessgreater(long double __x, long double __y) 769 { return __builtin_islessgreater(__x, __y); } 770 771 template<typename _Tp, typename _Up> 772 constexpr typename 773 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 774 && __is_arithmetic<_Up>::__value), bool>::__type 775 islessgreater(_Tp __x, _Up __y) 776 { 777 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 778 return __builtin_islessgreater(__type(__x), __type(__y)); 779 } 780 781 constexpr bool 782 isunordered(float __x, float __y) 783 { return __builtin_isunordered(__x, __y); } 784 785 constexpr bool 786 isunordered(double __x, double __y) 787 { return __builtin_isunordered(__x, __y); } 788 789 constexpr bool 790 isunordered(long double __x, long double __y) 791 { return __builtin_isunordered(__x, __y); } 792 793 template<typename _Tp, typename _Up> 794 constexpr typename 795 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value 796 && __is_arithmetic<_Up>::__value), bool>::__type 797 isunordered(_Tp __x, _Up __y) 798 { 799 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 800 return __builtin_isunordered(__type(__x), __type(__y)); 801 } 802 803 #else 804 805 template<typename _Tp> 806 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 807 int>::__type 808 fpclassify(_Tp __f) 809 { 810 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 811 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, 812 FP_SUBNORMAL, FP_ZERO, __type(__f)); 813 } 814 815 template<typename _Tp> 816 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 817 int>::__type 818 isfinite(_Tp __f) 819 { 820 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 821 return __builtin_isfinite(__type(__f)); 822 } 823 824 template<typename _Tp> 825 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 826 int>::__type 827 isinf(_Tp __f) 828 { 829 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 830 return __builtin_isinf(__type(__f)); 831 } 832 833 template<typename _Tp> 834 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 835 int>::__type 836 isnan(_Tp __f) 837 { 838 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 839 return __builtin_isnan(__type(__f)); 840 } 841 842 template<typename _Tp> 843 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 844 int>::__type 845 isnormal(_Tp __f) 846 { 847 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 848 return __builtin_isnormal(__type(__f)); 849 } 850 851 template<typename _Tp> 852 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 853 int>::__type 854 signbit(_Tp __f) 855 { 856 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 857 return __builtin_signbit(__type(__f)); 858 } 859 860 template<typename _Tp> 861 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 862 int>::__type 863 isgreater(_Tp __f1, _Tp __f2) 864 { 865 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 866 return __builtin_isgreater(__type(__f1), __type(__f2)); 867 } 868 869 template<typename _Tp> 870 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 871 int>::__type 872 isgreaterequal(_Tp __f1, _Tp __f2) 873 { 874 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 875 return __builtin_isgreaterequal(__type(__f1), __type(__f2)); 876 } 877 878 template<typename _Tp> 879 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 880 int>::__type 881 isless(_Tp __f1, _Tp __f2) 882 { 883 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 884 return __builtin_isless(__type(__f1), __type(__f2)); 885 } 886 887 template<typename _Tp> 888 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 889 int>::__type 890 islessequal(_Tp __f1, _Tp __f2) 891 { 892 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 893 return __builtin_islessequal(__type(__f1), __type(__f2)); 894 } 895 896 template<typename _Tp> 897 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 898 int>::__type 899 islessgreater(_Tp __f1, _Tp __f2) 900 { 901 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 902 return __builtin_islessgreater(__type(__f1), __type(__f2)); 903 } 904 905 template<typename _Tp> 906 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value, 907 int>::__type 908 isunordered(_Tp __f1, _Tp __f2) 909 { 910 typedef typename __gnu_cxx::__promote<_Tp>::__type __type; 911 return __builtin_isunordered(__type(__f1), __type(__f2)); 912 } 913 914 #endif 915 916 _GLIBCXX_END_NAMESPACE_VERSION 917 } // namespace 918 919 #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */ 920 #endif 921 922 #if __cplusplus >= 201103L 923 924 #ifdef _GLIBCXX_USE_C99_MATH_TR1 925 926 #undef acosh 927 #undef acoshf 928 #undef acoshl 929 #undef asinh 930 #undef asinhf 931 #undef asinhl 932 #undef atanh 933 #undef atanhf 934 #undef atanhl 935 #undef cbrt 936 #undef cbrtf 937 #undef cbrtl 938 #undef copysign 939 #undef copysignf 940 #undef copysignl 941 #undef erf 942 #undef erff 943 #undef erfl 944 #undef erfc 945 #undef erfcf 946 #undef erfcl 947 #undef exp2 948 #undef exp2f 949 #undef exp2l 950 #undef expm1 951 #undef expm1f 952 #undef expm1l 953 #undef fdim 954 #undef fdimf 955 #undef fdiml 956 #undef fma 957 #undef fmaf 958 #undef fmal 959 #undef fmax 960 #undef fmaxf 961 #undef fmaxl 962 #undef fmin 963 #undef fminf 964 #undef fminl 965 #undef hypot 966 #undef hypotf 967 #undef hypotl 968 #undef ilogb 969 #undef ilogbf 970 #undef ilogbl 971 #undef lgamma 972 #undef lgammaf 973 #undef lgammal 974 #undef llrint 975 #undef llrintf 976 #undef llrintl 977 #undef llround 978 #undef llroundf 979 #undef llroundl 980 #undef log1p 981 #undef log1pf 982 #undef log1pl 983 #undef log2 984 #undef log2f 985 #undef log2l 986 #undef logb 987 #undef logbf 988 #undef logbl 989 #undef lrint 990 #undef lrintf 991 #undef lrintl 992 #undef lround 993 #undef lroundf 994 #undef lroundl 995 #undef nan 996 #undef nanf 997 #undef nanl 998 #undef nearbyint 999 #undef nearbyintf 1000 #undef nearbyintl 1001 #undef nextafter 1002 #undef nextafterf 1003 #undef nextafterl 1004 #undef nexttoward 1005 #undef nexttowardf 1006 #undef nexttowardl 1007 #undef remainder 1008 #undef remainderf 1009 #undef remainderl 1010 #undef remquo 1011 #undef remquof 1012 #undef remquol 1013 #undef rint 1014 #undef rintf 1015 #undef rintl 1016 #undef round 1017 #undef roundf 1018 #undef roundl 1019 #undef scalbln 1020 #undef scalblnf 1021 #undef scalblnl 1022 #undef scalbn 1023 #undef scalbnf 1024 #undef scalbnl 1025 #undef tgamma 1026 #undef tgammaf 1027 #undef tgammal 1028 #undef trunc 1029 #undef truncf 1030 #undef truncl 1031 1032 namespace std _GLIBCXX_VISIBILITY(default) 1033 { 1034 _GLIBCXX_BEGIN_NAMESPACE_VERSION 1035 1036 // types 1037 using ::double_t; 1038 using ::float_t; 1039 1040 // functions 1041 using ::acosh; 1042 using ::acoshf; 1043 using ::acoshl; 1044 1045 using ::asinh; 1046 using ::asinhf; 1047 using ::asinhl; 1048 1049 using ::atanh; 1050 using ::atanhf; 1051 using ::atanhl; 1052 1053 using ::cbrt; 1054 using ::cbrtf; 1055 using ::cbrtl; 1056 1057 using ::copysign; 1058 using ::copysignf; 1059 using ::copysignl; 1060 1061 using ::erf; 1062 using ::erff; 1063 using ::erfl; 1064 1065 using ::erfc; 1066 using ::erfcf; 1067 using ::erfcl; 1068 1069 using ::exp2; 1070 using ::exp2f; 1071 using ::exp2l; 1072 1073 using ::expm1; 1074 using ::expm1f; 1075 using ::expm1l; 1076 1077 using ::fdim; 1078 using ::fdimf; 1079 using ::fdiml; 1080 1081 using ::fma; 1082 using ::fmaf; 1083 using ::fmal; 1084 1085 using ::fmax; 1086 using ::fmaxf; 1087 using ::fmaxl; 1088 1089 using ::fmin; 1090 using ::fminf; 1091 using ::fminl; 1092 1093 using ::hypot; 1094 using ::hypotf; 1095 using ::hypotl; 1096 1097 using ::ilogb; 1098 using ::ilogbf; 1099 using ::ilogbl; 1100 1101 using ::lgamma; 1102 using ::lgammaf; 1103 using ::lgammal; 1104 1105 using ::llrint; 1106 using ::llrintf; 1107 using ::llrintl; 1108 1109 using ::llround; 1110 using ::llroundf; 1111 using ::llroundl; 1112 1113 using ::log1p; 1114 using ::log1pf; 1115 using ::log1pl; 1116 1117 using ::log2; 1118 using ::log2f; 1119 using ::log2l; 1120 1121 using ::logb; 1122 using ::logbf; 1123 using ::logbl; 1124 1125 using ::lrint; 1126 using ::lrintf; 1127 using ::lrintl; 1128 1129 using ::lround; 1130 using ::lroundf; 1131 using ::lroundl; 1132 1133 using ::nan; 1134 using ::nanf; 1135 using ::nanl; 1136 1137 using ::nearbyint; 1138 using ::nearbyintf; 1139 using ::nearbyintl; 1140 1141 using ::nextafter; 1142 using ::nextafterf; 1143 using ::nextafterl; 1144 1145 using ::nexttoward; 1146 using ::nexttowardf; 1147 using ::nexttowardl; 1148 1149 using ::remainder; 1150 using ::remainderf; 1151 using ::remainderl; 1152 1153 using ::remquo; 1154 using ::remquof; 1155 using ::remquol; 1156 1157 using ::rint; 1158 using ::rintf; 1159 using ::rintl; 1160 1161 using ::round; 1162 using ::roundf; 1163 using ::roundl; 1164 1165 using ::scalbln; 1166 using ::scalblnf; 1167 using ::scalblnl; 1168 1169 using ::scalbn; 1170 using ::scalbnf; 1171 using ::scalbnl; 1172 1173 using ::tgamma; 1174 using ::tgammaf; 1175 using ::tgammal; 1176 1177 using ::trunc; 1178 using ::truncf; 1179 using ::truncl; 1180 1181 /// Additional overloads. 1182 constexpr float 1183 acosh(float __x) 1184 { return __builtin_acoshf(__x); } 1185 1186 constexpr long double 1187 acosh(long double __x) 1188 { return __builtin_acoshl(__x); } 1189 1190 template<typename _Tp> 1191 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1192 double>::__type 1193 acosh(_Tp __x) 1194 { return __builtin_acosh(__x); } 1195 1196 constexpr float 1197 asinh(float __x) 1198 { return __builtin_asinhf(__x); } 1199 1200 constexpr long double 1201 asinh(long double __x) 1202 { return __builtin_asinhl(__x); } 1203 1204 template<typename _Tp> 1205 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1206 double>::__type 1207 asinh(_Tp __x) 1208 { return __builtin_asinh(__x); } 1209 1210 constexpr float 1211 atanh(float __x) 1212 { return __builtin_atanhf(__x); } 1213 1214 constexpr long double 1215 atanh(long double __x) 1216 { return __builtin_atanhl(__x); } 1217 1218 template<typename _Tp> 1219 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1220 double>::__type 1221 atanh(_Tp __x) 1222 { return __builtin_atanh(__x); } 1223 1224 constexpr float 1225 cbrt(float __x) 1226 { return __builtin_cbrtf(__x); } 1227 1228 constexpr long double 1229 cbrt(long double __x) 1230 { return __builtin_cbrtl(__x); } 1231 1232 template<typename _Tp> 1233 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1234 double>::__type 1235 cbrt(_Tp __x) 1236 { return __builtin_cbrt(__x); } 1237 1238 constexpr float 1239 copysign(float __x, float __y) 1240 { return __builtin_copysignf(__x, __y); } 1241 1242 constexpr long double 1243 copysign(long double __x, long double __y) 1244 { return __builtin_copysignl(__x, __y); } 1245 1246 template<typename _Tp, typename _Up> 1247 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 1248 copysign(_Tp __x, _Up __y) 1249 { 1250 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1251 return copysign(__type(__x), __type(__y)); 1252 } 1253 1254 constexpr float 1255 erf(float __x) 1256 { return __builtin_erff(__x); } 1257 1258 constexpr long double 1259 erf(long double __x) 1260 { return __builtin_erfl(__x); } 1261 1262 template<typename _Tp> 1263 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1264 double>::__type 1265 erf(_Tp __x) 1266 { return __builtin_erf(__x); } 1267 1268 constexpr float 1269 erfc(float __x) 1270 { return __builtin_erfcf(__x); } 1271 1272 constexpr long double 1273 erfc(long double __x) 1274 { return __builtin_erfcl(__x); } 1275 1276 template<typename _Tp> 1277 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1278 double>::__type 1279 erfc(_Tp __x) 1280 { return __builtin_erfc(__x); } 1281 1282 constexpr float 1283 exp2(float __x) 1284 { return __builtin_exp2f(__x); } 1285 1286 constexpr long double 1287 exp2(long double __x) 1288 { return __builtin_exp2l(__x); } 1289 1290 template<typename _Tp> 1291 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1292 double>::__type 1293 exp2(_Tp __x) 1294 { return __builtin_exp2(__x); } 1295 1296 constexpr float 1297 expm1(float __x) 1298 { return __builtin_expm1f(__x); } 1299 1300 constexpr long double 1301 expm1(long double __x) 1302 { return __builtin_expm1l(__x); } 1303 1304 template<typename _Tp> 1305 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1306 double>::__type 1307 expm1(_Tp __x) 1308 { return __builtin_expm1(__x); } 1309 1310 constexpr float 1311 fdim(float __x, float __y) 1312 { return __builtin_fdimf(__x, __y); } 1313 1314 constexpr long double 1315 fdim(long double __x, long double __y) 1316 { return __builtin_fdiml(__x, __y); } 1317 1318 template<typename _Tp, typename _Up> 1319 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 1320 fdim(_Tp __x, _Up __y) 1321 { 1322 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1323 return fdim(__type(__x), __type(__y)); 1324 } 1325 1326 constexpr float 1327 fma(float __x, float __y, float __z) 1328 { return __builtin_fmaf(__x, __y, __z); } 1329 1330 constexpr long double 1331 fma(long double __x, long double __y, long double __z) 1332 { return __builtin_fmal(__x, __y, __z); } 1333 1334 template<typename _Tp, typename _Up, typename _Vp> 1335 constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type 1336 fma(_Tp __x, _Up __y, _Vp __z) 1337 { 1338 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type; 1339 return fma(__type(__x), __type(__y), __type(__z)); 1340 } 1341 1342 constexpr float 1343 fmax(float __x, float __y) 1344 { return __builtin_fmaxf(__x, __y); } 1345 1346 constexpr long double 1347 fmax(long double __x, long double __y) 1348 { return __builtin_fmaxl(__x, __y); } 1349 1350 template<typename _Tp, typename _Up> 1351 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 1352 fmax(_Tp __x, _Up __y) 1353 { 1354 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1355 return fmax(__type(__x), __type(__y)); 1356 } 1357 1358 constexpr float 1359 fmin(float __x, float __y) 1360 { return __builtin_fminf(__x, __y); } 1361 1362 constexpr long double 1363 fmin(long double __x, long double __y) 1364 { return __builtin_fminl(__x, __y); } 1365 1366 template<typename _Tp, typename _Up> 1367 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 1368 fmin(_Tp __x, _Up __y) 1369 { 1370 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1371 return fmin(__type(__x), __type(__y)); 1372 } 1373 1374 constexpr float 1375 hypot(float __x, float __y) 1376 { return __builtin_hypotf(__x, __y); } 1377 1378 constexpr long double 1379 hypot(long double __x, long double __y) 1380 { return __builtin_hypotl(__x, __y); } 1381 1382 template<typename _Tp, typename _Up> 1383 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 1384 hypot(_Tp __x, _Up __y) 1385 { 1386 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1387 return hypot(__type(__x), __type(__y)); 1388 } 1389 1390 constexpr int 1391 ilogb(float __x) 1392 { return __builtin_ilogbf(__x); } 1393 1394 constexpr int 1395 ilogb(long double __x) 1396 { return __builtin_ilogbl(__x); } 1397 1398 template<typename _Tp> 1399 constexpr 1400 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1401 int>::__type 1402 ilogb(_Tp __x) 1403 { return __builtin_ilogb(__x); } 1404 1405 constexpr float 1406 lgamma(float __x) 1407 { return __builtin_lgammaf(__x); } 1408 1409 constexpr long double 1410 lgamma(long double __x) 1411 { return __builtin_lgammal(__x); } 1412 1413 template<typename _Tp> 1414 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1415 double>::__type 1416 lgamma(_Tp __x) 1417 { return __builtin_lgamma(__x); } 1418 1419 constexpr long long 1420 llrint(float __x) 1421 { return __builtin_llrintf(__x); } 1422 1423 constexpr long long 1424 llrint(long double __x) 1425 { return __builtin_llrintl(__x); } 1426 1427 template<typename _Tp> 1428 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1429 long long>::__type 1430 llrint(_Tp __x) 1431 { return __builtin_llrint(__x); } 1432 1433 constexpr long long 1434 llround(float __x) 1435 { return __builtin_llroundf(__x); } 1436 1437 constexpr long long 1438 llround(long double __x) 1439 { return __builtin_llroundl(__x); } 1440 1441 template<typename _Tp> 1442 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1443 long long>::__type 1444 llround(_Tp __x) 1445 { return __builtin_llround(__x); } 1446 1447 constexpr float 1448 log1p(float __x) 1449 { return __builtin_log1pf(__x); } 1450 1451 constexpr long double 1452 log1p(long double __x) 1453 { return __builtin_log1pl(__x); } 1454 1455 template<typename _Tp> 1456 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1457 double>::__type 1458 log1p(_Tp __x) 1459 { return __builtin_log1p(__x); } 1460 1461 // DR 568. 1462 constexpr float 1463 log2(float __x) 1464 { return __builtin_log2f(__x); } 1465 1466 constexpr long double 1467 log2(long double __x) 1468 { return __builtin_log2l(__x); } 1469 1470 template<typename _Tp> 1471 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1472 double>::__type 1473 log2(_Tp __x) 1474 { return __builtin_log2(__x); } 1475 1476 constexpr float 1477 logb(float __x) 1478 { return __builtin_logbf(__x); } 1479 1480 constexpr long double 1481 logb(long double __x) 1482 { return __builtin_logbl(__x); } 1483 1484 template<typename _Tp> 1485 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1486 double>::__type 1487 logb(_Tp __x) 1488 { return __builtin_logb(__x); } 1489 1490 constexpr long 1491 lrint(float __x) 1492 { return __builtin_lrintf(__x); } 1493 1494 constexpr long 1495 lrint(long double __x) 1496 { return __builtin_lrintl(__x); } 1497 1498 template<typename _Tp> 1499 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1500 long>::__type 1501 lrint(_Tp __x) 1502 { return __builtin_lrint(__x); } 1503 1504 constexpr long 1505 lround(float __x) 1506 { return __builtin_lroundf(__x); } 1507 1508 constexpr long 1509 lround(long double __x) 1510 { return __builtin_lroundl(__x); } 1511 1512 template<typename _Tp> 1513 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1514 long>::__type 1515 lround(_Tp __x) 1516 { return __builtin_lround(__x); } 1517 1518 constexpr float 1519 nearbyint(float __x) 1520 { return __builtin_nearbyintf(__x); } 1521 1522 constexpr long double 1523 nearbyint(long double __x) 1524 { return __builtin_nearbyintl(__x); } 1525 1526 template<typename _Tp> 1527 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1528 double>::__type 1529 nearbyint(_Tp __x) 1530 { return __builtin_nearbyint(__x); } 1531 1532 constexpr float 1533 nextafter(float __x, float __y) 1534 { return __builtin_nextafterf(__x, __y); } 1535 1536 constexpr long double 1537 nextafter(long double __x, long double __y) 1538 { return __builtin_nextafterl(__x, __y); } 1539 1540 template<typename _Tp, typename _Up> 1541 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 1542 nextafter(_Tp __x, _Up __y) 1543 { 1544 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1545 return nextafter(__type(__x), __type(__y)); 1546 } 1547 1548 constexpr float 1549 nexttoward(float __x, long double __y) 1550 { return __builtin_nexttowardf(__x, __y); } 1551 1552 constexpr long double 1553 nexttoward(long double __x, long double __y) 1554 { return __builtin_nexttowardl(__x, __y); } 1555 1556 template<typename _Tp> 1557 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1558 double>::__type 1559 nexttoward(_Tp __x, long double __y) 1560 { return __builtin_nexttoward(__x, __y); } 1561 1562 constexpr float 1563 remainder(float __x, float __y) 1564 { return __builtin_remainderf(__x, __y); } 1565 1566 constexpr long double 1567 remainder(long double __x, long double __y) 1568 { return __builtin_remainderl(__x, __y); } 1569 1570 template<typename _Tp, typename _Up> 1571 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 1572 remainder(_Tp __x, _Up __y) 1573 { 1574 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1575 return remainder(__type(__x), __type(__y)); 1576 } 1577 1578 inline float 1579 remquo(float __x, float __y, int* __pquo) 1580 { return __builtin_remquof(__x, __y, __pquo); } 1581 1582 inline long double 1583 remquo(long double __x, long double __y, int* __pquo) 1584 { return __builtin_remquol(__x, __y, __pquo); } 1585 1586 template<typename _Tp, typename _Up> 1587 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type 1588 remquo(_Tp __x, _Up __y, int* __pquo) 1589 { 1590 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; 1591 return remquo(__type(__x), __type(__y), __pquo); 1592 } 1593 1594 constexpr float 1595 rint(float __x) 1596 { return __builtin_rintf(__x); } 1597 1598 constexpr long double 1599 rint(long double __x) 1600 { return __builtin_rintl(__x); } 1601 1602 template<typename _Tp> 1603 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1604 double>::__type 1605 rint(_Tp __x) 1606 { return __builtin_rint(__x); } 1607 1608 constexpr float 1609 round(float __x) 1610 { return __builtin_roundf(__x); } 1611 1612 constexpr long double 1613 round(long double __x) 1614 { return __builtin_roundl(__x); } 1615 1616 template<typename _Tp> 1617 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1618 double>::__type 1619 round(_Tp __x) 1620 { return __builtin_round(__x); } 1621 1622 constexpr float 1623 scalbln(float __x, long __ex) 1624 { return __builtin_scalblnf(__x, __ex); } 1625 1626 constexpr long double 1627 scalbln(long double __x, long __ex) 1628 { return __builtin_scalblnl(__x, __ex); } 1629 1630 template<typename _Tp> 1631 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1632 double>::__type 1633 scalbln(_Tp __x, long __ex) 1634 { return __builtin_scalbln(__x, __ex); } 1635 1636 constexpr float 1637 scalbn(float __x, int __ex) 1638 { return __builtin_scalbnf(__x, __ex); } 1639 1640 constexpr long double 1641 scalbn(long double __x, int __ex) 1642 { return __builtin_scalbnl(__x, __ex); } 1643 1644 template<typename _Tp> 1645 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1646 double>::__type 1647 scalbn(_Tp __x, int __ex) 1648 { return __builtin_scalbn(__x, __ex); } 1649 1650 constexpr float 1651 tgamma(float __x) 1652 { return __builtin_tgammaf(__x); } 1653 1654 constexpr long double 1655 tgamma(long double __x) 1656 { return __builtin_tgammal(__x); } 1657 1658 template<typename _Tp> 1659 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1660 double>::__type 1661 tgamma(_Tp __x) 1662 { return __builtin_tgamma(__x); } 1663 1664 constexpr float 1665 trunc(float __x) 1666 { return __builtin_truncf(__x); } 1667 1668 constexpr long double 1669 trunc(long double __x) 1670 { return __builtin_truncl(__x); } 1671 1672 template<typename _Tp> 1673 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, 1674 double>::__type 1675 trunc(_Tp __x) 1676 { return __builtin_trunc(__x); } 1677 1678 _GLIBCXX_END_NAMESPACE_VERSION 1679 } // namespace 1680 1681 #endif // _GLIBCXX_USE_C99_MATH_TR1 1682 1683 #endif // C++11 1684 1685 #endif 1686