Coverage Report

Created: 2025-08-28 06:28

/src/llvm-project-18.1.8.build/include/c++/v1/cmath
Line
Count
Source (jump to first uncovered line)
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/promote.h>
315
#include <__type_traits/remove_cv.h>
316
#include <limits>
317
#include <version>
318
319
#include <math.h>
320
321
#ifndef _LIBCPP_MATH_H
322
#   error <cmath> tried including <math.h> but didn't find libc++'s <math.h> header. \
323
          This usually means that your header search paths are not configured properly. \
324
          The header search paths should contain the C++ Standard Library headers before \
325
          any C Standard Library, and you are probably using compiler flags that make that \
326
          not be the case.
327
#endif
328
329
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
330
#  pragma GCC system_header
331
#endif
332
333
_LIBCPP_PUSH_MACROS
334
#include <__undef_macros>
335
336
_LIBCPP_BEGIN_NAMESPACE_STD
337
338
using ::signbit _LIBCPP_USING_IF_EXISTS;
339
using ::fpclassify _LIBCPP_USING_IF_EXISTS;
340
using ::isfinite _LIBCPP_USING_IF_EXISTS;
341
using ::isinf _LIBCPP_USING_IF_EXISTS;
342
using ::isnan _LIBCPP_USING_IF_EXISTS;
343
using ::isnormal _LIBCPP_USING_IF_EXISTS;
344
using ::isgreater _LIBCPP_USING_IF_EXISTS;
345
using ::isgreaterequal _LIBCPP_USING_IF_EXISTS;
346
using ::isless _LIBCPP_USING_IF_EXISTS;
347
using ::islessequal _LIBCPP_USING_IF_EXISTS;
348
using ::islessgreater _LIBCPP_USING_IF_EXISTS;
349
using ::isunordered _LIBCPP_USING_IF_EXISTS;
350
using ::isunordered _LIBCPP_USING_IF_EXISTS;
351
352
using ::float_t _LIBCPP_USING_IF_EXISTS;
353
using ::double_t _LIBCPP_USING_IF_EXISTS;
354
355
using ::abs _LIBCPP_USING_IF_EXISTS;
356
357
using ::acos _LIBCPP_USING_IF_EXISTS;
358
using ::acosf _LIBCPP_USING_IF_EXISTS;
359
using ::asin _LIBCPP_USING_IF_EXISTS;
360
using ::asinf _LIBCPP_USING_IF_EXISTS;
361
using ::atan _LIBCPP_USING_IF_EXISTS;
362
using ::atanf _LIBCPP_USING_IF_EXISTS;
363
using ::atan2 _LIBCPP_USING_IF_EXISTS;
364
using ::atan2f _LIBCPP_USING_IF_EXISTS;
365
using ::ceil _LIBCPP_USING_IF_EXISTS;
366
using ::ceilf _LIBCPP_USING_IF_EXISTS;
367
using ::cos _LIBCPP_USING_IF_EXISTS;
368
using ::cosf _LIBCPP_USING_IF_EXISTS;
369
using ::cosh _LIBCPP_USING_IF_EXISTS;
370
using ::coshf _LIBCPP_USING_IF_EXISTS;
371
372
using ::exp _LIBCPP_USING_IF_EXISTS;
373
using ::expf _LIBCPP_USING_IF_EXISTS;
374
375
using ::fabs _LIBCPP_USING_IF_EXISTS;
376
using ::fabsf _LIBCPP_USING_IF_EXISTS;
377
using ::floor _LIBCPP_USING_IF_EXISTS;
378
using ::floorf _LIBCPP_USING_IF_EXISTS;
379
380
using ::fmod _LIBCPP_USING_IF_EXISTS;
381
using ::fmodf _LIBCPP_USING_IF_EXISTS;
382
383
using ::frexp _LIBCPP_USING_IF_EXISTS;
384
using ::frexpf _LIBCPP_USING_IF_EXISTS;
385
using ::ldexp _LIBCPP_USING_IF_EXISTS;
386
using ::ldexpf _LIBCPP_USING_IF_EXISTS;
387
388
using ::log _LIBCPP_USING_IF_EXISTS;
389
using ::logf _LIBCPP_USING_IF_EXISTS;
390
391
using ::log10 _LIBCPP_USING_IF_EXISTS;
392
using ::log10f _LIBCPP_USING_IF_EXISTS;
393
using ::modf _LIBCPP_USING_IF_EXISTS;
394
using ::modff _LIBCPP_USING_IF_EXISTS;
395
396
using ::pow _LIBCPP_USING_IF_EXISTS;
397
using ::powf _LIBCPP_USING_IF_EXISTS;
398
399
using ::sin _LIBCPP_USING_IF_EXISTS;
400
using ::sinf _LIBCPP_USING_IF_EXISTS;
401
using ::sinh _LIBCPP_USING_IF_EXISTS;
402
using ::sinhf _LIBCPP_USING_IF_EXISTS;
403
404
using ::sqrt _LIBCPP_USING_IF_EXISTS;
405
using ::sqrtf _LIBCPP_USING_IF_EXISTS;
406
using ::tan _LIBCPP_USING_IF_EXISTS;
407
using ::tanf _LIBCPP_USING_IF_EXISTS;
408
409
using ::tanh _LIBCPP_USING_IF_EXISTS;
410
using ::tanhf _LIBCPP_USING_IF_EXISTS;
411
412
using ::acosh _LIBCPP_USING_IF_EXISTS;
413
using ::acoshf _LIBCPP_USING_IF_EXISTS;
414
using ::asinh _LIBCPP_USING_IF_EXISTS;
415
using ::asinhf _LIBCPP_USING_IF_EXISTS;
416
using ::atanh _LIBCPP_USING_IF_EXISTS;
417
using ::atanhf _LIBCPP_USING_IF_EXISTS;
418
using ::cbrt _LIBCPP_USING_IF_EXISTS;
419
using ::cbrtf _LIBCPP_USING_IF_EXISTS;
420
421
using ::copysign _LIBCPP_USING_IF_EXISTS;
422
using ::copysignf _LIBCPP_USING_IF_EXISTS;
423
424
using ::erf _LIBCPP_USING_IF_EXISTS;
425
using ::erff _LIBCPP_USING_IF_EXISTS;
426
using ::erfc _LIBCPP_USING_IF_EXISTS;
427
using ::erfcf _LIBCPP_USING_IF_EXISTS;
428
using ::exp2 _LIBCPP_USING_IF_EXISTS;
429
using ::exp2f _LIBCPP_USING_IF_EXISTS;
430
using ::expm1 _LIBCPP_USING_IF_EXISTS;
431
using ::expm1f _LIBCPP_USING_IF_EXISTS;
432
using ::fdim _LIBCPP_USING_IF_EXISTS;
433
using ::fdimf _LIBCPP_USING_IF_EXISTS;
434
using ::fmaf _LIBCPP_USING_IF_EXISTS;
435
using ::fma _LIBCPP_USING_IF_EXISTS;
436
using ::fmax _LIBCPP_USING_IF_EXISTS;
437
using ::fmaxf _LIBCPP_USING_IF_EXISTS;
438
using ::fmin _LIBCPP_USING_IF_EXISTS;
439
using ::fminf _LIBCPP_USING_IF_EXISTS;
440
using ::hypot _LIBCPP_USING_IF_EXISTS;
441
using ::hypotf _LIBCPP_USING_IF_EXISTS;
442
using ::ilogb _LIBCPP_USING_IF_EXISTS;
443
using ::ilogbf _LIBCPP_USING_IF_EXISTS;
444
using ::lgamma _LIBCPP_USING_IF_EXISTS;
445
using ::lgammaf _LIBCPP_USING_IF_EXISTS;
446
using ::llrint _LIBCPP_USING_IF_EXISTS;
447
using ::llrintf _LIBCPP_USING_IF_EXISTS;
448
using ::llround _LIBCPP_USING_IF_EXISTS;
449
using ::llroundf _LIBCPP_USING_IF_EXISTS;
450
using ::log1p _LIBCPP_USING_IF_EXISTS;
451
using ::log1pf _LIBCPP_USING_IF_EXISTS;
452
using ::log2 _LIBCPP_USING_IF_EXISTS;
453
using ::log2f _LIBCPP_USING_IF_EXISTS;
454
using ::logb _LIBCPP_USING_IF_EXISTS;
455
using ::logbf _LIBCPP_USING_IF_EXISTS;
456
using ::lrint _LIBCPP_USING_IF_EXISTS;
457
using ::lrintf _LIBCPP_USING_IF_EXISTS;
458
using ::lround _LIBCPP_USING_IF_EXISTS;
459
using ::lroundf _LIBCPP_USING_IF_EXISTS;
460
461
using ::nan _LIBCPP_USING_IF_EXISTS;
462
using ::nanf _LIBCPP_USING_IF_EXISTS;
463
464
using ::nearbyint _LIBCPP_USING_IF_EXISTS;
465
using ::nearbyintf _LIBCPP_USING_IF_EXISTS;
466
using ::nextafter _LIBCPP_USING_IF_EXISTS;
467
using ::nextafterf _LIBCPP_USING_IF_EXISTS;
468
using ::nexttoward _LIBCPP_USING_IF_EXISTS;
469
using ::nexttowardf _LIBCPP_USING_IF_EXISTS;
470
using ::remainder _LIBCPP_USING_IF_EXISTS;
471
using ::remainderf _LIBCPP_USING_IF_EXISTS;
472
using ::remquo _LIBCPP_USING_IF_EXISTS;
473
using ::remquof _LIBCPP_USING_IF_EXISTS;
474
using ::rint _LIBCPP_USING_IF_EXISTS;
475
using ::rintf _LIBCPP_USING_IF_EXISTS;
476
using ::round _LIBCPP_USING_IF_EXISTS;
477
using ::roundf _LIBCPP_USING_IF_EXISTS;
478
using ::scalbln _LIBCPP_USING_IF_EXISTS;
479
using ::scalblnf _LIBCPP_USING_IF_EXISTS;
480
using ::scalbn _LIBCPP_USING_IF_EXISTS;
481
using ::scalbnf _LIBCPP_USING_IF_EXISTS;
482
using ::tgamma _LIBCPP_USING_IF_EXISTS;
483
using ::tgammaf _LIBCPP_USING_IF_EXISTS;
484
using ::trunc _LIBCPP_USING_IF_EXISTS;
485
using ::truncf _LIBCPP_USING_IF_EXISTS;
486
487
using ::acosl _LIBCPP_USING_IF_EXISTS;
488
using ::asinl _LIBCPP_USING_IF_EXISTS;
489
using ::atanl _LIBCPP_USING_IF_EXISTS;
490
using ::atan2l _LIBCPP_USING_IF_EXISTS;
491
using ::ceill _LIBCPP_USING_IF_EXISTS;
492
using ::cosl _LIBCPP_USING_IF_EXISTS;
493
using ::coshl _LIBCPP_USING_IF_EXISTS;
494
using ::expl _LIBCPP_USING_IF_EXISTS;
495
using ::fabsl _LIBCPP_USING_IF_EXISTS;
496
using ::floorl _LIBCPP_USING_IF_EXISTS;
497
using ::fmodl _LIBCPP_USING_IF_EXISTS;
498
using ::frexpl _LIBCPP_USING_IF_EXISTS;
499
using ::ldexpl _LIBCPP_USING_IF_EXISTS;
500
using ::logl _LIBCPP_USING_IF_EXISTS;
501
using ::log10l _LIBCPP_USING_IF_EXISTS;
502
using ::modfl _LIBCPP_USING_IF_EXISTS;
503
using ::powl _LIBCPP_USING_IF_EXISTS;
504
using ::sinl _LIBCPP_USING_IF_EXISTS;
505
using ::sinhl _LIBCPP_USING_IF_EXISTS;
506
using ::sqrtl _LIBCPP_USING_IF_EXISTS;
507
using ::tanl _LIBCPP_USING_IF_EXISTS;
508
509
using ::tanhl _LIBCPP_USING_IF_EXISTS;
510
using ::acoshl _LIBCPP_USING_IF_EXISTS;
511
using ::asinhl _LIBCPP_USING_IF_EXISTS;
512
using ::atanhl _LIBCPP_USING_IF_EXISTS;
513
using ::cbrtl _LIBCPP_USING_IF_EXISTS;
514
515
using ::copysignl _LIBCPP_USING_IF_EXISTS;
516
517
using ::erfl _LIBCPP_USING_IF_EXISTS;
518
using ::erfcl _LIBCPP_USING_IF_EXISTS;
519
using ::exp2l _LIBCPP_USING_IF_EXISTS;
520
using ::expm1l _LIBCPP_USING_IF_EXISTS;
521
using ::fdiml _LIBCPP_USING_IF_EXISTS;
522
using ::fmal _LIBCPP_USING_IF_EXISTS;
523
using ::fmaxl _LIBCPP_USING_IF_EXISTS;
524
using ::fminl _LIBCPP_USING_IF_EXISTS;
525
using ::hypotl _LIBCPP_USING_IF_EXISTS;
526
using ::ilogbl _LIBCPP_USING_IF_EXISTS;
527
using ::lgammal _LIBCPP_USING_IF_EXISTS;
528
using ::llrintl _LIBCPP_USING_IF_EXISTS;
529
using ::llroundl _LIBCPP_USING_IF_EXISTS;
530
using ::log1pl _LIBCPP_USING_IF_EXISTS;
531
using ::log2l _LIBCPP_USING_IF_EXISTS;
532
using ::logbl _LIBCPP_USING_IF_EXISTS;
533
using ::lrintl _LIBCPP_USING_IF_EXISTS;
534
using ::lroundl _LIBCPP_USING_IF_EXISTS;
535
using ::nanl _LIBCPP_USING_IF_EXISTS;
536
using ::nearbyintl _LIBCPP_USING_IF_EXISTS;
537
using ::nextafterl _LIBCPP_USING_IF_EXISTS;
538
using ::nexttowardl _LIBCPP_USING_IF_EXISTS;
539
using ::remainderl _LIBCPP_USING_IF_EXISTS;
540
using ::remquol _LIBCPP_USING_IF_EXISTS;
541
using ::rintl _LIBCPP_USING_IF_EXISTS;
542
using ::roundl _LIBCPP_USING_IF_EXISTS;
543
using ::scalblnl _LIBCPP_USING_IF_EXISTS;
544
using ::scalbnl _LIBCPP_USING_IF_EXISTS;
545
using ::tgammal _LIBCPP_USING_IF_EXISTS;
546
using ::truncl _LIBCPP_USING_IF_EXISTS;
547
548
#if _LIBCPP_STD_VER >= 17
549
0
inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) {
550
0
  return sqrt(__x * __x + __y * __y + __z * __z);
551
0
}
552
0
inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) {
553
0
  return sqrt(__x * __x + __y * __y + __z * __z);
554
0
}
555
0
inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) {
556
0
  return sqrt(__x * __x + __y * __y + __z * __z);
557
0
}
558
559
template <class _A1, class _A2, class _A3>
560
inline _LIBCPP_HIDE_FROM_ABI
561
    typename enable_if_t< is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value,
