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
00045 #ifndef _GLIBCXX_CMATH
00046 #define _GLIBCXX_CMATH 1
00047
00048 #pragma GCC system_header
00049
00050 #include <bits/c++config.h>
00051 #include <bits/cpp_type_traits.h>
00052
00053 #include <math.h>
00054
00055
00056 #undef abs
00057 #undef div
00058 #undef acos
00059 #undef asin
00060 #undef atan
00061 #undef atan2
00062 #undef ceil
00063 #undef cos
00064 #undef cosh
00065 #undef exp
00066 #undef fabs
00067 #undef floor
00068 #undef fmod
00069 #undef frexp
00070 #undef ldexp
00071 #undef log
00072 #undef log10
00073 #undef modf
00074 #undef pow
00075 #undef sin
00076 #undef sinh
00077 #undef sqrt
00078 #undef tan
00079 #undef tanh
00080
00081
00082 namespace std
00083 {
00084
00085
00086 template<typename _Tp> _Tp __cmath_power(_Tp, unsigned int);
00087
00088 inline double
00089 abs(double __x)
00090 { return __builtin_fabs(__x); }
00091
00092 inline float
00093 abs(float __x)
00094 { return __builtin_fabsf(__x); }
00095
00096 inline long double
00097 abs(long double __x)
00098 { return __builtin_fabsl(__x); }
00099
00100 using ::acos;
00101
00102 inline float
00103 acos(float __x)
00104 { return __builtin_acosf(__x); }
00105
00106 inline long double
00107 acos(long double __x)
00108 { return __builtin_acosl(__x); }
00109
00110 template<typename _Tp>
00111 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00112 acos(_Tp __x)
00113 {
00114 return __builtin_acos(__x);
00115 }
00116
00117 using ::asin;
00118
00119 inline float
00120 asin(float __x)
00121 { return __builtin_asinf(__x); }
00122
00123 inline long double
00124 asin(long double __x)
00125 { return __builtin_asinl(__x); }
00126
00127 template<typename _Tp>
00128 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00129 asin(_Tp __x)
00130 { return __builtin_asin(__x); }
00131
00132 using ::atan;
00133
00134 inline float
00135 atan(float __x)
00136 { return __builtin_atanf(__x); }
00137
00138 inline long double
00139 atan(long double __x)
00140 { return __builtin_atanl(__x); }
00141
00142 template<typename _Tp>
00143 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00144 atan(_Tp __x)
00145 { return __builtin_atan(__x); }
00146
00147 using ::atan2;
00148
00149 inline float
00150 atan2(float __y, float __x)
00151 { return __builtin_atan2f(__y, __x); }
00152
00153 inline long double
00154 atan2(long double __y, long double __x)
00155 { return __builtin_atan2l(__y, __x); }
00156
00157 template<typename _Tp, typename _Up>
00158 inline typename __enable_if<double, __is_integer<_Tp>::__value
00159 && __is_integer<_Up>::__value>::__type
00160 atan2(_Tp __y, _Up __x)
00161 { return __builtin_atan2(__y, __x); }
00162
00163 using ::ceil;
00164
00165 inline float
00166 ceil(float __x)
00167 { return __builtin_ceilf(__x); }
00168
00169 inline long double
00170 ceil(long double __x)
00171 { return __builtin_ceill(__x); }
00172
00173 template<typename _Tp>
00174 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00175 ceil(_Tp __x)
00176 { return __builtin_ceil(__x); }
00177
00178 using ::cos;
00179
00180 inline float
00181 cos(float __x)
00182 { return __builtin_cosf(__x); }
00183
00184 inline long double
00185 cos(long double __x)
00186 { return __builtin_cosl(__x); }
00187
00188 template<typename _Tp>
00189 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00190 cos(_Tp __x)
00191 { return __builtin_cos(__x); }
00192
00193 using ::cosh;
00194
00195 inline float
00196 cosh(float __x)
00197 { return __builtin_coshf(__x); }
00198
00199 inline long double
00200 cosh(long double __x)
00201 { return __builtin_coshl(__x); }
00202
00203 template<typename _Tp>
00204 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00205 cosh(_Tp __x)
00206 { return __builtin_cosh(__x); }
00207
00208 using ::exp;
00209
00210 inline float
00211 exp(float __x)
00212 { return __builtin_expf(__x); }
00213
00214 inline long double
00215 exp(long double __x)
00216 { return __builtin_expl(__x); }
00217
00218 template<typename _Tp>
00219 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00220 exp(_Tp __x)
00221 { return __builtin_exp(__x); }
00222
00223 using ::fabs;
00224
00225 inline float
00226 fabs(float __x)
00227 { return __builtin_fabsf(__x); }
00228
00229 inline long double
00230 fabs(long double __x)
00231 { return __builtin_fabsl(__x); }
00232
00233 template<typename _Tp>
00234 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00235 fabs(_Tp __x)
00236 { return __builtin_fabs(__x); }
00237
00238 using ::floor;
00239
00240 inline float
00241 floor(float __x)
00242 { return __builtin_floorf(__x); }
00243
00244 inline long double
00245 floor(long double __x)
00246 { return __builtin_floorl(__x); }
00247
00248 template<typename _Tp>
00249 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00250 floor(_Tp __x)
00251 { return __builtin_floor(__x); }
00252
00253 using ::fmod;
00254
00255 inline float
00256 fmod(float __x, float __y)
00257 { return __builtin_fmodf(__x, __y); }
00258
00259 inline long double
00260 fmod(long double __x, long double __y)
00261 { return __builtin_fmodl(__x, __y); }
00262
00263 using ::frexp;
00264
00265 inline float
00266 frexp(float __x, int* __exp)
00267 { return __builtin_frexpf(__x, __exp); }
00268
00269 inline long double
00270 frexp(long double __x, int* __exp)
00271 { return __builtin_frexpl(__x, __exp); }
00272
00273 template<typename _Tp>
00274 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00275 frexp(_Tp __x, int* __exp)
00276 { return __builtin_frexp(__x, __exp); }
00277
00278 using ::ldexp;
00279
00280 inline float
00281 ldexp(float __x, int __exp)
00282 { return __builtin_ldexpf(__x, __exp); }
00283
00284 inline long double
00285 ldexp(long double __x, int __exp)
00286 { return __builtin_ldexpl(__x, __exp); }
00287
00288 template<typename _Tp>
00289 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00290 ldexp(_Tp __x, int __exp)
00291 { return __builtin_ldexp(__x, __exp); }
00292
00293 using ::log;
00294
00295 inline float
00296 log(float __x)
00297 { return __builtin_logf(__x); }
00298
00299 inline long double
00300 log(long double __x)
00301 { return __builtin_logl(__x); }
00302
00303 template<typename _Tp>
00304 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00305 log(_Tp __x)
00306 { return __builtin_log(__x); }
00307
00308 using ::log10;
00309
00310 inline float
00311 log10(float __x)
00312 { return __builtin_log10f(__x); }
00313
00314 inline long double
00315 log10(long double __x)
00316 { return __builtin_log10l(__x); }
00317
00318 template<typename _Tp>
00319 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00320 log10(_Tp __x)
00321 { return __builtin_log10(__x); }
00322
00323 using ::modf;
00324
00325 inline float
00326 modf(float __x, float* __iptr)
00327 { return __builtin_modff(__x, __iptr); }
00328
00329 inline long double
00330 modf(long double __x, long double* __iptr)
00331 { return __builtin_modfl(__x, __iptr); }
00332
00333 template<typename _Tp>
00334 inline _Tp
00335 __pow_helper(_Tp __x, int __n)
00336 {
00337 return __n < 0
00338 ? _Tp(1)/__cmath_power(__x, -__n)
00339 : __cmath_power(__x, __n);
00340 }
00341
00342 using ::pow;
00343
00344 inline float
00345 pow(float __x, float __y)
00346 { return __builtin_powf(__x, __y); }
00347
00348 inline long double
00349 pow(long double __x, long double __y)
00350 { return __builtin_powl(__x, __y); }
00351
00352 inline double
00353 pow(double __x, int __i)
00354 { return __builtin_powi(__x, __i); }
00355
00356 inline float
00357 pow(float __x, int __n)
00358 { return __builtin_powif(__x, __n); }
00359
00360 inline long double
00361 pow(long double __x, int __n)
00362 { return __builtin_powil(__x, __n); }
00363
00364 using ::sin;
00365
00366 inline float
00367 sin(float __x)
00368 { return __builtin_sinf(__x); }
00369
00370 inline long double
00371 sin(long double __x)
00372 { return __builtin_sinl(__x); }
00373
00374 template<typename _Tp>
00375 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00376 sin(_Tp __x)
00377 { return __builtin_sin(__x); }
00378
00379 using ::sinh;
00380
00381 inline float
00382 sinh(float __x)
00383 { return __builtin_sinhf(__x); }
00384
00385 inline long double
00386 sinh(long double __x)
00387 { return __builtin_sinhl(__x); }
00388
00389 template<typename _Tp>
00390 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00391 sinh(_Tp __x)
00392 { return __builtin_sinh(__x); }
00393
00394 using ::sqrt;
00395
00396 inline float
00397 sqrt(float __x)
00398 { return __builtin_sqrtf(__x); }
00399
00400 inline long double
00401 sqrt(long double __x)
00402 { return __builtin_sqrtl(__x); }
00403
00404 template<typename _Tp>
00405 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00406 sqrt(_Tp __x)
00407 { return __builtin_sqrt(__x); }
00408
00409 using ::tan;
00410
00411 inline float
00412 tan(float __x)
00413 { return __builtin_tanf(__x); }
00414
00415 inline long double
00416 tan(long double __x)
00417 { return __builtin_tanl(__x); }
00418
00419 template<typename _Tp>
00420 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00421 tan(_Tp __x)
00422 { return __builtin_tan(__x); }
00423
00424 using ::tanh;
00425
00426 inline float
00427 tanh(float __x)
00428 { return __builtin_tanhf(__x); }
00429
00430 inline long double
00431 tanh(long double __x)
00432 { return __builtin_tanhl(__x); }
00433
00434 template<typename _Tp>
00435 inline typename __enable_if<double, __is_integer<_Tp>::__value>::__type
00436 tanh(_Tp __x)
00437 { return __builtin_tanh(__x); }
00438 }
00439
00440 #if _GLIBCXX_USE_C99_MATH
00441 #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
00442
00443
00444
00445 namespace __gnu_cxx
00446 {
00447 template<typename _Tp>
00448 inline int
00449 __capture_fpclassify(_Tp __f) { return fpclassify(__f); }
00450
00451 template<typename _Tp>
00452 inline int
00453 __capture_isfinite(_Tp __f) { return isfinite(__f); }
00454
00455 template<typename _Tp>
00456 inline int
00457 __capture_isinf(_Tp __f) { return isinf(__f); }
00458
00459 template<typename _Tp>
00460 inline int
00461 __capture_isnan(_Tp __f) { return isnan(__f); }
00462
00463 template<typename _Tp>
00464 inline int
00465 __capture_isnormal(_Tp __f) { return isnormal(__f); }
00466
00467 template<typename _Tp>
00468 inline int
00469 __capture_signbit(_Tp __f) { return signbit(__f); }
00470
00471 template<typename _Tp>
00472 inline int
00473 __capture_isgreater(_Tp __f1, _Tp __f2)
00474 { return isgreater(__f1, __f2); }
00475
00476 template<typename _Tp>
00477 inline int
00478 __capture_isgreaterequal(_Tp __f1, _Tp __f2)
00479 { return isgreaterequal(__f1, __f2); }
00480
00481 template<typename _Tp>
00482 inline int
00483 __capture_isless(_Tp __f1, _Tp __f2) { return isless(__f1, __f2); }
00484
00485 template<typename _Tp>
00486 inline int
00487 __capture_islessequal(_Tp __f1, _Tp __f2)
00488 { return islessequal(__f1, __f2); }
00489
00490 template<typename _Tp>
00491 inline int
00492 __capture_islessgreater(_Tp __f1, _Tp __f2)
00493 { return islessgreater(__f1, __f2); }
00494
00495 template<typename _Tp>
00496 inline int
00497 __capture_isunordered(_Tp __f1, _Tp __f2)
00498 { return isunordered(__f1, __f2); }
00499 }
00500
00501
00502 #undef fpclassify
00503 #undef isfinite
00504 #undef isinf
00505 #undef isnan
00506 #undef isnormal
00507 #undef signbit
00508 #undef isgreater
00509 #undef isgreaterequal
00510 #undef isless
00511 #undef islessequal
00512 #undef islessgreater
00513 #undef isunordered
00514
00515 namespace std
00516 {
00517 template<typename _Tp>
00518 inline int
00519 fpclassify(_Tp __f) { return __gnu_cxx::__capture_fpclassify(__f); }
00520
00521 template<typename _Tp>
00522 inline int
00523 isfinite(_Tp __f) { return __gnu_cxx::__capture_isfinite(__f); }
00524
00525 template<typename _Tp>
00526 inline int
00527 isinf(_Tp __f) { return __gnu_cxx::__capture_isinf(__f); }
00528
00529 template<typename _Tp>
00530 inline int
00531 isnan(_Tp __f) { return __gnu_cxx::__capture_isnan(__f); }
00532
00533 template<typename _Tp>
00534 inline int
00535 isnormal(_Tp __f) { return __gnu_cxx::__capture_isnormal(__f); }
00536
00537 template<typename _Tp>
00538 inline int
00539 signbit(_Tp __f) { return __gnu_cxx::__capture_signbit(__f); }
00540
00541 template<typename _Tp>
00542 inline int
00543 isgreater(_Tp __f1, _Tp __f2)
00544 { return __gnu_cxx::__capture_isgreater(__f1, __f2); }
00545
00546 template<typename _Tp>
00547 inline int
00548 isgreaterequal(_Tp __f1, _Tp __f2)
00549 { return __gnu_cxx::__capture_isgreaterequal(__f1, __f2); }
00550
00551 template<typename _Tp>
00552 inline int
00553 isless(_Tp __f1, _Tp __f2)
00554 { return __gnu_cxx::__capture_isless(__f1, __f2); }
00555
00556 template<typename _Tp>
00557 inline int
00558 islessequal(_Tp __f1, _Tp __f2)
00559 { return __gnu_cxx::__capture_islessequal(__f1, __f2); }
00560
00561 template<typename _Tp>
00562 inline int
00563 islessgreater(_Tp __f1, _Tp __f2)
00564 { return __gnu_cxx::__capture_islessgreater(__f1, __f2); }
00565
00566 template<typename _Tp>
00567 inline int
00568 isunordered(_Tp __f1, _Tp __f2)
00569 { return __gnu_cxx::__capture_isunordered(__f1, __f2); }
00570 }
00571 #endif
00572 #endif
00573
00574 #ifndef _GLIBCXX_EXPORT_TEMPLATE
00575 # include <bits/cmath.tcc>
00576 #endif
00577
00578 #endif