| 1 |
// -*- C++ -*- |
| 2 |
//===----------------------------------------------------------------------===// |
| 3 |
// |
| 4 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 |
// See https://llvm.org/LICENSE.txt for license information. |
| 6 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
|
| 10 |
#ifndef _LIBCPP_CMATH |
| 11 |
#define _LIBCPP_CMATH |
| 12 |
|
| 13 |
/* |
| 14 |
cmath synopsis |
| 15 |
|
| 16 |
Macros: |
| 17 |
|
| 18 |
HUGE_VAL |
| 19 |
HUGE_VALF // C99 |
| 20 |
HUGE_VALL // C99 |
| 21 |
INFINITY // C99 |
| 22 |
NAN // C99 |
| 23 |
FP_INFINITE // C99 |
| 24 |
FP_NAN // C99 |
| 25 |
FP_NORMAL // C99 |
| 26 |
FP_SUBNORMAL // C99 |
| 27 |
FP_ZERO // C99 |
| 28 |
FP_FAST_FMA // C99 |
| 29 |
FP_FAST_FMAF // C99 |
| 30 |
FP_FAST_FMAL // C99 |
| 31 |
FP_ILOGB0 // C99 |
| 32 |
FP_ILOGBNAN // C99 |
| 33 |
MATH_ERRNO // C99 |
| 34 |
MATH_ERREXCEPT // C99 |
| 35 |
math_errhandling // C99 |
| 36 |
|
| 37 |
namespace std |
| 38 |
{ |
| 39 |
|
| 40 |
Types: |
| 41 |
|
| 42 |
float_t // C99 |
| 43 |
double_t // C99 |
| 44 |
|
| 45 |
// C90 |
| 46 |
|
| 47 |
floating_point abs(floating_point x); |
| 48 |
|
| 49 |
floating_point acos (arithmetic x); |
| 50 |
float acosf(float x); |
| 51 |
long double acosl(long double x); |
| 52 |
|
| 53 |
floating_point asin (arithmetic x); |
| 54 |
float asinf(float x); |
| 55 |
long double asinl(long double x); |
| 56 |
|
| 57 |
floating_point atan (arithmetic x); |
| 58 |
float atanf(float x); |
| 59 |
long double atanl(long double x); |
| 60 |
|
| 61 |
floating_point atan2 (arithmetic y, arithmetic x); |
| 62 |
float atan2f(float y, float x); |
| 63 |
long double atan2l(long double y, long double x); |
| 64 |
|
| 65 |
floating_point ceil (arithmetic x); |
| 66 |
float ceilf(float x); |
| 67 |
long double ceill(long double x); |
| 68 |
|
| 69 |
floating_point cos (arithmetic x); |
| 70 |
float cosf(float x); |
| 71 |
long double cosl(long double x); |
| 72 |
|
| 73 |
floating_point cosh (arithmetic x); |
| 74 |
float coshf(float x); |
| 75 |
long double coshl(long double x); |
| 76 |
|
| 77 |
floating_point exp (arithmetic x); |
| 78 |
float expf(float x); |
| 79 |
long double expl(long double x); |
| 80 |
|
| 81 |
floating_point fabs (arithmetic x); |
| 82 |
float fabsf(float x); |
| 83 |
long double fabsl(long double x); |
| 84 |
|
| 85 |
floating_point floor (arithmetic x); |
| 86 |
float floorf(float x); |
| 87 |
long double floorl(long double x); |
| 88 |
|
| 89 |
floating_point fmod (arithmetic x, arithmetic y); |
| 90 |
float fmodf(float x, float y); |
| 91 |
long double fmodl(long double x, long double y); |
| 92 |
|
| 93 |
floating_point frexp (arithmetic value, int* exp); |
| 94 |
float frexpf(float value, int* exp); |
| 95 |
long double frexpl(long double value, int* exp); |
| 96 |
|
| 97 |
floating_point ldexp (arithmetic value, int exp); |
| 98 |
float ldexpf(float value, int exp); |
| 99 |
long double ldexpl(long double value, int exp); |
| 100 |
|
| 101 |
floating_point log (arithmetic x); |
| 102 |
float logf(float x); |
| 103 |
long double logl(long double x); |
| 104 |
|
| 105 |
floating_point log10 (arithmetic x); |
| 106 |
float log10f(float x); |
| 107 |
long double log10l(long double x); |
| 108 |
|
| 109 |
floating_point modf (floating_point value, floating_point* iptr); |
| 110 |
float modff(float value, float* iptr); |
| 111 |
long double modfl(long double value, long double* iptr); |
| 112 |
|
| 113 |
floating_point pow (arithmetic x, arithmetic y); |
| 114 |
float powf(float x, float y); |
| 115 |
long double powl(long double x, long double y); |
| 116 |
|
| 117 |
floating_point sin (arithmetic x); |
| 118 |
float sinf(float x); |
| 119 |
long double sinl(long double x); |
| 120 |
|
| 121 |
floating_point sinh (arithmetic x); |
| 122 |
float sinhf(float x); |
| 123 |
long double sinhl(long double x); |
| 124 |
|
| 125 |
floating_point sqrt (arithmetic x); |
| 126 |
float sqrtf(float x); |
| 127 |
long double sqrtl(long double x); |
| 128 |
|
| 129 |
floating_point tan (arithmetic x); |
| 130 |
float tanf(float x); |
| 131 |
long double tanl(long double x); |
| 132 |
|
| 133 |
floating_point tanh (arithmetic x); |
| 134 |
float tanhf(float x); |
| 135 |
long double tanhl(long double x); |
| 136 |
|
| 137 |
// C99 |
| 138 |
|
| 139 |
bool signbit(arithmetic x); |
| 140 |
|
| 141 |
int fpclassify(arithmetic x); |
| 142 |
|
| 143 |
bool isfinite(arithmetic x); |
| 144 |
bool isinf(arithmetic x); |
| 145 |
bool isnan(arithmetic x); |
| 146 |
bool isnormal(arithmetic x); |
| 147 |
|
| 148 |
bool isgreater(arithmetic x, arithmetic y); |
| 149 |
bool isgreaterequal(arithmetic x, arithmetic y); |
| 150 |
bool isless(arithmetic x, arithmetic y); |
| 151 |
bool islessequal(arithmetic x, arithmetic y); |
| 152 |
bool islessgreater(arithmetic x, arithmetic y); |
| 153 |
bool isunordered(arithmetic x, arithmetic y); |
| 154 |
|
| 155 |
floating_point acosh (arithmetic x); |
| 156 |
float acoshf(float x); |
| 157 |
long double acoshl(long double x); |
| 158 |
|
| 159 |
floating_point asinh (arithmetic x); |
| 160 |
float asinhf(float x); |
| 161 |
long double asinhl(long double x); |
| 162 |
|
| 163 |
floating_point atanh (arithmetic x); |
| 164 |
float atanhf(float x); |
| 165 |
long double atanhl(long double x); |
| 166 |
|
| 167 |
floating_point cbrt (arithmetic x); |
| 168 |
float cbrtf(float x); |
| 169 |
long double cbrtl(long double x); |
| 170 |
|
| 171 |
floating_point copysign (arithmetic x, arithmetic y); |
| 172 |
float copysignf(float x, float y); |
| 173 |
long double copysignl(long double x, long double y); |
| 174 |
|
| 175 |
floating_point erf (arithmetic x); |
| 176 |
float erff(float x); |
| 177 |
long double erfl(long double x); |
| 178 |
|
| 179 |
floating_point erfc (arithmetic x); |
| 180 |
float erfcf(float x); |
| 181 |
long double erfcl(long double x); |
| 182 |
|
| 183 |
floating_point exp2 (arithmetic x); |
| 184 |
float exp2f(float x); |
| 185 |
long double exp2l(long double x); |
| 186 |
|
| 187 |
floating_point expm1 (arithmetic x); |
| 188 |
float expm1f(float x); |
| 189 |
long double expm1l(long double x); |
| 190 |
|
| 191 |
floating_point fdim (arithmetic x, arithmetic y); |
| 192 |
float fdimf(float x, float y); |
| 193 |
long double fdiml(long double x, long double y); |
| 194 |
|
| 195 |
floating_point fma (arithmetic x, arithmetic y, arithmetic z); |
| 196 |
float fmaf(float x, float y, float z); |
| 197 |
long double fmal(long double x, long double y, long double z); |
| 198 |
|
| 199 |
floating_point fmax (arithmetic x, arithmetic y); |
| 200 |
float fmaxf(float x, float y); |
| 201 |
long double fmaxl(long double x, long double y); |
| 202 |
|
| 203 |
floating_point fmin (arithmetic x, arithmetic y); |
| 204 |
float fminf(float x, float y); |
| 205 |
long double fminl(long double x, long double y); |
| 206 |
|
| 207 |
floating_point hypot (arithmetic x, arithmetic y); |
| 208 |
float hypotf(float x, float y); |
| 209 |
long double hypotl(long double x, long double y); |
| 210 |
|
| 211 |
double hypot(double x, double y, double z); // C++17 |
| 212 |
float hypot(float x, float y, float z); // C++17 |
| 213 |
long double hypot(long double x, long double y, long double z); // C++17 |
| 214 |
|
| 215 |
int ilogb (arithmetic x); |
| 216 |
int ilogbf(float x); |
| 217 |
int ilogbl(long double x); |
| 218 |
|
| 219 |
floating_point lgamma (arithmetic x); |
| 220 |
float lgammaf(float x); |
| 221 |
long double lgammal(long double x); |
| 222 |
|
| 223 |
long long llrint (arithmetic x); |
| 224 |
long long llrintf(float x); |
| 225 |
long long llrintl(long double x); |
| 226 |
|
| 227 |
long long llround (arithmetic x); |
| 228 |
long long llroundf(float x); |
| 229 |
long long llroundl(long double x); |
| 230 |
|
| 231 |
floating_point log1p (arithmetic x); |
| 232 |
float log1pf(float x); |
| 233 |
long double log1pl(long double x); |
| 234 |
|
| 235 |
floating_point log2 (arithmetic x); |
| 236 |
float log2f(float x); |
| 237 |
long double log2l(long double x); |
| 238 |
|
| 239 |
floating_point logb (arithmetic x); |
| 240 |
float logbf(float x); |
| 241 |
long double logbl(long double x); |
| 242 |
|
| 243 |
long lrint (arithmetic x); |
| 244 |
long lrintf(float x); |
| 245 |
long lrintl(long double x); |
| 246 |
|
| 247 |
long lround (arithmetic x); |
| 248 |
long lroundf(float x); |
| 249 |
long lroundl(long double x); |
| 250 |
|
| 251 |
double nan (const char* str); |
| 252 |
float nanf(const char* str); |
| 253 |
long double nanl(const char* str); |
| 254 |
|
| 255 |
floating_point nearbyint (arithmetic x); |
| 256 |
float nearbyintf(float x); |
| 257 |
long double nearbyintl(long double x); |
| 258 |
|
| 259 |
floating_point nextafter (arithmetic x, arithmetic y); |
| 260 |
float nextafterf(float x, float y); |
| 261 |
long double nextafterl(long double x, long double y); |
| 262 |
|
| 263 |
floating_point nexttoward (arithmetic x, long double y); |
| 264 |
float nexttowardf(float x, long double y); |
| 265 |
long double nexttowardl(long double x, long double y); |
| 266 |
|
| 267 |
floating_point remainder (arithmetic x, arithmetic y); |
| 268 |
float remainderf(float x, float y); |
| 269 |
long double remainderl(long double x, long double y); |
| 270 |
|
| 271 |
floating_point remquo (arithmetic x, arithmetic y, int* pquo); |
| 272 |
float remquof(float x, float y, int* pquo); |
| 273 |
long double remquol(long double x, long double y, int* pquo); |
| 274 |
|
| 275 |
floating_point rint (arithmetic x); |
| 276 |
float rintf(float x); |
| 277 |
long double rintl(long double x); |
| 278 |
|
| 279 |
floating_point round (arithmetic x); |
| 280 |
float roundf(float x); |
| 281 |
long double roundl(long double x); |
| 282 |
|
| 283 |
floating_point scalbln (arithmetic x, long ex); |
| 284 |
float scalblnf(float x, long ex); |
| 285 |
long double scalblnl(long double x, long ex); |
| 286 |
|
| 287 |
floating_point scalbn (arithmetic x, int ex); |
| 288 |
float scalbnf(float x, int ex); |
| 289 |
long double scalbnl(long double x, int ex); |
| 290 |
|
| 291 |
floating_point tgamma (arithmetic x); |
| 292 |
float tgammaf(float x); |
| 293 |
long double tgammal(long double x); |
| 294 |
|
| 295 |
floating_point trunc (arithmetic x); |
| 296 |
float truncf(float x); |
| 297 |
long double truncl(long double x); |
| 298 |
|
| 299 |
constexpr float lerp(float a, float b, float t) noexcept; // C++20 |
| 300 |
constexpr double lerp(double a, double b, double t) noexcept; // C++20 |
| 301 |
constexpr long double lerp(long double a, long double b, long double t) noexcept; // C++20 |
| 302 |
|
| 303 |
} // std |
| 304 |
|
| 305 |
*/ |
| 306 |
|
| 307 |
#include <__assert> // all public C++ headers provide the assertion handler |
| 308 |
#include <__config> |
| 309 |
#include <__type_traits/enable_if.h> |
| 310 |
#include <__type_traits/is_arithmetic.h> |
| 311 |
#include <__type_traits/is_constant_evaluated.h> |
| 312 |
#include <__type_traits/is_floating_point.h> |
| 313 |
#include <__type_traits/is_same.h> |
| 314 |
#include <__type_traits/remove_cv.h> |
| 315 |
#include <version> |
| 316 |
|
| 317 |
#include <math.h> |
| 318 |
|
| 319 |
#ifndef _LIBCPP_MATH_H |
| 320 |
# error <cmath> tried including <math.h> but didn't find libc++'s <math.h> header. \ |
| 321 |
This usually means that your header search paths are not configured properly. \ |
| 322 |
The header search paths should contain the C++ Standard Library headers before \ |
| 323 |
any C Standard Library, and you are probably using compiler flags that make that \ |
| 324 |
not be the case. |
| 325 |
#endif |
| 326 |
|
| 327 |
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 328 |
# pragma GCC system_header |
| 329 |
#endif |
| 330 |
|
| 331 |
_LIBCPP_PUSH_MACROS |
| 332 |
#include <__undef_macros> |
| 333 |
|
| 334 |
_LIBCPP_BEGIN_NAMESPACE_STD |
| 335 |
|
| 336 |
using ::signbit _LIBCPP_USING_IF_EXISTS; |
| 337 |
using ::fpclassify _LIBCPP_USING_IF_EXISTS; |
| 338 |
using ::isfinite _LIBCPP_USING_IF_EXISTS; |
| 339 |
using ::isinf _LIBCPP_USING_IF_EXISTS; |
| 340 |
using ::isnan _LIBCPP_USING_IF_EXISTS; |
| 341 |
using ::isnormal _LIBCPP_USING_IF_EXISTS; |
| 342 |
using ::isgreater _LIBCPP_USING_IF_EXISTS; |
| 343 |
using ::isgreaterequal _LIBCPP_USING_IF_EXISTS; |
| 344 |
using ::isless _LIBCPP_USING_IF_EXISTS; |
| 345 |
using ::islessequal _LIBCPP_USING_IF_EXISTS; |
| 346 |
using ::islessgreater _LIBCPP_USING_IF_EXISTS; |
| 347 |
using ::isunordered _LIBCPP_USING_IF_EXISTS; |
| 348 |
using ::isunordered _LIBCPP_USING_IF_EXISTS; |
| 349 |
|
| 350 |
using ::float_t _LIBCPP_USING_IF_EXISTS; |
| 351 |
using ::double_t _LIBCPP_USING_IF_EXISTS; |
| 352 |
|
| 353 |
using ::abs _LIBCPP_USING_IF_EXISTS; |
| 354 |
|
| 355 |
using ::acos _LIBCPP_USING_IF_EXISTS; |
| 356 |
using ::acosf _LIBCPP_USING_IF_EXISTS; |
| 357 |
using ::asin _LIBCPP_USING_IF_EXISTS; |
| 358 |
using ::asinf _LIBCPP_USING_IF_EXISTS; |
| 359 |
using ::atan _LIBCPP_USING_IF_EXISTS; |
| 360 |
using ::atanf _LIBCPP_USING_IF_EXISTS; |
| 361 |
using ::atan2 _LIBCPP_USING_IF_EXISTS; |
| 362 |
using ::atan2f _LIBCPP_USING_IF_EXISTS; |
| 363 |
using ::ceil _LIBCPP_USING_IF_EXISTS; |
| 364 |
using ::ceilf _LIBCPP_USING_IF_EXISTS; |
| 365 |
using ::cos _LIBCPP_USING_IF_EXISTS; |
| 366 |
using ::cosf _LIBCPP_USING_IF_EXISTS; |
| 367 |
using ::cosh _LIBCPP_USING_IF_EXISTS; |
| 368 |
using ::coshf _LIBCPP_USING_IF_EXISTS; |
| 369 |
|
| 370 |
using ::exp _LIBCPP_USING_IF_EXISTS; |
| 371 |
using ::expf _LIBCPP_USING_IF_EXISTS; |
| 372 |
|
| 373 |
using ::fabs _LIBCPP_USING_IF_EXISTS; |
| 374 |
using ::fabsf _LIBCPP_USING_IF_EXISTS; |
| 375 |
using ::floor _LIBCPP_USING_IF_EXISTS; |
| 376 |
using ::floorf _LIBCPP_USING_IF_EXISTS; |
| 377 |
|
| 378 |
using ::fmod _LIBCPP_USING_IF_EXISTS; |
| 379 |
using ::fmodf _LIBCPP_USING_IF_EXISTS; |
| 380 |
|
| 381 |
using ::frexp _LIBCPP_USING_IF_EXISTS; |
| 382 |
using ::frexpf _LIBCPP_USING_IF_EXISTS; |
| 383 |
using ::ldexp _LIBCPP_USING_IF_EXISTS; |
| 384 |
using ::ldexpf _LIBCPP_USING_IF_EXISTS; |
| 385 |
|
| 386 |
using ::log _LIBCPP_USING_IF_EXISTS; |
| 387 |
using ::logf _LIBCPP_USING_IF_EXISTS; |
| 388 |
|
| 389 |
using ::log10 _LIBCPP_USING_IF_EXISTS; |
| 390 |
using ::log10f _LIBCPP_USING_IF_EXISTS; |
| 391 |
using ::modf _LIBCPP_USING_IF_EXISTS; |
| 392 |
using ::modff _LIBCPP_USING_IF_EXISTS; |
| 393 |
|
| 394 |
using ::pow _LIBCPP_USING_IF_EXISTS; |
| 395 |
using ::powf _LIBCPP_USING_IF_EXISTS; |
| 396 |
|
| 397 |
using ::sin _LIBCPP_USING_IF_EXISTS; |
| 398 |
using ::sinf _LIBCPP_USING_IF_EXISTS; |
| 399 |
using ::sinh _LIBCPP_USING_IF_EXISTS; |
| 400 |
using ::sinhf _LIBCPP_USING_IF_EXISTS; |
| 401 |
|
| 402 |
using ::sqrt _LIBCPP_USING_IF_EXISTS; |
| 403 |
using ::sqrtf _LIBCPP_USING_IF_EXISTS; |
| 404 |
using ::tan _LIBCPP_USING_IF_EXISTS; |
| 405 |
using ::tanf _LIBCPP_USING_IF_EXISTS; |
| 406 |
|
| 407 |
using ::tanh _LIBCPP_USING_IF_EXISTS; |
| 408 |
using ::tanhf _LIBCPP_USING_IF_EXISTS; |
| 409 |
|
| 410 |
using ::acosh _LIBCPP_USING_IF_EXISTS; |
| 411 |
using ::acoshf _LIBCPP_USING_IF_EXISTS; |
| 412 |
using ::asinh _LIBCPP_USING_IF_EXISTS; |
| 413 |
using ::asinhf _LIBCPP_USING_IF_EXISTS; |
| 414 |
using ::atanh _LIBCPP_USING_IF_EXISTS; |
| 415 |
using ::atanhf _LIBCPP_USING_IF_EXISTS; |
| 416 |
using ::cbrt _LIBCPP_USING_IF_EXISTS; |
| 417 |
using ::cbrtf _LIBCPP_USING_IF_EXISTS; |
| 418 |
|
| 419 |
using ::copysign _LIBCPP_USING_IF_EXISTS; |
| 420 |
using ::copysignf _LIBCPP_USING_IF_EXISTS; |
| 421 |
|
| 422 |
using ::erf _LIBCPP_USING_IF_EXISTS; |
| 423 |
using ::erff _LIBCPP_USING_IF_EXISTS; |
| 424 |
using ::erfc _LIBCPP_USING_IF_EXISTS; |
| 425 |
using ::erfcf _LIBCPP_USING_IF_EXISTS; |
| 426 |
using ::exp2 _LIBCPP_USING_IF_EXISTS; |
| 427 |
using ::exp2f _LIBCPP_USING_IF_EXISTS; |
| 428 |
using ::expm1 _LIBCPP_USING_IF_EXISTS; |
| 429 |
using ::expm1f _LIBCPP_USING_IF_EXISTS; |
| 430 |
using ::fdim _LIBCPP_USING_IF_EXISTS; |
| 431 |
using ::fdimf _LIBCPP_USING_IF_EXISTS; |
| 432 |
using ::fmaf _LIBCPP_USING_IF_EXISTS; |
| 433 |
using ::fma _LIBCPP_USING_IF_EXISTS; |
| 434 |
using ::fmax _LIBCPP_USING_IF_EXISTS; |
| 435 |
using ::fmaxf _LIBCPP_USING_IF_EXISTS; |
| 436 |
using ::fmin _LIBCPP_USING_IF_EXISTS; |
| 437 |
using ::fminf _LIBCPP_USING_IF_EXISTS; |
| 438 |
using ::hypot _LIBCPP_USING_IF_EXISTS; |
| 439 |
using ::hypotf _LIBCPP_USING_IF_EXISTS; |
| 440 |
using ::ilogb _LIBCPP_USING_IF_EXISTS; |
| 441 |
using ::ilogbf _LIBCPP_USING_IF_EXISTS; |
| 442 |
using ::lgamma _LIBCPP_USING_IF_EXISTS; |
| 443 |
using ::lgammaf _LIBCPP_USING_IF_EXISTS; |
| 444 |
using ::llrint _LIBCPP_USING_IF_EXISTS; |
| 445 |
using ::llrintf _LIBCPP_USING_IF_EXISTS; |
| 446 |
using ::llround _LIBCPP_USING_IF_EXISTS; |
| 447 |
using ::llroundf _LIBCPP_USING_IF_EXISTS; |
| 448 |
using ::log1p _LIBCPP_USING_IF_EXISTS; |
| 449 |
using ::log1pf _LIBCPP_USING_IF_EXISTS; |
| 450 |
using ::log2 _LIBCPP_USING_IF_EXISTS; |
| 451 |
using ::log2f _LIBCPP_USING_IF_EXISTS; |
| 452 |
using ::logb _LIBCPP_USING_IF_EXISTS; |
| 453 |
using ::logbf _LIBCPP_USING_IF_EXISTS; |
| 454 |
using ::lrint _LIBCPP_USING_IF_EXISTS; |
| 455 |
using ::lrintf _LIBCPP_USING_IF_EXISTS; |
| 456 |
using ::lround _LIBCPP_USING_IF_EXISTS; |
| 457 |
using ::lroundf _LIBCPP_USING_IF_EXISTS; |
| 458 |
|
| 459 |
using ::nan _LIBCPP_USING_IF_EXISTS; |
| 460 |
using ::nanf _LIBCPP_USING_IF_EXISTS; |
| 461 |
|
| 462 |
using ::nearbyint _LIBCPP_USING_IF_EXISTS; |
| 463 |
using ::nearbyintf _LIBCPP_USING_IF_EXISTS; |
| 464 |
using ::nextafter _LIBCPP_USING_IF_EXISTS; |
| 465 |
using ::nextafterf _LIBCPP_USING_IF_EXISTS; |
| 466 |
using ::nexttoward _LIBCPP_USING_IF_EXISTS; |
| 467 |
using ::nexttowardf _LIBCPP_USING_IF_EXISTS; |
| 468 |
using ::remainder _LIBCPP_USING_IF_EXISTS; |
| 469 |
using ::remainderf _LIBCPP_USING_IF_EXISTS; |
| 470 |
using ::remquo _LIBCPP_USING_IF_EXISTS; |
| 471 |
using ::remquof _LIBCPP_USING_IF_EXISTS; |
| 472 |
using ::rint _LIBCPP_USING_IF_EXISTS; |
| 473 |
using ::rintf _LIBCPP_USING_IF_EXISTS; |
| 474 |
using ::round _LIBCPP_USING_IF_EXISTS; |
| 475 |
using ::roundf _LIBCPP_USING_IF_EXISTS; |
| 476 |
using ::scalbln _LIBCPP_USING_IF_EXISTS; |
| 477 |
using ::scalblnf _LIBCPP_USING_IF_EXISTS; |
| 478 |
using ::scalbn _LIBCPP_USING_IF_EXISTS; |
| 479 |
using ::scalbnf _LIBCPP_USING_IF_EXISTS; |
| 480 |
using ::tgamma _LIBCPP_USING_IF_EXISTS; |
| 481 |
using ::tgammaf _LIBCPP_USING_IF_EXISTS; |
| 482 |
using ::trunc _LIBCPP_USING_IF_EXISTS; |
| 483 |
using ::truncf _LIBCPP_USING_IF_EXISTS; |
| 484 |
|
| 485 |
using ::acosl _LIBCPP_USING_IF_EXISTS; |
| 486 |
using ::asinl _LIBCPP_USING_IF_EXISTS; |
| 487 |
using ::atanl _LIBCPP_USING_IF_EXISTS; |
| 488 |
using ::atan2l _LIBCPP_USING_IF_EXISTS; |
| 489 |
using ::ceill _LIBCPP_USING_IF_EXISTS; |
| 490 |
using ::cosl _LIBCPP_USING_IF_EXISTS; |
| 491 |
using ::coshl _LIBCPP_USING_IF_EXISTS; |
| 492 |
using ::expl _LIBCPP_USING_IF_EXISTS; |
| 493 |
using ::fabsl _LIBCPP_USING_IF_EXISTS; |
| 494 |
using ::floorl _LIBCPP_USING_IF_EXISTS; |
| 495 |
using ::fmodl _LIBCPP_USING_IF_EXISTS; |
| 496 |
using ::frexpl _LIBCPP_USING_IF_EXISTS; |
| 497 |
using ::ldexpl _LIBCPP_USING_IF_EXISTS; |
| 498 |
using ::logl _LIBCPP_USING_IF_EXISTS; |
| 499 |
using ::log10l _LIBCPP_USING_IF_EXISTS; |
| 500 |
using ::modfl _LIBCPP_USING_IF_EXISTS; |
| 501 |
using ::powl _LIBCPP_USING_IF_EXISTS; |
| 502 |
using ::sinl _LIBCPP_USING_IF_EXISTS; |
| 503 |
using ::sinhl _LIBCPP_USING_IF_EXISTS; |
| 504 |
using ::sqrtl _LIBCPP_USING_IF_EXISTS; |
| 505 |
using ::tanl _LIBCPP_USING_IF_EXISTS; |
| 506 |
|
| 507 |
using ::tanhl _LIBCPP_USING_IF_EXISTS; |
| 508 |
using ::acoshl _LIBCPP_USING_IF_EXISTS; |
| 509 |
using ::asinhl _LIBCPP_USING_IF_EXISTS; |
| 510 |
using ::atanhl _LIBCPP_USING_IF_EXISTS; |
| 511 |
using ::cbrtl _LIBCPP_USING_IF_EXISTS; |
| 512 |
|
| 513 |
using ::copysignl _LIBCPP_USING_IF_EXISTS; |
| 514 |
|
| 515 |
using ::erfl _LIBCPP_USING_IF_EXISTS; |
| 516 |
using ::erfcl _LIBCPP_USING_IF_EXISTS; |
| 517 |
using ::exp2l _LIBCPP_USING_IF_EXISTS; |
| 518 |
using ::expm1l _LIBCPP_USING_IF_EXISTS; |
| 519 |
using ::fdiml _LIBCPP_USING_IF_EXISTS; |
| 520 |
using ::fmal _LIBCPP_USING_IF_EXISTS; |
| 521 |
using ::fmaxl _LIBCPP_USING_IF_EXISTS; |
| 522 |
using ::fminl _LIBCPP_USING_IF_EXISTS; |
| 523 |
using ::hypotl _LIBCPP_USING_IF_EXISTS; |
| 524 |
using ::ilogbl _LIBCPP_USING_IF_EXISTS; |
| 525 |
using ::lgammal _LIBCPP_USING_IF_EXISTS; |
| 526 |
using ::llrintl _LIBCPP_USING_IF_EXISTS; |
| 527 |
using ::llroundl _LIBCPP_USING_IF_EXISTS; |
| 528 |
using ::log1pl _LIBCPP_USING_IF_EXISTS; |
| 529 |
using ::log2l _LIBCPP_USING_IF_EXISTS; |
| 530 |
using ::logbl _LIBCPP_USING_IF_EXISTS; |
| 531 |
using ::lrintl _LIBCPP_USING_IF_EXISTS; |
| 532 |
using ::lroundl _LIBCPP_USING_IF_EXISTS; |
| 533 |
using ::nanl _LIBCPP_USING_IF_EXISTS; |
| 534 |
using ::nearbyintl _LIBCPP_USING_IF_EXISTS; |
| 535 |
using ::nextafterl _LIBCPP_USING_IF_EXISTS; |
| 536 |
using ::nexttowardl _LIBCPP_USING_IF_EXISTS; |
| 537 |
using ::remainderl _LIBCPP_USING_IF_EXISTS; |
| 538 |
using ::remquol _LIBCPP_USING_IF_EXISTS; |
| 539 |
using ::rintl _LIBCPP_USING_IF_EXISTS; |
| 540 |
using ::roundl _LIBCPP_USING_IF_EXISTS; |
| 541 |
using ::scalblnl _LIBCPP_USING_IF_EXISTS; |
| 542 |
using ::scalbnl _LIBCPP_USING_IF_EXISTS; |
| 543 |
using ::tgammal _LIBCPP_USING_IF_EXISTS; |
| 544 |
using ::truncl _LIBCPP_USING_IF_EXISTS; |
| 545 |
|
| 546 |
#if _LIBCPP_STD_VER > 14 |
| 547 |
inline _LIBCPP_INLINE_VISIBILITY float hypot( float __x, float __y, float __z ) { return sqrt(__x*__x + __y*__y + __z*__z); } |
| 548 |
inline _LIBCPP_INLINE_VISIBILITY double hypot( double __x, double __y, double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); } |
| 549 |
inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double __x, long double __y, long double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); } |
| 550 |
|
| 551 |
template <class _A1, class _A2, class _A3> |
| 552 |
inline _LIBCPP_INLINE_VISIBILITY |
| 553 |
typename enable_if_t |
| 554 |
< |
| 555 |
is_arithmetic<_A1>::value && |
| 556 |
is_arithmetic<_A2>::value && |
| 557 |
is_arithmetic<_A3>::value, |
| 558 |
__promote<_A1, _A2, _A3> |
| 559 |
>::type |
| 560 |
hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT |
| 561 |
{ |
| 562 |
typedef typename __promote<_A1, _A2, _A3>::type __result_type; |
| 563 |
static_assert((!(is_same<_A1, __result_type>::value && |
| 564 |
is_same<_A2, __result_type>::value && |
| 565 |
is_same<_A3, __result_type>::value)), ""); |
| 566 |
return std::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); |
| 567 |
} |
| 568 |
#endif |
| 569 |
|
| 570 |
template <class _A1> |
| 571 |
_LIBCPP_INLINE_VISIBILITY |
| 572 |
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type |
| 573 |
__constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT |
| 574 |
{ |
| 575 |
#if __has_builtin(__builtin_isnan) |
| 576 |
return __builtin_isnan(__lcpp_x); |
| 577 |
#else |
| 578 |
return isnan(__lcpp_x); |
| 579 |
#endif |
| 580 |
} |
| 581 |
|
| 582 |
template <class _A1> |
| 583 |
_LIBCPP_INLINE_VISIBILITY |
| 584 |
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type |
| 585 |
__constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT |
| 586 |
{ |
| 587 |
return std::isnan(__lcpp_x); |
| 588 |
} |
| 589 |
|
| 590 |
template <class _A1> |
| 591 |
_LIBCPP_INLINE_VISIBILITY |
| 592 |
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type |
| 593 |
__constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT |
| 594 |
{ |
| 595 |
#if __has_builtin(__builtin_isinf) |
| 596 |
return __builtin_isinf(__lcpp_x); |
| 597 |
#else |
| 598 |
return isinf(__lcpp_x); |
| 599 |
#endif |
| 600 |
} |
| 601 |
|
| 602 |
template <class _A1> |
| 603 |
_LIBCPP_INLINE_VISIBILITY |
| 604 |
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type |
| 605 |
__constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT |
| 606 |
{ |
| 607 |
return std::isinf(__lcpp_x); |
| 608 |
} |
| 609 |
|
| 610 |
template <class _A1> |
| 611 |
_LIBCPP_INLINE_VISIBILITY |
| 612 |
_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type |
| 613 |
__constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT |
| 614 |
{ |
| 615 |
#if __has_builtin(__builtin_isfinite) |
| 616 |
return __builtin_isfinite(__lcpp_x); |
| 617 |
#else |
| 618 |
return isfinite(__lcpp_x); |
| 619 |
#endif |
| 620 |
} |
| 621 |
|
| 622 |
template <class _A1> |
| 623 |
_LIBCPP_INLINE_VISIBILITY |
| 624 |
_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type |
| 625 |
__constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT |
| 626 |
{ |
| 627 |
return __builtin_isfinite(__lcpp_x); |
| 628 |
} |
| 629 |
|
| 630 |
_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI float __constexpr_copysign(float __x, float __y) _NOEXCEPT { |
| 631 |
return __builtin_copysignf(__x, __y); |
| 632 |
} |
| 633 |
|
| 634 |
_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI double __constexpr_copysign(double __x, double __y) _NOEXCEPT { |
| 635 |
return __builtin_copysign(__x, __y); |
| 636 |
} |
| 637 |
|
| 638 |
_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI long double |
| 639 |
__constexpr_copysign(long double __x, long double __y) _NOEXCEPT { |
| 640 |
return __builtin_copysignl(__x, __y); |
| 641 |
} |
| 642 |
|
| 643 |
template <class _A1, class _A2> |
| 644 |
_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI |
| 645 |
typename std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, |
| 646 |
std::__promote<_A1, _A2> >::type |
| 647 |
__constexpr_copysign(_A1 __x, _A2 __y) _NOEXCEPT { |
| 648 |
typedef typename std::__promote<_A1, _A2>::type __result_type; |
| 649 |
static_assert((!(std::_IsSame<_A1, __result_type>::value && std::_IsSame<_A2, __result_type>::value)), ""); |
| 650 |
return __builtin_copysign((__result_type)__x, (__result_type)__y); |
| 651 |
} |
| 652 |
|
| 653 |
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float __constexpr_fabs(float __x) _NOEXCEPT { |
| 654 |
return __builtin_fabsf(__x); |
| 655 |
} |
| 656 |
|
| 657 |
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(double __x) _NOEXCEPT { |
| 658 |
return __builtin_fabs(__x); |
| 659 |
} |
| 660 |
|
| 661 |
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double __constexpr_fabs(long double __x) _NOEXCEPT { |
| 662 |
return __builtin_fabsl(__x); |
| 663 |
} |
| 664 |
|
| 665 |
template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> |
| 666 |
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(_Tp __x) _NOEXCEPT { |
| 667 |
return __builtin_fabs(static_cast<double>(__x)); |
| 668 |
} |
| 669 |
|
| 670 |
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 float __constexpr_fmax(float __x, float __y) _NOEXCEPT { |
| 671 |
#if !__has_constexpr_builtin(__builtin_fmaxf) |
| 672 |
if (__libcpp_is_constant_evaluated()) { |
| 673 |
if (std::__constexpr_isnan(__x)) |
| 674 |
return __y; |
| 675 |
if (std::__constexpr_isnan(__y)) |
| 676 |
return __x; |
| 677 |
return __x < __y ? __y : __x; |
| 678 |
} |
| 679 |
#endif |
| 680 |
return __builtin_fmaxf(__x, __y); |
| 681 |
} |
| 682 |
|
| 683 |
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 double __constexpr_fmax(double __x, double __y) _NOEXCEPT { |
| 684 |
#if !__has_constexpr_builtin(__builtin_fmax) |
| 685 |
if (__libcpp_is_constant_evaluated()) { |
| 686 |
if (std::__constexpr_isnan(__x)) |
| 687 |
return __y; |
| 688 |
if (std::__constexpr_isnan(__y)) |
| 689 |
return __x; |
| 690 |
return __x < __y ? __y : __x; |
| 691 |
} |
| 692 |
#endif |
| 693 |
return __builtin_fmax(__x, __y); |
| 694 |
} |
| 695 |
|
| 696 |
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 long double |
| 697 |
__constexpr_fmax(long double __x, long double __y) _NOEXCEPT { |
| 698 |
#if !__has_constexpr_builtin(__builtin_fmaxl) |
| 699 |
if (__libcpp_is_constant_evaluated()) { |
| 700 |
if (std::__constexpr_isnan(__x)) |
| 701 |
return __y; |
| 702 |
if (std::__constexpr_isnan(__y)) |
| 703 |
return __x; |
| 704 |
return __x < __y ? __y : __x; |
| 705 |
} |
| 706 |
#endif |
| 707 |
return __builtin_fmaxl(__x, __y); |
| 708 |
} |
| 709 |
|
| 710 |
template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_arithmetic<_Up>::value, int> = 0> |
| 711 |
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __promote<_Tp, _Up>::type |
| 712 |
__constexpr_fmax(_Tp __x, _Up __y) _NOEXCEPT { |
| 713 |
using __result_type = typename __promote<_Tp, _Up>::type; |
| 714 |
return std::__constexpr_fmax(static_cast<__result_type>(__x), static_cast<__result_type>(__y)); |
| 715 |
} |
| 716 |
|
| 717 |
template <class _Tp> |
| 718 |
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __constexpr_logb(_Tp __x) { |
| 719 |
#if !__has_constexpr_builtin(__builtin_logb) |
| 720 |
if (__libcpp_is_constant_evaluated()) { |
| 721 |
if (__x == _Tp(0)) { |
| 722 |
// raise FE_DIVBYZERO |
| 723 |
return -numeric_limits<_Tp>::infinity(); |
| 724 |
} |
| 725 |
|
| 726 |
if (std::__constexpr_isinf(__x)) |
| 727 |
return numeric_limits<_Tp>::infinity(); |
| 728 |
|
| 729 |
if (std::__constexpr_isnan(__x)) |
| 730 |
return numeric_limits<_Tp>::quiet_NaN(); |
| 731 |
|
| 732 |
__x = std::__constexpr_fabs(__x); |
| 733 |
unsigned long long __exp = 0; |
| 734 |
while (__x >= numeric_limits<_Tp>::radix) { |
| 735 |
__x /= numeric_limits<_Tp>::radix; |
| 736 |
__exp += 1; |
| 737 |
} |
| 738 |
return _Tp(__exp); |
| 739 |
} |
| 740 |
#endif // !__has_constexpr_builtin(__builtin_logb) |
| 741 |
return __builtin_logb(__x); |
| 742 |
} |
| 743 |
|
| 744 |
template <class _Tp> |
| 745 |
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp __constexpr_scalbn(_Tp __x, int __exp) { |
| 746 |
#if !__has_constexpr_builtin(__builtin_scalbln) |
| 747 |
if (__libcpp_is_constant_evaluated()) { |
| 748 |
if (__x == _Tp(0)) |
| 749 |
return __x; |
| 750 |
|
| 751 |
if (std::__constexpr_isinf(__x)) |
| 752 |
return __x; |
| 753 |
|
| 754 |
if (__exp == _Tp(0)) |
| 755 |
return __x; |
| 756 |
|
| 757 |
if (std::__constexpr_isnan(__x)) |
| 758 |
return numeric_limits<_Tp>::quiet_NaN(); |
| 759 |
|
| 760 |
_Tp __mult(1); |
| 761 |
if (__exp > 0) { |
| 762 |
__mult = numeric_limits<_Tp>::radix; |
| 763 |
--__exp; |
| 764 |
} else { |
| 765 |
++__exp; |
| 766 |
__exp = -__exp; |
| 767 |
__mult /= numeric_limits<_Tp>::radix; |
| 768 |
} |
| 769 |
|
| 770 |
while (__exp > 0) { |
| 771 |
if (!(__exp & 1)) { |
| 772 |
__mult *= __mult; |
| 773 |
__exp >>= 1; |
| 774 |
} else { |
| 775 |
__x *= __mult; |
| 776 |
--__exp; |
| 777 |
} |
| 778 |
} |
| 779 |
return __x; |
| 780 |
} |
| 781 |
#endif // !__has_constexpr_builtin(__builtin_scalbln) |
| 782 |
return __builtin_scalbn(__x, __exp); |
| 783 |
} |
| 784 |
|
| 785 |
#if _LIBCPP_STD_VER > 17 |
| 786 |
template <typename _Fp> |
| 787 |
_LIBCPP_HIDE_FROM_ABI constexpr |
| 788 |
_Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept { |
| 789 |
if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0)) |
| 790 |
return __t * __b + (1 - __t) * __a; |
| 791 |
|
| 792 |
if (__t == 1) return __b; |
| 793 |
const _Fp __x = __a + __t * (__b - __a); |
| 794 |
if ((__t > 1) == (__b > __a)) |
| 795 |
return __b < __x ? __x : __b; |
| 796 |
else |
| 797 |
return __x < __b ? __x : __b; |
| 798 |
} |
| 799 |
|
| 800 |
_LIBCPP_HIDE_FROM_ABI constexpr float |
| 801 |
lerp(float __a, float __b, float __t) _NOEXCEPT { return __lerp(__a, __b, __t); } |
| 802 |
|
| 803 |
_LIBCPP_HIDE_FROM_ABI constexpr double |
| 804 |
lerp(double __a, double __b, double __t) _NOEXCEPT { return __lerp(__a, __b, __t); } |
| 805 |
|
| 806 |
_LIBCPP_HIDE_FROM_ABI constexpr long double |
| 807 |
lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); } |
| 808 |
|
| 809 |
template <class _A1, class _A2, class _A3> |
| 810 |
inline _LIBCPP_HIDE_FROM_ABI |
| 811 |
constexpr typename enable_if_t |
| 812 |
< |
| 813 |
is_arithmetic<_A1>::value && |
| 814 |
is_arithmetic<_A2>::value && |
| 815 |
is_arithmetic<_A3>::value, |
| 816 |
__promote<_A1, _A2, _A3> |
| 817 |
>::type |
| 818 |
lerp(_A1 __a, _A2 __b, _A3 __t) noexcept |
| 819 |
{ |
| 820 |
typedef typename __promote<_A1, _A2, _A3>::type __result_type; |
| 821 |
static_assert(!(_IsSame<_A1, __result_type>::value && |
| 822 |
_IsSame<_A2, __result_type>::value && |
| 823 |
_IsSame<_A3, __result_type>::value)); |
| 824 |
return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t); |
| 825 |
} |
| 826 |
#endif // _LIBCPP_STD_VER > 17 |
| 827 |
|
| 828 |
_LIBCPP_END_NAMESPACE_STD |
| 829 |
|
| 830 |
_LIBCPP_POP_MACROS |
| 831 |
|
| 832 |
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
| 833 |
# include <type_traits> |
| 834 |
#endif |
| 835 |
|
| 836 |
#endif // _LIBCPP_CMATH |