562
                          __promote<_A1, _A2, _A3> >::type
563
    hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT {
564
  typedef typename __promote<_A1, _A2, _A3>::type __result_type;
565
  static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value &&
566
                   is_same<_A3, __result_type>::value)),
567
                "");
568
  return std::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
569
}
570
#endif
571
572
template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
573
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT {
574
#if __has_builtin(__builtin_isnan)
575
  return __builtin_isnan(__lcpp_x);
576
#else
577
  return isnan(__lcpp_x);
578
#endif
579
}
580
581
template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0>
582
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT {
583
  return std::isnan(__lcpp_x);
584
}
585
586
template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
587
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT {
588
#if __has_builtin(__builtin_isinf)
589
  return __builtin_isinf(__lcpp_x);
590
#else
591
  return isinf(__lcpp_x);
592
#endif
593
}
594
595
template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0>
596
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT {
597
  return std::isinf(__lcpp_x);
598
}
599
600
template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
601
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT {
602
#if __has_builtin(__builtin_isfinite)
603
  return __builtin_isfinite(__lcpp_x);
604
#else
605
  return isfinite(__lcpp_x);
606
#endif
607
}
608
609
template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0>
610
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT {
611
  return __builtin_isfinite(__lcpp_x);
612
}
613
614
0
_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI float __constexpr_copysign(float __x, float __y) _NOEXCEPT {
615
0
  return __builtin_copysignf(__x, __y);
616
0
}
617
618
0
_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI double __constexpr_copysign(double __x, double __y) _NOEXCEPT {
619
0
  return __builtin_copysign(__x, __y);
620
0
}
621
622
_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI long double
623
0
__constexpr_copysign(long double __x, long double __y) _NOEXCEPT {
624
0
  return __builtin_copysignl(__x, __y);
625
0
}
626
627
template <class _A1,
628
          class _A2,
