00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef _CPP_CMATH
00045 #define _CPP_CMATH 1
00046
00047 #pragma GCC system_header
00048
00049 #include <bits/c++config.h>
00050
00051 #include <math.h>
00052
00053
00054 #undef abs
00055 #undef div
00056 #undef acos
00057 #undef asin
00058 #undef atan
00059 #undef atan2
00060 #undef ceil
00061 #undef cos
00062 #undef cosh
00063 #undef exp
00064 #undef fabs
00065 #undef floor
00066 #undef fmod
00067 #undef frexp
00068 #undef ldexp
00069 #undef log
00070 #undef log10
00071 #undef modf
00072 #undef pow
00073 #undef sin
00074 #undef sinh
00075 #undef sqrt
00076 #undef tan
00077 #undef tanh
00078
00079
00080 namespace __gnu_cxx
00081 {
00082 namespace __c99_binding
00083 {
00084 #if _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_CHECK || \
00085 _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
00086 extern "C" float (acosf)(float);
00087 extern "C" float (asinf)(float);
00088 extern "C" float (atanf)(float);
00089 extern "C" float (atan2f)(float, float);
00090 extern "C" float (ceilf)(float);
00091 extern "C" float (coshf)(float);
00092 extern "C" float (expf)(float);
00093 extern "C" float (floorf)(float);
00094 extern "C" float (fmodf)(float, float);
00095 extern "C" float (frexpf)(float, int*);
00096 extern "C" float (ldexpf)(float, int);
00097 extern "C" float (logf)(float);
00098 extern "C" float (log10f)(float);
00099 extern "C" float (modff)(float, float*);
00100 extern "C" float (powf)(float, float);
00101 extern "C" float (sinhf)(float);
00102 extern "C" float (tanf)(float);
00103 extern "C" float (tanhf)(float);
00104 #endif
00105 #if !_GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
00106 #if _GLIBCPP_HAVE_ACOSF
00107 using ::acosf;
00108 #endif
00109 #if _GLIBCPP_HAVE_ASINF
00110 using ::asinf;
00111 #endif
00112 #if _GLIBCPP_HAVE_ATANF
00113 using ::atanf;
00114 #endif
00115 #if _GLIBCPP_HAVE_ATAN2F
00116 using ::atan2f;
00117 #endif
00118 #if _GLIBCPP_HAVE_CEILF
00119 using ::ceilf;
00120 #endif
00121 #if _GLIBCPP_HAVE_COSHF
00122 using ::coshf;
00123 #endif
00124 #if _GLIBCPP_HAVE_EXPF
00125 using ::expf;
00126 #endif
00127 #if _GLIBCPP_HAVE_FLOORF
00128 using ::floorf;
00129 #endif
00130 #if _GLIBCPP_HAVE_FMODF
00131 using ::fmodf;
00132 #endif
00133 #if _GLIBCPP_HAVE_FREXPF
00134 using ::frexpf;
00135 #endif
00136 #if _GLIBCPP_HAVE_LDEXPF
00137 using ::ldexpf;
00138 #endif
00139 #if _GLIBCPP_HAVE_LOGF
00140 using ::logf;
00141 #endif
00142 #if _GLIBCPP_HAVE_LOG10F
00143 using ::log10f;
00144 #endif
00145 #if _GLIBCPP_HAVE_MODFF
00146 using ::modff;
00147 #endif
00148 #if _GLIBCPP_HAVE_POWF
00149 using ::powf;
00150 #endif
00151 #if _GLIBCPP_HAVE_SINHF
00152 using ::sinhf;
00153 #endif
00154 #if _GLIBCPP_HAVE_TANF
00155 using ::tanf;
00156 #endif
00157 #if _GLIBCPP_HAVE_TANHF
00158 using ::tanhf;
00159 #endif
00160 #endif
00161 }
00162 }
00163
00164 namespace std
00165 {
00166
00167
00168 template<typename _Tp> _Tp __cmath_power(_Tp, unsigned int);
00169
00170 inline double
00171 abs(double __x)
00172 { return __builtin_fabs(__x); }
00173
00174 inline float
00175 abs(float __x)
00176 { return __builtin_fabsf(__x); }
00177
00178 inline long double
00179 abs(long double __x)
00180 { return __builtin_fabsl(__x); }
00181
00182 #if _GLIBCPP_HAVE_ACOSF
00183 inline float
00184 acos(float __x) { return __gnu_cxx::__c99_binding::acosf(__x); }
00185 #else
00186 inline float
00187 acos(float __x) { return ::acos(static_cast<double>(__x)); }
00188 #endif
00189
00190 using ::acos;
00191
00192 #if _GLIBCPP_HAVE_ACOSL
00193 inline long double
00194 acos(long double __x) { return ::acosl(__x); }
00195 #else
00196 inline long double
00197 acos(long double __x) { return ::acos(static_cast<double>(__x)); }
00198 #endif
00199
00200 using ::asin;
00201
00202 #if _GLIBCPP_HAVE_ASINF
00203 inline float
00204 asin(float __x) { return __gnu_cxx::__c99_binding::asinf(__x); }
00205 #else
00206 inline float
00207 asin(float __x) { return ::asin(static_cast<double>(__x)); }
00208 #endif
00209
00210 #if _GLIBCPP_HAVE_ASINL
00211 inline long double
00212 asin(long double __x) { return ::asinl(__x); }
00213 #else
00214 inline long double
00215 asin(long double __x) { return ::asin(static_cast<double>(__x)); }
00216 #endif
00217
00218 using ::atan;
00219
00220 #if _GLIBCPP_HAVE_ATANF
00221 inline float
00222 atan(float __x) { return __gnu_cxx::__c99_binding::atanf(__x); }
00223 #else
00224 inline float
00225 atan(float __x) { return ::atan(static_cast<double>(__x)); }
00226 #endif
00227
00228 #if _GLIBCPP_HAVE_ATANL
00229 inline long double
00230 atan(long double __x) { return ::atanl(__x); }
00231 #else
00232 inline long double
00233 atan(long double __x) { return ::atan(static_cast<double>(__x)); }
00234 #endif
00235
00236 using ::atan2;
00237
00238 #if _GLIBCPP_HAVE_ATAN2F
00239 inline float
00240 atan2(float __y, float __x) { return __gnu_cxx::__c99_binding::atan2f(__y, __x); }
00241 #else
00242 inline float
00243 atan2(float __y, float __x)
00244 { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); }
00245 #endif
00246
00247 #if _GLIBCPP_HAVE_ATAN2L
00248 inline long double
00249 atan2(long double __y, long double __x) { return ::atan2l(__y, __x); }
00250 #else
00251 inline long double
00252 atan2(long double __y, long double __x)
00253 { return ::atan2(static_cast<double>(__y), static_cast<double>(__x)); }
00254 #endif
00255
00256 using ::ceil;
00257
00258 #if _GLIBCPP_HAVE_CEILF
00259 inline float
00260 ceil(float __x) { return __gnu_cxx::__c99_binding::ceilf(__x); }
00261 #else
00262 inline float
00263 ceil(float __x) { return ::ceil(static_cast<double>(__x)); }
00264 #endif
00265
00266 #if _GLIBCPP_HAVE_CEILL
00267 inline long double
00268 ceil(long double __x) { return ::ceill(__x); }
00269 #else
00270 inline long double
00271 ceil(long double __x) { return ::ceil(static_cast<double>(__x)); }
00272 #endif
00273
00274 using ::cos;
00275
00276 inline float
00277 cos(float __x)
00278 { return __builtin_cosf(__x); }
00279
00280 inline long double
00281 cos(long double __x)
00282 { return __builtin_cosl(__x); }
00283
00284 using ::cosh;
00285
00286 #if _GLIBCPP_HAVE_COSHF
00287 inline float
00288 cosh(float __x) { return __gnu_cxx::__c99_binding::coshf(__x); }
00289 #else
00290 inline float
00291 cosh(float __x) { return ::cosh(static_cast<double>(__x)); }
00292 #endif
00293
00294 #if _GLIBCPP_HAVE_COSHL
00295 inline long double
00296 cosh(long double __x) { return ::coshl(__x); }
00297 #else
00298 inline long double
00299 cosh(long double __x) { return ::cosh(static_cast<double>(__x)); }
00300 #endif
00301
00302 using ::exp;
00303
00304 #if _GLIBCPP_HAVE_EXPF
00305 inline float
00306 exp(float __x) { return __gnu_cxx::__c99_binding::expf(__x); }
00307 #else
00308 inline float
00309 exp(float __x) { return ::exp(static_cast<double>(__x)); }
00310 #endif
00311
00312 #if _GLIBCPP_HAVE_EXPL
00313 inline long double
00314 exp(long double __x) { return ::expl(__x); }
00315 #else
00316 inline long double
00317 exp(long double __x) { return ::exp(static_cast<double>(__x)); }
00318 #endif
00319
00320 using ::fabs;
00321
00322 inline float
00323 fabs(float __x)
00324 { return __builtin_fabsf(__x); }
00325
00326 inline long double
00327 fabs(long double __x)
00328 { return __builtin_fabsl(__x); }
00329
00330 using ::floor;
00331
00332 #if _GLIBCPP_HAVE_FLOORF
00333 inline float
00334 floor(float __x) { return __gnu_cxx::__c99_binding::floorf(__x); }
00335 #else
00336 inline float
00337 floor(float __x) { return ::floor(static_cast<double>(__x)); }
00338 #endif
00339
00340 #if _GLIBCPP_HAVE_FLOORL
00341 inline long double
00342 floor(long double __x) { return ::floorl(__x); }
00343 #else
00344 inline long double
00345 floor(long double __x) { return ::floor(static_cast<double>(__x)); }
00346 #endif
00347
00348 using ::fmod;
00349
00350 #if _GLIBCPP_HAVE_FMODF
00351 inline float
00352 fmod(float __x, float __y) { return __gnu_cxx::__c99_binding::fmodf(__x, __y); }
00353 #else
00354 inline float
00355 fmod(float __x, float __y)
00356 { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); }
00357 #endif
00358
00359 #if _GLIBCPP_HAVE_FMODL
00360 inline long double
00361 fmod(long double __x, long double __y) { return ::fmodl(__x, __y); }
00362 #else
00363 inline long double
00364 fmod(long double __x, long double __y)
00365 { return ::fmod(static_cast<double>(__x), static_cast<double>(__y)); }
00366 #endif
00367
00368 using ::frexp;
00369
00370 #if _GLIBCPP_HAVE_FREXPF
00371 inline float
00372 frexp(float __x, int* __exp) { return __gnu_cxx::__c99_binding::frexpf(__x, __exp); }
00373 #else
00374 inline float
00375 frexp(float __x, int* __exp) { return ::frexp(__x, __exp); }
00376 #endif
00377
00378 #if _GLIBCPP_HAVE_FREXPL
00379 inline long double
00380 frexp(long double __x, int* __exp) { return ::frexpl(__x, __exp); }
00381 #else
00382 inline long double
00383 frexp(long double __x, int* __exp)
00384 { return ::frexp(static_cast<double>(__x), __exp); }
00385 #endif
00386
00387 using ::ldexp;
00388
00389 #if _GLIBCPP_HAVE_LDEXPF
00390 inline float
00391 ldexp(float __x, int __exp) { return __gnu_cxx::__c99_binding::ldexpf(__x, __exp); }
00392 #else
00393 inline float
00394 ldexp(float __x, int __exp)
00395 { return ::ldexp(static_cast<double>(__x), __exp); }
00396 #endif
00397
00398 #if _GLIBCPP_HAVE_LDEXPL
00399 inline long double
00400 ldexp(long double __x, int __exp) { return ::ldexpl(__x, __exp); }
00401 #else
00402 inline long double
00403 ldexp(long double __x, int __exp)
00404 { return ::ldexp(static_cast<double>(__x), __exp); }
00405 #endif
00406
00407 using ::log;
00408
00409 #if _GLIBCPP_HAVE_LOGF
00410 inline float
00411 log(float __x) { return __gnu_cxx::__c99_binding::logf(__x); }
00412 #else
00413 inline float log(float __x)
00414 { return ::log(static_cast<double>(__x)); }
00415 #endif
00416
00417 #if _GLIBCPP_HAVE_LOGL
00418 inline long double
00419 log(long double __x) { return ::logl(__x); }
00420 #else
00421 inline long double
00422 log(long double __x) { return ::log(static_cast<double>(__x)); }
00423 #endif
00424
00425 using ::log10;
00426
00427 #if _GLIBCPP_HAVE_LOG10F
00428 inline float
00429 log10(float __x) { return __gnu_cxx::__c99_binding::log10f(__x); }
00430 #else
00431 inline float
00432 log10(float __x) { return ::log10(static_cast<double>(__x)); }
00433 #endif
00434
00435 #if _GLIBCPP_HAVE_LOG10L
00436 inline long double
00437 log10(long double __x) { return ::log10l(__x); }
00438 #else
00439 inline long double
00440 log10(long double __x) { return ::log10(static_cast<double>(__x)); }
00441 #endif
00442
00443 using ::modf;
00444
00445 #if _GLIBCPP_HAVE_MODFF
00446 inline float
00447 modf(float __x, float* __iptr) { return __gnu_cxx::__c99_binding::modff(__x, __iptr); }
00448 #else
00449 inline float
00450 modf(float __x, float* __iptr)
00451 {
00452 double __tmp;
00453 double __res = ::modf(static_cast<double>(__x), &__tmp);
00454 *__iptr = static_cast<float>(__tmp);
00455 return __res;
00456 }
00457 #endif
00458
00459 #if _GLIBCPP_HAVE_MODFL
00460 inline long double
00461 modf(long double __x, long double* __iptr) { return ::modfl(__x, __iptr); }
00462 #else
00463 inline long double
00464 modf(long double __x, long double* __iptr)
00465 {
00466 double __tmp;
00467 double __res = ::modf(static_cast<double>(__x), &__tmp);
00468 * __iptr = static_cast<long double>(__tmp);
00469 return __res;
00470 }
00471 #endif
00472
00473 template<typename _Tp>
00474 inline _Tp
00475 __pow_helper(_Tp __x, int __n)
00476 {
00477 return __n < 0
00478 ? _Tp(1)/__cmath_power(__x, -__n)
00479 : __cmath_power(__x, __n);
00480 }
00481
00482 using ::pow;
00483
00484 #if _GLIBCPP_HAVE_POWF
00485 inline float
00486 pow(float __x, float __y) { return __gnu_cxx::__c99_binding::powf(__x, __y); }
00487 #else
00488 inline float
00489 pow(float __x, float __y)
00490 { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
00491 #endif
00492
00493 #if _GLIBCPP_HAVE_POWL
00494 inline long double
00495 pow(long double __x, long double __y) { return ::powl(__x, __y); }
00496 #else
00497 inline long double
00498 pow(long double __x, long double __y)
00499 { return ::pow(static_cast<double>(__x), static_cast<double>(__y)); }
00500 #endif
00501
00502 inline double
00503 pow(double __x, int __i)
00504 { return __pow_helper(__x, __i); }
00505
00506 inline float
00507 pow(float __x, int __n)
00508 { return __pow_helper(__x, __n); }
00509
00510 inline long double
00511 pow(long double __x, int __n)
00512 { return __pow_helper(__x, __n); }
00513
00514 using ::sin;
00515
00516 inline float
00517 sin(float __x)
00518 { return __builtin_sinf(__x); }
00519
00520 inline long double
00521 sin(long double __x)
00522 { return __builtin_sinl(__x); }
00523
00524 using ::sinh;
00525
00526 #if _GLIBCPP_HAVE_SINHF
00527 inline float
00528 sinh(float __x) { return __gnu_cxx::__c99_binding::sinhf(__x); }
00529 #else
00530 inline float
00531 sinh(float __x) { return ::sinh(static_cast<double>(__x)); }
00532 #endif
00533
00534 #if _GLIBCPP_HAVE_SINHL
00535 inline long double
00536 sinh(long double __x) { return ::sinhl(__x); }
00537 #else
00538 inline long double
00539 sinh(long double __x) { return ::sinh(static_cast<double>(__x)); }
00540 #endif
00541
00542 using ::sqrt;
00543
00544 inline float
00545 sqrt(float __x)
00546 { return __builtin_sqrtf(__x); }
00547
00548 inline long double
00549 sqrt(long double __x)
00550 { return __builtin_sqrtl(__x); }
00551
00552 using ::tan;
00553
00554 #if _GLIBCPP_HAVE_TANF
00555 inline float
00556 tan(float __x) { return __gnu_cxx::__c99_binding::tanf(__x); }
00557 #else
00558 inline float
00559 tan(float __x) { return ::tan(static_cast<double>(__x)); }
00560 #endif
00561
00562 #if _GLIBCPP_HAVE_TANL
00563 inline long double
00564 tan(long double __x) { return ::tanl(__x); }
00565 #else
00566 inline long double
00567 tan(long double __x) { return ::tan(static_cast<double>(__x)); }
00568 #endif
00569
00570 using ::tanh;
00571
00572 #if _GLIBCPP_HAVE_TANHF
00573 inline float
00574 tanh(float __x) { return __gnu_cxx::__c99_binding::tanhf(__x); }
00575 #else
00576 inline float
00577 tanh(float __x) { return ::tanh(static_cast<double>(__x)); }
00578 #endif
00579
00580 #if _GLIBCPP_HAVE_TANHL
00581 inline long double
00582 tanh(long double __x) { return ::tanhl(__x); }
00583 #else
00584 inline long double
00585 tanh(long double __x) { return ::tanh(static_cast<double>(__x)); }
00586 #endif
00587 }
00588
00589
00590 #if _GLIBCPP_USE_C99
00591 #if !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC
00592
00593
00594
00595 namespace __gnu_cxx
00596 {
00597 template<typename _Tp>
00598 int
00599 __capture_fpclassify(_Tp __f) { return fpclassify(__f); }
00600
00601 template<typename _Tp>
00602 int
00603 __capture_isfinite(_Tp __f) { return isfinite(__f); }
00604
00605 template<typename _Tp>
00606 int
00607 __capture_isinf(_Tp __f) { return isinf(__f); }
00608
00609 template<typename _Tp>
00610 int
00611 __capture_isnan(_Tp __f) { return isnan(__f); }
00612
00613 template<typename _Tp>
00614 int
00615 __capture_isnormal(_Tp __f) { return isnormal(__f); }
00616
00617 template<typename _Tp>
00618 int
00619 __capture_signbit(_Tp __f) { return signbit(__f); }
00620
00621 template<typename _Tp>
00622 int
00623 __capture_isgreater(_Tp __f1, _Tp __f2)
00624 { return isgreater(__f1, __f2); }
00625
00626 template<typename _Tp>
00627 int
00628 __capture_isgreaterequal(_Tp __f1, _Tp __f2)
00629 { return isgreaterequal(__f1, __f2); }
00630
00631 template<typename _Tp>
00632 int
00633 __capture_isless(_Tp __f1, _Tp __f2) { return isless(__f1, __f2); }
00634
00635 template<typename _Tp>
00636 int
00637 __capture_islessequal(_Tp __f1, _Tp __f2)
00638 { return islessequal(__f1, __f2); }
00639
00640 template<typename _Tp>
00641 int
00642 __capture_islessgreater(_Tp __f1, _Tp __f2)
00643 { return islessgreater(__f1, __f2); }
00644
00645 template<typename _Tp>
00646 int
00647 __capture_isunordered(_Tp __f1, _Tp __f2)
00648 { return isunordered(__f1, __f2); }
00649 }
00650 #endif
00651 #endif
00652
00653 #undef fpclassify
00654 #undef isfinite
00655 #undef isinf
00656 #undef isnan
00657 #undef isnormal
00658 #undef signbit
00659 #undef isgreater
00660 #undef isgreaterequal
00661 #undef isless
00662 #undef islessequal
00663 #undef islessgreater
00664 #undef isunordered
00665
00666 #if _GLIBCPP_USE_C99
00667 #if !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC
00668 namespace __gnu_cxx
00669 {
00670 template<typename _Tp>
00671 int
00672 fpclassify(_Tp __f) { return __capture_fpclassify(__f); }
00673
00674 template<typename _Tp>
00675 int
00676 isfinite(_Tp __f) { return __capture_isfinite(__f); }
00677
00678 template<typename _Tp>
00679 int
00680 isinf(_Tp __f) { return __capture_isinf(__f); }
00681
00682 template<typename _Tp>
00683 int
00684 isnan(_Tp __f) { return __capture_isnan(__f); }
00685
00686 template<typename _Tp>
00687 int
00688 isnormal(_Tp __f) { return __capture_isnormal(__f); }
00689
00690 template<typename _Tp>
00691 int
00692 signbit(_Tp __f) { return __capture_signbit(__f); }
00693
00694 template<typename _Tp>
00695 int
00696 isgreater(_Tp __f1, _Tp __f2) { return __capture_isgreater(__f1, __f2); }
00697
00698 template<typename _Tp>
00699 int
00700 isgreaterequal(_Tp __f1, _Tp __f2)
00701 { return __capture_isgreaterequal(__f1, __f2); }
00702
00703 template<typename _Tp>
00704 int
00705 isless(_Tp __f1, _Tp __f2) { return __capture_isless(__f1, __f2); }
00706
00707 template<typename _Tp>
00708 int
00709 islessequal(_Tp __f1, _Tp __f2)
00710 { return __capture_islessequal(__f1, __f2); }
00711
00712 template<typename _Tp>
00713 int
00714 islessgreater(_Tp __f1, _Tp __f2)
00715 { return __capture_islessgreater(__f1, __f2); }
00716
00717 template<typename _Tp>
00718 int
00719 isunordered(_Tp __f1, _Tp __f2)
00720 { return __capture_isunordered(__f1, __f2); }
00721 }
00722
00723 namespace std
00724 {
00725 using __gnu_cxx::fpclassify;
00726 using __gnu_cxx::isfinite;
00727 using __gnu_cxx::isinf;
00728 using __gnu_cxx::isnan;
00729 using __gnu_cxx::isnormal;
00730 using __gnu_cxx::signbit;
00731 using __gnu_cxx::isgreater;
00732 using __gnu_cxx::isgreaterequal;
00733 using __gnu_cxx::isless;
00734 using __gnu_cxx::islessequal;
00735 using __gnu_cxx::islessgreater;
00736 using __gnu_cxx::isunordered;
00737 }
00738 #endif
00739 #endif
00740
00741 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
00742 # define export
00743 # include <bits/cmath.tcc>
00744 #endif
00745
00746 #endif