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