629
          __enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
630
_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type
631
__constexpr_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
632
  typedef typename std::__promote<_A1, _A2>::type __result_type;
633
  static_assert((!(std::_IsSame<_A1, __result_type>::value && std::_IsSame<_A2, __result_type>::value)), "");
634
  return __builtin_copysign((__result_type)__x, (__result_type)__y);
635
}
636
637
0
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float __constexpr_fabs(float __x) _NOEXCEPT {
638
0
  return __builtin_fabsf(__x);
639
0
}
640
641
0
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(double __x) _NOEXCEPT {
642
0
  return __builtin_fabs(__x);
643
0
}
644
645
0
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double __constexpr_fabs(long double __x) _NOEXCEPT {
646
0
  return __builtin_fabsl(__x);
647
0
}
648
649
template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
650
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(_Tp __x) _NOEXCEPT {
651
  return __builtin_fabs(static_cast<double>(__x));
652
}
653
654
0
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 float __constexpr_fmax(float __x, float __y) _NOEXCEPT {
655
0
#if !__has_constexpr_builtin(__builtin_fmaxf)
656
0
  if (__libcpp_is_constant_evaluated()) {
657
0
    if (std::__constexpr_isnan(__x))
658
0
      return __y;
659
0
    if (std::__constexpr_isnan(__y))
660
0
      return __x;
661
0
    return __x < __y ? __y : __x;
662
0
  }
663
0
#endif
664
0
  return __builtin_fmaxf(__x, __y);
665
0
}
666
667
0
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 double __constexpr_fmax(double __x, double __y) _NOEXCEPT {
668
0
#if !__has_constexpr_builtin(__builtin_fmax)
669
0
  if (__libcpp_is_constant_evaluated()) {
670
0
    if (std::__constexpr_isnan(__x))
671
0
      return __y;
672
0
    if (std::__constexpr_isnan(__y))
673
0
      return __x;
674
0
    return __x < __y ? __y : __x;
675
0
  }
676
0
#endif
677
0
  return __builtin_fmax(__x, __y);
678
0
}
679
680
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 long double
681
0
__constexpr_fmax(long double __x, long double __y) _NOEXCEPT {
682
0
#if !__has_constexpr_builtin(__builtin_fmaxl)
683
0
  if (__libcpp_is_constant_evaluated()) {
684
0
    if (std::__constexpr_isnan(__x))
685
0
      return __y;
686
0
    if (std::__constexpr_isnan(__y))
687
0
      return __x;
688
0
    return __x < __y ? __y : __x;
689
0
  }
690
0
#endif
691
0
  return __builtin_fmaxl(__x, __y);
692
0
}
693
694
template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_arithmetic<_Up>::value, int> = 0>
695
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __promote<_Tp, _Up>::type
696
__constexpr_fmax(_Tp __x, _Up __y) _NOEXCEPT {
697
  using __result_type = typename __promote<_Tp, _Up>::type;
698
  return std::__constexpr_fmax(static_cast<__result_type>(__x), static_cast<__result_type>(__y));
699
}
700
701
template <class _Tp>
702
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __constexpr_logb(_Tp __x) {
703
#if !__has_constexpr_builtin(__builtin_logb)
704
  if (__libcpp_is_constant_evaluated()) {
705
    if (__x == _Tp(0)) {
706
      // raise FE_DIVBYZERO
707
      return -numeric_limits<_Tp>::infinity();
708
    }
709
710
    if (std::__constexpr_isinf(__x))
711
      return numeric_limits<_Tp>::infinity();
712
713
    if (std::__constexpr_isnan(__x))
714
      return numeric_limits<_Tp>::quiet_NaN();
715
716
    __x                      = std::__constexpr_fabs(__x);
717
    unsigned long long __exp = 0;
718
    while (__x >= numeric_limits<_Tp>::radix) {
719
      __x /= numeric_limits<_Tp>::radix;
720
      __exp += 1;
721
    }
722
    return _Tp(__exp);
723
  }
724
#endif // !__has_constexpr_builtin(__builtin_logb)
725
  return __builtin_logb(__x);
726
}
727
728
template <class _Tp>
729
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp __constexpr_scalbn(_Tp __x, int __exp) {
730
#if !__has_constexpr_builtin(__builtin_scalbln)
731
  if (__libcpp_is_constant_evaluated()) {
732
    if (__x == _Tp(0))
733
      return __x;
734
735
    if (std::__constexpr_isinf(__x))
736
      return __x;
737
738
    if (__exp == _Tp(0))
739
      return __x;
740
741
    if (std::__constexpr_isnan(__x))
742
      return numeric_limits<_Tp>::quiet_NaN();
743
744
    _Tp __mult(1);
745
    if (__exp > 0) {
746
      __mult = numeric_limits<_Tp>::radix;
747
      --__exp;
748
    } else {
749
      ++__exp;
750
      __exp = -__exp;
751
      __mult /= numeric_limits<_Tp>::radix;
752
    }
753
754
    while (__exp > 0) {
755
      if (!(__exp & 1)) {
756
        __mult *= __mult;
757
        __exp >>= 1;
758
      } else {
759
        __x *= __mult;
760
        --__exp;
761
      }
762
    }
763
    return __x;
764
  }
765
#endif // !__has_constexpr_builtin(__builtin_scalbln)
766
  return __builtin_scalbn(__x, __exp);
767
}
768
769
#if _LIBCPP_STD_VER >= 20
770
template <typename _Fp>
771
0
_LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
772
0
  if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
