Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- cmath -----------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_CMATH |
| 12 | #define _LIBCPP_CMATH |
| 13 | |
| 14 | /* |
| 15 | cmath synopsis |
| 16 | |
| 17 | Macros: |
| 18 | |
| 19 | HUGE_VAL |
| 20 | HUGE_VALF // C99 |
| 21 | HUGE_VALL // C99 |
| 22 | INFINITY // C99 |
| 23 | NAN // C99 |
| 24 | FP_INFINITE // C99 |
| 25 | FP_NAN // C99 |
| 26 | FP_NORMAL // C99 |
| 27 | FP_SUBNORMAL // C99 |
| 28 | FP_ZERO // C99 |
| 29 | FP_FAST_FMA // C99 |
| 30 | FP_FAST_FMAF // C99 |
| 31 | FP_FAST_FMAL // C99 |
| 32 | FP_ILOGB0 // C99 |
| 33 | FP_ILOGBNAN // C99 |
| 34 | MATH_ERRNO // C99 |
| 35 | MATH_ERREXCEPT // C99 |
| 36 | math_errhandling // C99 |
| 37 | |
| 38 | namespace std |
| 39 | { |
| 40 | |
| 41 | Types: |
| 42 | |
| 43 | float_t // C99 |
| 44 | double_t // C99 |
| 45 | |
| 46 | // C90 |
| 47 | |
| 48 | floating_point abs(floating_point x); |
| 49 | |
| 50 | floating_point acos (arithmetic x); |
| 51 | float acosf(float x); |
| 52 | long double acosl(long double x); |
| 53 | |
| 54 | floating_point asin (arithmetic x); |
| 55 | float asinf(float x); |
| 56 | long double asinl(long double x); |
| 57 | |
| 58 | floating_point atan (arithmetic x); |
| 59 | float atanf(float x); |
| 60 | long double atanl(long double x); |
| 61 | |
| 62 | floating_point atan2 (arithmetic y, arithmetic x); |
| 63 | float atan2f(float y, float x); |
| 64 | long double atan2l(long double y, long double x); |
| 65 | |
| 66 | floating_point ceil (arithmetic x); |
| 67 | float ceilf(float x); |
| 68 | long double ceill(long double x); |
| 69 | |
| 70 | floating_point cos (arithmetic x); |
| 71 | float cosf(float x); |
| 72 | long double cosl(long double x); |
| 73 | |
| 74 | floating_point cosh (arithmetic x); |
| 75 | float coshf(float x); |
| 76 | long double coshl(long double x); |
| 77 | |
| 78 | floating_point exp (arithmetic x); |
| 79 | float expf(float x); |
| 80 | long double expl(long double x); |
| 81 | |
| 82 | floating_point fabs (arithmetic x); |
| 83 | float fabsf(float x); |
| 84 | long double fabsl(long double x); |
| 85 | |
| 86 | floating_point floor (arithmetic x); |
| 87 | float floorf(float x); |
| 88 | long double floorl(long double x); |
| 89 | |
| 90 | floating_point fmod (arithmetic x, arithmetic y); |
| 91 | float fmodf(float x, float y); |
| 92 | long double fmodl(long double x, long double y); |
| 93 | |
| 94 | floating_point frexp (arithmetic value, int* exp); |
| 95 | float frexpf(float value, int* exp); |
| 96 | long double frexpl(long double value, int* exp); |
| 97 | |
| 98 | floating_point ldexp (arithmetic value, int exp); |
| 99 | float ldexpf(float value, int exp); |
| 100 | long double ldexpl(long double value, int exp); |
| 101 | |
| 102 | floating_point log (arithmetic x); |
| 103 | float logf(float x); |
| 104 | long double logl(long double x); |
| 105 | |
| 106 | floating_point log10 (arithmetic x); |
| 107 | float log10f(float x); |
| 108 | long double log10l(long double x); |
| 109 | |
| 110 | floating_point modf (floating_point value, floating_point* iptr); |
| 111 | float modff(float value, float* iptr); |
| 112 | long double modfl(long double value, long double* iptr); |
| 113 | |
| 114 | floating_point pow (arithmetic x, arithmetic y); |
| 115 | float powf(float x, float y); |
| 116 | long double powl(long double x, long double y); |
| 117 | |
| 118 | floating_point sin (arithmetic x); |
| 119 | float sinf(float x); |
| 120 | long double sinl(long double x); |
| 121 | |
| 122 | floating_point sinh (arithmetic x); |
| 123 | float sinhf(float x); |
| 124 | long double sinhl(long double x); |
| 125 | |
| 126 | floating_point sqrt (arithmetic x); |
| 127 | float sqrtf(float x); |
| 128 | long double sqrtl(long double x); |
| 129 | |
| 130 | floating_point tan (arithmetic x); |
| 131 | float tanf(float x); |
| 132 | long double tanl(long double x); |
| 133 | |
| 134 | floating_point tanh (arithmetic x); |
| 135 | float tanhf(float x); |
| 136 | long double tanhl(long double x); |
| 137 | |
| 138 | // C99 |
| 139 | |
Howard Hinnant | b05a556 | 2013-01-14 20:56:22 +0000 | [diff] [blame] | 140 | bool signbit(arithmetic x); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 141 | |
Howard Hinnant | b05a556 | 2013-01-14 20:56:22 +0000 | [diff] [blame] | 142 | int fpclassify(arithmetic x); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 143 | |
Howard Hinnant | b05a556 | 2013-01-14 20:56:22 +0000 | [diff] [blame] | 144 | bool isfinite(arithmetic x); |
| 145 | bool isinf(arithmetic x); |
| 146 | bool isnan(arithmetic x); |
| 147 | bool isnormal(arithmetic x); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 148 | |
Howard Hinnant | b05a556 | 2013-01-14 20:56:22 +0000 | [diff] [blame] | 149 | bool isgreater(arithmetic x, arithmetic y); |
| 150 | bool isgreaterequal(arithmetic x, arithmetic y); |
| 151 | bool isless(arithmetic x, arithmetic y); |
| 152 | bool islessequal(arithmetic x, arithmetic y); |
| 153 | bool islessgreater(arithmetic x, arithmetic y); |
| 154 | bool isunordered(arithmetic x, arithmetic y); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 155 | |
| 156 | floating_point acosh (arithmetic x); |
| 157 | float acoshf(float x); |
| 158 | long double acoshl(long double x); |
| 159 | |
| 160 | floating_point asinh (arithmetic x); |
| 161 | float asinhf(float x); |
| 162 | long double asinhl(long double x); |
| 163 | |
| 164 | floating_point atanh (arithmetic x); |
| 165 | float atanhf(float x); |
| 166 | long double atanhl(long double x); |
| 167 | |
| 168 | floating_point cbrt (arithmetic x); |
| 169 | float cbrtf(float x); |
| 170 | long double cbrtl(long double x); |
| 171 | |
| 172 | floating_point copysign (arithmetic x, arithmetic y); |
| 173 | float copysignf(float x, float y); |
| 174 | long double copysignl(long double x, long double y); |
| 175 | |
| 176 | floating_point erf (arithmetic x); |
| 177 | float erff(float x); |
| 178 | long double erfl(long double x); |
| 179 | |
| 180 | floating_point erfc (arithmetic x); |
| 181 | float erfcf(float x); |
| 182 | long double erfcl(long double x); |
| 183 | |
| 184 | floating_point exp2 (arithmetic x); |
| 185 | float exp2f(float x); |
| 186 | long double exp2l(long double x); |
| 187 | |
| 188 | floating_point expm1 (arithmetic x); |
| 189 | float expm1f(float x); |
| 190 | long double expm1l(long double x); |
| 191 | |
| 192 | floating_point fdim (arithmetic x, arithmetic y); |
| 193 | float fdimf(float x, float y); |
| 194 | long double fdiml(long double x, long double y); |
| 195 | |
| 196 | floating_point fma (arithmetic x, arithmetic y, arithmetic z); |
| 197 | float fmaf(float x, float y, float z); |
| 198 | long double fmal(long double x, long double y, long double z); |
| 199 | |
| 200 | floating_point fmax (arithmetic x, arithmetic y); |
| 201 | float fmaxf(float x, float y); |
| 202 | long double fmaxl(long double x, long double y); |
| 203 | |
| 204 | floating_point fmin (arithmetic x, arithmetic y); |
| 205 | float fminf(float x, float y); |
| 206 | long double fminl(long double x, long double y); |
| 207 | |
| 208 | floating_point hypot (arithmetic x, arithmetic y); |
| 209 | float hypotf(float x, float y); |
| 210 | long double hypotl(long double x, long double y); |
| 211 | |
Marshall Clow | 2c15439 | 2016-05-17 14:52:19 +0000 | [diff] [blame] | 212 | double hypot(double x, double y, double z); // C++17 |
| 213 | float hypot(float x, float y, float z); // C++17 |
| 214 | long double hypot(long double x, long double y, long double z); // C++17 |
| 215 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 216 | int ilogb (arithmetic x); |
| 217 | int ilogbf(float x); |
| 218 | int ilogbl(long double x); |
| 219 | |
| 220 | floating_point lgamma (arithmetic x); |
| 221 | float lgammaf(float x); |
| 222 | long double lgammal(long double x); |
| 223 | |
| 224 | long long llrint (arithmetic x); |
| 225 | long long llrintf(float x); |
| 226 | long long llrintl(long double x); |
| 227 | |
| 228 | long long llround (arithmetic x); |
| 229 | long long llroundf(float x); |
| 230 | long long llroundl(long double x); |
| 231 | |
| 232 | floating_point log1p (arithmetic x); |
| 233 | float log1pf(float x); |
| 234 | long double log1pl(long double x); |
| 235 | |
| 236 | floating_point log2 (arithmetic x); |
| 237 | float log2f(float x); |
| 238 | long double log2l(long double x); |
| 239 | |
| 240 | floating_point logb (arithmetic x); |
| 241 | float logbf(float x); |
| 242 | long double logbl(long double x); |
| 243 | |
| 244 | long lrint (arithmetic x); |
| 245 | long lrintf(float x); |
| 246 | long lrintl(long double x); |
| 247 | |
| 248 | long lround (arithmetic x); |
| 249 | long lroundf(float x); |
| 250 | long lroundl(long double x); |
| 251 | |
| 252 | double nan (const char* str); |
| 253 | float nanf(const char* str); |
| 254 | long double nanl(const char* str); |
| 255 | |
| 256 | floating_point nearbyint (arithmetic x); |
| 257 | float nearbyintf(float x); |
| 258 | long double nearbyintl(long double x); |
| 259 | |
| 260 | floating_point nextafter (arithmetic x, arithmetic y); |
| 261 | float nextafterf(float x, float y); |
| 262 | long double nextafterl(long double x, long double y); |
| 263 | |
| 264 | floating_point nexttoward (arithmetic x, long double y); |
| 265 | float nexttowardf(float x, long double y); |
| 266 | long double nexttowardl(long double x, long double y); |
| 267 | |
| 268 | floating_point remainder (arithmetic x, arithmetic y); |
| 269 | float remainderf(float x, float y); |
| 270 | long double remainderl(long double x, long double y); |
| 271 | |
| 272 | floating_point remquo (arithmetic x, arithmetic y, int* pquo); |
| 273 | float remquof(float x, float y, int* pquo); |
| 274 | long double remquol(long double x, long double y, int* pquo); |
| 275 | |
| 276 | floating_point rint (arithmetic x); |
| 277 | float rintf(float x); |
| 278 | long double rintl(long double x); |
| 279 | |
| 280 | floating_point round (arithmetic x); |
| 281 | float roundf(float x); |
| 282 | long double roundl(long double x); |
| 283 | |
| 284 | floating_point scalbln (arithmetic x, long ex); |
| 285 | float scalblnf(float x, long ex); |
| 286 | long double scalblnl(long double x, long ex); |
| 287 | |
| 288 | floating_point scalbn (arithmetic x, int ex); |
| 289 | float scalbnf(float x, int ex); |
| 290 | long double scalbnl(long double x, int ex); |
| 291 | |
| 292 | floating_point tgamma (arithmetic x); |
| 293 | float tgammaf(float x); |
| 294 | long double tgammal(long double x); |
| 295 | |
| 296 | floating_point trunc (arithmetic x); |
| 297 | float truncf(float x); |
| 298 | long double truncl(long double x); |
| 299 | |
| 300 | } // std |
| 301 | |
| 302 | */ |
| 303 | |
| 304 | #include <__config> |
| 305 | #include <math.h> |
Marshall Clow | e3973fd | 2018-09-12 19:41:40 +0000 | [diff] [blame^] | 306 | #include <version> |
Howard Hinnant | 9f8884e | 2011-10-27 16:24:42 +0000 | [diff] [blame] | 307 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 308 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 309 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 310 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 311 | |
| 312 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 313 | |
Howard Hinnant | 0a11111 | 2011-05-13 21:52:40 +0000 | [diff] [blame] | 314 | using ::signbit; |
| 315 | using ::fpclassify; |
| 316 | using ::isfinite; |
| 317 | using ::isinf; |
| 318 | using ::isnan; |
| 319 | using ::isnormal; |
| 320 | using ::isgreater; |
| 321 | using ::isgreaterequal; |
| 322 | using ::isless; |
| 323 | using ::islessequal; |
| 324 | using ::islessgreater; |
| 325 | using ::isunordered; |
| 326 | using ::isunordered; |
| 327 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 328 | using ::float_t; |
| 329 | using ::double_t; |
| 330 | |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 331 | #ifndef _AIX |
Eric Fiselier | 0b6f8ed | 2015-03-18 15:24:18 +0000 | [diff] [blame] | 332 | using ::abs; |
| 333 | #endif |
| 334 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 335 | using ::acos; |
| 336 | using ::acosf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 337 | using ::asin; |
| 338 | using ::asinf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 339 | using ::atan; |
| 340 | using ::atanf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 341 | using ::atan2; |
| 342 | using ::atan2f; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 343 | using ::ceil; |
| 344 | using ::ceilf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 345 | using ::cos; |
| 346 | using ::cosf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 347 | using ::cosh; |
| 348 | using ::coshf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 349 | |
| 350 | using ::exp; |
| 351 | using ::expf; |
| 352 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 353 | using ::fabs; |
| 354 | using ::fabsf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 355 | using ::floor; |
| 356 | using ::floorf; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 357 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 358 | using ::fmod; |
| 359 | using ::fmodf; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 360 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 361 | using ::frexp; |
| 362 | using ::frexpf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 363 | using ::ldexp; |
| 364 | using ::ldexpf; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 365 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 366 | using ::log; |
| 367 | using ::logf; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 368 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 369 | using ::log10; |
| 370 | using ::log10f; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 371 | using ::modf; |
| 372 | using ::modff; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 373 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 374 | using ::pow; |
| 375 | using ::powf; |
| 376 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 377 | using ::sin; |
| 378 | using ::sinf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 379 | using ::sinh; |
| 380 | using ::sinhf; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 381 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 382 | using ::sqrt; |
| 383 | using ::sqrtf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 384 | using ::tan; |
| 385 | using ::tanf; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 386 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 387 | using ::tanh; |
| 388 | using ::tanhf; |
| 389 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 390 | using ::acosh; |
| 391 | using ::acoshf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 392 | using ::asinh; |
| 393 | using ::asinhf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 394 | using ::atanh; |
| 395 | using ::atanhf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 396 | using ::cbrt; |
| 397 | using ::cbrtf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 398 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 399 | using ::copysign; |
| 400 | using ::copysignf; |
| 401 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 402 | using ::erf; |
| 403 | using ::erff; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 404 | using ::erfc; |
| 405 | using ::erfcf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 406 | using ::exp2; |
| 407 | using ::exp2f; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 408 | using ::expm1; |
| 409 | using ::expm1f; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 410 | using ::fdim; |
| 411 | using ::fdimf; |
Marshall Clow | 0d6dcb5 | 2014-03-05 17:09:51 +0000 | [diff] [blame] | 412 | using ::fmaf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 413 | using ::fma; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 414 | using ::fmax; |
| 415 | using ::fmaxf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 416 | using ::fmin; |
| 417 | using ::fminf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 418 | using ::hypot; |
| 419 | using ::hypotf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 420 | using ::ilogb; |
| 421 | using ::ilogbf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 422 | using ::lgamma; |
| 423 | using ::lgammaf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 424 | using ::llrint; |
| 425 | using ::llrintf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 426 | using ::llround; |
| 427 | using ::llroundf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 428 | using ::log1p; |
| 429 | using ::log1pf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 430 | using ::log2; |
| 431 | using ::log2f; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 432 | using ::logb; |
| 433 | using ::logbf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 434 | using ::lrint; |
| 435 | using ::lrintf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 436 | using ::lround; |
| 437 | using ::lroundf; |
Howard Hinnant | e9df0a5 | 2013-08-01 18:17:34 +0000 | [diff] [blame] | 438 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 439 | using ::nan; |
| 440 | using ::nanf; |
Howard Hinnant | e9df0a5 | 2013-08-01 18:17:34 +0000 | [diff] [blame] | 441 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 442 | using ::nearbyint; |
| 443 | using ::nearbyintf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 444 | using ::nextafter; |
| 445 | using ::nextafterf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 446 | using ::nexttoward; |
| 447 | using ::nexttowardf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 448 | using ::remainder; |
| 449 | using ::remainderf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 450 | using ::remquo; |
| 451 | using ::remquof; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 452 | using ::rint; |
| 453 | using ::rintf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 454 | using ::round; |
| 455 | using ::roundf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 456 | using ::scalbln; |
| 457 | using ::scalblnf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 458 | using ::scalbn; |
| 459 | using ::scalbnf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 460 | using ::tgamma; |
| 461 | using ::tgammaf; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 462 | using ::trunc; |
| 463 | using ::truncf; |
Howard Hinnant | 9f8884e | 2011-10-27 16:24:42 +0000 | [diff] [blame] | 464 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 465 | using ::acosl; |
| 466 | using ::asinl; |
| 467 | using ::atanl; |
| 468 | using ::atan2l; |
| 469 | using ::ceill; |
| 470 | using ::cosl; |
| 471 | using ::coshl; |
| 472 | using ::expl; |
| 473 | using ::fabsl; |
| 474 | using ::floorl; |
| 475 | using ::fmodl; |
| 476 | using ::frexpl; |
| 477 | using ::ldexpl; |
| 478 | using ::logl; |
| 479 | using ::log10l; |
| 480 | using ::modfl; |
| 481 | using ::powl; |
| 482 | using ::sinl; |
| 483 | using ::sinhl; |
| 484 | using ::sqrtl; |
| 485 | using ::tanl; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 486 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 487 | using ::tanhl; |
| 488 | using ::acoshl; |
| 489 | using ::asinhl; |
| 490 | using ::atanhl; |
| 491 | using ::cbrtl; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 492 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 493 | using ::copysignl; |
Richard Smith | 4faa394 | 2015-10-08 20:40:34 +0000 | [diff] [blame] | 494 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 495 | using ::erfl; |
| 496 | using ::erfcl; |
| 497 | using ::exp2l; |
| 498 | using ::expm1l; |
| 499 | using ::fdiml; |
| 500 | using ::fmal; |
| 501 | using ::fmaxl; |
| 502 | using ::fminl; |
| 503 | using ::hypotl; |
| 504 | using ::ilogbl; |
| 505 | using ::lgammal; |
| 506 | using ::llrintl; |
| 507 | using ::llroundl; |
| 508 | using ::log1pl; |
| 509 | using ::log2l; |
| 510 | using ::logbl; |
| 511 | using ::lrintl; |
| 512 | using ::lroundl; |
| 513 | using ::nanl; |
| 514 | using ::nearbyintl; |
| 515 | using ::nextafterl; |
| 516 | using ::nexttowardl; |
| 517 | using ::remainderl; |
| 518 | using ::remquol; |
| 519 | using ::rintl; |
| 520 | using ::roundl; |
| 521 | using ::scalblnl; |
| 522 | using ::scalbnl; |
| 523 | using ::tgammal; |
| 524 | using ::truncl; |
| 525 | |
Marshall Clow | 2c15439 | 2016-05-17 14:52:19 +0000 | [diff] [blame] | 526 | #if _LIBCPP_STD_VER > 14 |
| 527 | inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); } |
| 528 | inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); } |
| 529 | inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); } |
| 530 | |
| 531 | template <class _A1, class _A2, class _A3> |
| 532 | inline _LIBCPP_INLINE_VISIBILITY |
Hal Finkel | d24aba4 | 2016-10-01 20:38:44 +0000 | [diff] [blame] | 533 | typename __lazy_enable_if |
Marshall Clow | 2c15439 | 2016-05-17 14:52:19 +0000 | [diff] [blame] | 534 | < |
Hal Finkel | d24aba4 | 2016-10-01 20:38:44 +0000 | [diff] [blame] | 535 | is_arithmetic<_A1>::value && |
| 536 | is_arithmetic<_A2>::value && |
| 537 | is_arithmetic<_A3>::value, |
| 538 | __promote<_A1, _A2, _A3> |
Marshall Clow | 2c15439 | 2016-05-17 14:52:19 +0000 | [diff] [blame] | 539 | >::type |
| 540 | hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT |
| 541 | { |
Hal Finkel | d24aba4 | 2016-10-01 20:38:44 +0000 | [diff] [blame] | 542 | typedef typename __promote<_A1, _A2, _A3>::type __result_type; |
| 543 | static_assert((!(is_same<_A1, __result_type>::value && |
| 544 | is_same<_A2, __result_type>::value && |
| 545 | is_same<_A3, __result_type>::value)), ""); |
Marshall Clow | 2c15439 | 2016-05-17 14:52:19 +0000 | [diff] [blame] | 546 | return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); |
| 547 | } |
| 548 | #endif |
| 549 | |
Hal Finkel | 970af07 | 2016-10-01 20:38:31 +0000 | [diff] [blame] | 550 | template <class _A1> |
Louis Dionne | 5423805 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 551 | _LIBCPP_INLINE_VISIBILITY |
Justin Lebar | bb835ac | 2016-11-15 19:15:57 +0000 | [diff] [blame] | 552 | _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type |
Duncan P. N. Exon Smith | e452f6a | 2017-07-07 05:13:36 +0000 | [diff] [blame] | 553 | __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT |
Hal Finkel | 970af07 | 2016-10-01 20:38:31 +0000 | [diff] [blame] | 554 | { |
| 555 | #if __has_builtin(__builtin_isnan) |
| 556 | return __builtin_isnan(__lcpp_x); |
| 557 | #else |
| 558 | return isnan(__lcpp_x); |
| 559 | #endif |
| 560 | } |
| 561 | |
| 562 | template <class _A1> |
Louis Dionne | 5423805 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 563 | _LIBCPP_INLINE_VISIBILITY |
Justin Lebar | bb835ac | 2016-11-15 19:15:57 +0000 | [diff] [blame] | 564 | _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type |
Duncan P. N. Exon Smith | e452f6a | 2017-07-07 05:13:36 +0000 | [diff] [blame] | 565 | __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT |
Hal Finkel | 970af07 | 2016-10-01 20:38:31 +0000 | [diff] [blame] | 566 | { |
| 567 | return isnan(__lcpp_x); |
| 568 | } |
| 569 | |
| 570 | template <class _A1> |
Louis Dionne | 5423805 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 571 | _LIBCPP_INLINE_VISIBILITY |
Justin Lebar | bb835ac | 2016-11-15 19:15:57 +0000 | [diff] [blame] | 572 | _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type |
Duncan P. N. Exon Smith | e452f6a | 2017-07-07 05:13:36 +0000 | [diff] [blame] | 573 | __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT |
Hal Finkel | 970af07 | 2016-10-01 20:38:31 +0000 | [diff] [blame] | 574 | { |
| 575 | #if __has_builtin(__builtin_isinf) |
| 576 | return __builtin_isinf(__lcpp_x); |
| 577 | #else |
| 578 | return isinf(__lcpp_x); |
| 579 | #endif |
| 580 | } |
| 581 | |
| 582 | template <class _A1> |
Louis Dionne | 5423805 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 583 | _LIBCPP_INLINE_VISIBILITY |
Justin Lebar | bb835ac | 2016-11-15 19:15:57 +0000 | [diff] [blame] | 584 | _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type |
Duncan P. N. Exon Smith | e452f6a | 2017-07-07 05:13:36 +0000 | [diff] [blame] | 585 | __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT |
Hal Finkel | 970af07 | 2016-10-01 20:38:31 +0000 | [diff] [blame] | 586 | { |
| 587 | return isinf(__lcpp_x); |
| 588 | } |
| 589 | |
| 590 | template <class _A1> |
Louis Dionne | 5423805 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 591 | _LIBCPP_INLINE_VISIBILITY |
Justin Lebar | bb835ac | 2016-11-15 19:15:57 +0000 | [diff] [blame] | 592 | _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type |
Duncan P. N. Exon Smith | e452f6a | 2017-07-07 05:13:36 +0000 | [diff] [blame] | 593 | __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT |
Hal Finkel | 970af07 | 2016-10-01 20:38:31 +0000 | [diff] [blame] | 594 | { |
| 595 | #if __has_builtin(__builtin_isfinite) |
| 596 | return __builtin_isfinite(__lcpp_x); |
| 597 | #else |
| 598 | return isfinite(__lcpp_x); |
| 599 | #endif |
| 600 | } |
| 601 | |
| 602 | template <class _A1> |
Louis Dionne | 5423805 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 603 | _LIBCPP_INLINE_VISIBILITY |
Justin Lebar | bb835ac | 2016-11-15 19:15:57 +0000 | [diff] [blame] | 604 | _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type |
Duncan P. N. Exon Smith | e452f6a | 2017-07-07 05:13:36 +0000 | [diff] [blame] | 605 | __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT |
Hal Finkel | 970af07 | 2016-10-01 20:38:31 +0000 | [diff] [blame] | 606 | { |
| 607 | return isfinite(__lcpp_x); |
| 608 | } |
| 609 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 610 | _LIBCPP_END_NAMESPACE_STD |
| 611 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 612 | #endif // _LIBCPP_CMATH |