773
0
    return __t * __b + (1 - __t) * __a;
774
0
775
0
  if (__t == 1)
776
0
    return __b;
777
0
  const _Fp __x = __a + __t * (__b - __a);
778
0
  if ((__t > 1) == (__b > __a))
779
0
    return __b < __x ? __x : __b;
780
0
  else
781
0
    return __x < __b ? __x : __b;
782
0
}
Unexecuted instantiation: float std::__1::__lerp[abi:ne180100]<float>(float, float, float)
Unexecuted instantiation: double std::__1::__lerp[abi:ne180100]<double>(double, double, double)
Unexecuted instantiation: long double std::__1::__lerp[abi:ne180100]<long double>(long double, long double, long double)
783
784
0
_LIBCPP_HIDE_FROM_ABI inline constexpr float lerp(float __a, float __b, float __t) _NOEXCEPT {
785
0
  return __lerp(__a, __b, __t);
786
0
}
787
788
0
_LIBCPP_HIDE_FROM_ABI inline constexpr double lerp(double __a, double __b, double __t) _NOEXCEPT {
789
0
  return __lerp(__a, __b, __t);
790
0
}
791
792
0
_LIBCPP_HIDE_FROM_ABI inline constexpr long double lerp(long double __a, long double __b, long double __t) _NOEXCEPT {
793
0
  return __lerp(__a, __b, __t);
794
0
}
795
796
template <class _A1, class _A2, class _A3>
797
inline _LIBCPP_HIDE_FROM_ABI constexpr
798
    typename enable_if_t< is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value,
799
                          __promote<_A1, _A2, _A3> >::type
800
    lerp(_A1 __a, _A2 __b, _A3 __t) noexcept {
801
  typedef typename __promote<_A1, _A2, _A3>::type __result_type;
802
  static_assert(!(
803
      _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value));
804
  return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t);
805
}
806
#endif // _LIBCPP_STD_VER >= 20
807
808
_LIBCPP_END_NAMESPACE_STD
809
810
_LIBCPP_POP_MACROS
811
812
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
813
#  include <type_traits>
814
#endif
815
816
#endif // _LIBCPP_CMATH