1// -*- C++ -*-
2//===---------------------------- math.h ----------------------------------===//
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_MATH_H
11#define _LIBCPP_MATH_H
12
13/*
14 math.h synopsis
15
16Macros:
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
37Types:
38
39 float_t // C99
40 double_t // C99
41
42// C90
43
44floating_point abs(floating_point x);
45
46floating_point acos (arithmetic x);
47float acosf(float x);
48long double acosl(long double x);
49
50floating_point asin (arithmetic x);
51float asinf(float x);
52long double asinl(long double x);
53
54floating_point atan (arithmetic x);
55float atanf(float x);
56long double atanl(long double x);
57
58floating_point atan2 (arithmetic y, arithmetic x);
59float atan2f(float y, float x);
60long double atan2l(long double y, long double x);
61
62floating_point ceil (arithmetic x);
63float ceilf(float x);
64long double ceill(long double x);
65
66floating_point cos (arithmetic x);
67float cosf(float x);
68long double cosl(long double x);
69
70floating_point cosh (arithmetic x);
71float coshf(float x);
72long double coshl(long double x);
73
74floating_point exp (arithmetic x);
75float expf(float x);
76long double expl(long double x);
77
78floating_point fabs (arithmetic x);
79float fabsf(float x);
80long double fabsl(long double x);
81
82floating_point floor (arithmetic x);
83float floorf(float x);
84long double floorl(long double x);
85
86floating_point fmod (arithmetic x, arithmetic y);
87float fmodf(float x, float y);
88long double fmodl(long double x, long double y);
89
90floating_point frexp (arithmetic value, int* exp);
91float frexpf(float value, int* exp);
92long double frexpl(long double value, int* exp);
93
94floating_point ldexp (arithmetic value, int exp);
95float ldexpf(float value, int exp);
96long double ldexpl(long double value, int exp);
97
98floating_point log (arithmetic x);
99float logf(float x);
100long double logl(long double x);
101
102floating_point log10 (arithmetic x);
103float log10f(float x);
104long double log10l(long double x);
105
106floating_point modf (floating_point value, floating_point* iptr);
107float modff(float value, float* iptr);
108long double modfl(long double value, long double* iptr);
109
110floating_point pow (arithmetic x, arithmetic y);
111float powf(float x, float y);
112long double powl(long double x, long double y);
113
114floating_point sin (arithmetic x);
115float sinf(float x);
116long double sinl(long double x);
117
118floating_point sinh (arithmetic x);
119float sinhf(float x);
120long double sinhl(long double x);
121
122floating_point sqrt (arithmetic x);
123float sqrtf(float x);
124long double sqrtl(long double x);
125
126floating_point tan (arithmetic x);
127float tanf(float x);
128long double tanl(long double x);
129
130floating_point tanh (arithmetic x);
131float tanhf(float x);
132long double tanhl(long double x);
133
134// C99
135
136bool signbit(arithmetic x);
137
138int fpclassify(arithmetic x);
139
140bool isfinite(arithmetic x);
141bool isinf(arithmetic x);
142bool isnan(arithmetic x);
143bool isnormal(arithmetic x);
144
145bool isgreater(arithmetic x, arithmetic y);
146bool isgreaterequal(arithmetic x, arithmetic y);
147bool isless(arithmetic x, arithmetic y);
148bool islessequal(arithmetic x, arithmetic y);
149bool islessgreater(arithmetic x, arithmetic y);
150bool isunordered(arithmetic x, arithmetic y);
151
152floating_point acosh (arithmetic x);
153float acoshf(float x);
154long double acoshl(long double x);
155
156floating_point asinh (arithmetic x);
157float asinhf(float x);
158long double asinhl(long double x);
159
160floating_point atanh (arithmetic x);
161float atanhf(float x);
162long double atanhl(long double x);
163
164floating_point cbrt (arithmetic x);
165float cbrtf(float x);
166long double cbrtl(long double x);
167
168floating_point copysign (arithmetic x, arithmetic y);
169float copysignf(float x, float y);
170long double copysignl(long double x, long double y);
171
172floating_point erf (arithmetic x);
173float erff(float x);
174long double erfl(long double x);
175
176floating_point erfc (arithmetic x);
177float erfcf(float x);
178long double erfcl(long double x);
179
180floating_point exp2 (arithmetic x);
181float exp2f(float x);
182long double exp2l(long double x);
183
184floating_point expm1 (arithmetic x);
185float expm1f(float x);
186long double expm1l(long double x);
187
188floating_point fdim (arithmetic x, arithmetic y);
189float fdimf(float x, float y);
190long double fdiml(long double x, long double y);
191
192floating_point fma (arithmetic x, arithmetic y, arithmetic z);
193float fmaf(float x, float y, float z);
194long double fmal(long double x, long double y, long double z);
195
196floating_point fmax (arithmetic x, arithmetic y);
197float fmaxf(float x, float y);
198long double fmaxl(long double x, long double y);
199
200floating_point fmin (arithmetic x, arithmetic y);
201float fminf(float x, float y);
202long double fminl(long double x, long double y);
203
204floating_point hypot (arithmetic x, arithmetic y);
205float hypotf(float x, float y);
206long double hypotl(long double x, long double y);
207
208int ilogb (arithmetic x);
209int ilogbf(float x);
210int ilogbl(long double x);
211
212floating_point lgamma (arithmetic x);
213float lgammaf(float x);
214long double lgammal(long double x);
215
216long long llrint (arithmetic x);
217long long llrintf(float x);
218long long llrintl(long double x);
219
220long long llround (arithmetic x);
221long long llroundf(float x);
222long long llroundl(long double x);
223
224floating_point log1p (arithmetic x);
225float log1pf(float x);
226long double log1pl(long double x);
227
228floating_point log2 (arithmetic x);
229float log2f(float x);
230long double log2l(long double x);
231
232floating_point logb (arithmetic x);
233float logbf(float x);
234long double logbl(long double x);
235
236long lrint (arithmetic x);
237long lrintf(float x);
238long lrintl(long double x);
239
240long lround (arithmetic x);
241long lroundf(float x);
242long lroundl(long double x);
243
244double nan (const char* str);
245float nanf(const char* str);
246long double nanl(const char* str);
247
248floating_point nearbyint (arithmetic x);
249float nearbyintf(float x);
250long double nearbyintl(long double x);
251
252floating_point nextafter (arithmetic x, arithmetic y);
253float nextafterf(float x, float y);
254long double nextafterl(long double x, long double y);
255
256floating_point nexttoward (arithmetic x, long double y);
257float nexttowardf(float x, long double y);
258long double nexttowardl(long double x, long double y);
259
260floating_point remainder (arithmetic x, arithmetic y);
261float remainderf(float x, float y);
262long double remainderl(long double x, long double y);
263
264floating_point remquo (arithmetic x, arithmetic y, int* pquo);
265float remquof(float x, float y, int* pquo);
266long double remquol(long double x, long double y, int* pquo);
267
268floating_point rint (arithmetic x);
269float rintf(float x);
270long double rintl(long double x);
271
272floating_point round (arithmetic x);
273float roundf(float x);
274long double roundl(long double x);
275
276floating_point scalbln (arithmetic x, long ex);
277float scalblnf(float x, long ex);
278long double scalblnl(long double x, long ex);
279
280floating_point scalbn (arithmetic x, int ex);
281float scalbnf(float x, int ex);
282long double scalbnl(long double x, int ex);
283
284floating_point tgamma (arithmetic x);
285float tgammaf(float x);
286long double tgammal(long double x);
287
288floating_point trunc (arithmetic x);
289float truncf(float x);
290long double truncl(long double x);
291
292*/
293
294#include <__config>
295
296#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
297#pragma GCC system_header
298#endif
299
300#define _LIBCPP_STDLIB_INCLUDE_NEXT
301#include <stdlib.h>
302
303#include_next <math.h>
304
305#ifdef __cplusplus
306
307// We support including .h headers inside 'extern "C"' contexts, so switch
308// back to C++ linkage before including these C++ headers.
309extern "C++" {
310
311#include <type_traits>
312#include <limits>
313
314// signbit
315
316#ifdef signbit
317
318template <class _A1>
319_LIBCPP_INLINE_VISIBILITY
320bool
321__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
322{
323 return signbit(__lcpp_x);
324}
325
326#undef signbit
327
328template <class _A1>
329inline _LIBCPP_INLINE_VISIBILITY
330typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
331signbit(_A1 __lcpp_x) _NOEXCEPT
332{
333 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
334}
335
336template <class _A1>
337inline _LIBCPP_INLINE_VISIBILITY
338typename std::enable_if<
339 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
340signbit(_A1 __lcpp_x) _NOEXCEPT
341{ return __lcpp_x < 0; }
342
343template <class _A1>
344inline _LIBCPP_INLINE_VISIBILITY
345typename std::enable_if<
346 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
347signbit(_A1) _NOEXCEPT
348{ return false; }
349
350#elif defined(_LIBCPP_MSVCRT)
351
352template <typename _A1>
353inline _LIBCPP_INLINE_VISIBILITY
354typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
355signbit(_A1 __lcpp_x) _NOEXCEPT
356{
357 return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
358}
359
360template <class _A1>
361inline _LIBCPP_INLINE_VISIBILITY
362typename std::enable_if<
363 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
364signbit(_A1 __lcpp_x) _NOEXCEPT
365{ return __lcpp_x < 0; }
366
367template <class _A1>
368inline _LIBCPP_INLINE_VISIBILITY
369typename std::enable_if<
370 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
371signbit(_A1) _NOEXCEPT
372{ return false; }
373
374#endif // signbit
375
376// fpclassify
377
378#ifdef fpclassify
379
380template <class _A1>
381_LIBCPP_INLINE_VISIBILITY
382int
383__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
384{
385 return fpclassify(__lcpp_x);
386}
387
388#undef fpclassify
389
390template <class _A1>
391inline _LIBCPP_INLINE_VISIBILITY
392typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
393fpclassify(_A1 __lcpp_x) _NOEXCEPT
394{
395 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
396}
397
398template <class _A1>
399inline _LIBCPP_INLINE_VISIBILITY
400typename std::enable_if<std::is_integral<_A1>::value, int>::type
401fpclassify(_A1 __lcpp_x) _NOEXCEPT
402{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
403
404#elif defined(_LIBCPP_MSVCRT)
405
406template <typename _A1>
407inline _LIBCPP_INLINE_VISIBILITY
408typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
409fpclassify(_A1 __lcpp_x) _NOEXCEPT
410{
411 return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
412}
413
414template <class _A1>
415inline _LIBCPP_INLINE_VISIBILITY
416typename std::enable_if<std::is_integral<_A1>::value, int>::type
417fpclassify(_A1 __lcpp_x) _NOEXCEPT
418{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
419
420#endif // fpclassify
421
422// isfinite
423
424#ifdef isfinite
425
426template <class _A1>
427_LIBCPP_INLINE_VISIBILITY
428bool
429__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
430{
431 return isfinite(__lcpp_x);
432}
433
434#undef isfinite
435
436template <class _A1>
437inline _LIBCPP_INLINE_VISIBILITY
438typename std::enable_if<
439 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
440 bool>::type
441isfinite(_A1 __lcpp_x) _NOEXCEPT
442{
443 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
444}
445
446template <class _A1>
447inline _LIBCPP_INLINE_VISIBILITY
448typename std::enable_if<
449 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
450 bool>::type
451isfinite(_A1) _NOEXCEPT
452{ return true; }
453
454#endif // isfinite
455
456// isinf
457
458#ifdef isinf
459
460template <class _A1>
461_LIBCPP_INLINE_VISIBILITY
462bool
463__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
464{
465 return isinf(__lcpp_x);
466}
467
468#undef isinf
469
470template <class _A1>
471inline _LIBCPP_INLINE_VISIBILITY
472typename std::enable_if<
473 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
474 bool>::type
475isinf(_A1 __lcpp_x) _NOEXCEPT
476{
477 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
478}
479
480template <class _A1>
481inline _LIBCPP_INLINE_VISIBILITY
482typename std::enable_if<
483 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
484 bool>::type
485isinf(_A1) _NOEXCEPT
486{ return false; }
487
488#ifdef _LIBCPP_PREFERRED_OVERLOAD
489inline _LIBCPP_INLINE_VISIBILITY
490bool
491isinf(float __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
492
493inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
494bool
495isinf(double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
496
497inline _LIBCPP_INLINE_VISIBILITY
498bool
499isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
500#endif
501
502#endif // isinf
503
504// isnan
505
506#ifdef isnan
507
508template <class _A1>
509_LIBCPP_INLINE_VISIBILITY
510bool
511__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
512{
513 return isnan(__lcpp_x);
514}
515
516#undef isnan
517
518template <class _A1>
519inline _LIBCPP_INLINE_VISIBILITY
520typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
521isnan(_A1 __lcpp_x) _NOEXCEPT
522{
523 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
524}
525
526template <class _A1>
527inline _LIBCPP_INLINE_VISIBILITY
528typename std::enable_if<std::is_integral<_A1>::value, bool>::type
529isnan(_A1) _NOEXCEPT
530{ return false; }
531
532#ifdef _LIBCPP_PREFERRED_OVERLOAD
533inline _LIBCPP_INLINE_VISIBILITY
534bool
535isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
536
537inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
538bool
539isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
540
541inline _LIBCPP_INLINE_VISIBILITY
542bool
543isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
544#endif
545
546#endif // isnan
547
548// isnormal
549
550#ifdef isnormal
551
552template <class _A1>
553_LIBCPP_INLINE_VISIBILITY
554bool
555__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
556{
557 return isnormal(__lcpp_x);
558}
559
560#undef isnormal
561
562template <class _A1>
563inline _LIBCPP_INLINE_VISIBILITY
564typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
565isnormal(_A1 __lcpp_x) _NOEXCEPT
566{
567 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
568}
569
570template <class _A1>
571inline _LIBCPP_INLINE_VISIBILITY
572typename std::enable_if<std::is_integral<_A1>::value, bool>::type
573isnormal(_A1 __lcpp_x) _NOEXCEPT
574{ return __lcpp_x != 0; }
575
576#endif // isnormal
577
578// isgreater
579
580#ifdef isgreater
581
582template <class _A1, class _A2>
583_LIBCPP_INLINE_VISIBILITY
584bool
585__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
586{
587 return isgreater(__lcpp_x, __lcpp_y);
588}
589
590#undef isgreater
591
592template <class _A1, class _A2>
593inline _LIBCPP_INLINE_VISIBILITY
594typename std::enable_if
595<
596 std::is_arithmetic<_A1>::value &&
597 std::is_arithmetic<_A2>::value,
598 bool
599>::type
600isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
601{
602 typedef typename std::__promote<_A1, _A2>::type type;
603 return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
604}
605
606#endif // isgreater
607
608// isgreaterequal
609
610#ifdef isgreaterequal
611
612template <class _A1, class _A2>
613_LIBCPP_INLINE_VISIBILITY
614bool
615__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
616{
617 return isgreaterequal(__lcpp_x, __lcpp_y);
618}
619
620#undef isgreaterequal
621
622template <class _A1, class _A2>
623inline _LIBCPP_INLINE_VISIBILITY
624typename std::enable_if
625<
626 std::is_arithmetic<_A1>::value &&
627 std::is_arithmetic<_A2>::value,
628 bool
629>::type
630isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
631{
632 typedef typename std::__promote<_A1, _A2>::type type;
633 return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
634}
635
636#endif // isgreaterequal
637
638// isless
639
640#ifdef isless
641
642template <class _A1, class _A2>
643_LIBCPP_INLINE_VISIBILITY
644bool
645__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
646{
647 return isless(__lcpp_x, __lcpp_y);
648}
649
650#undef isless
651
652template <class _A1, class _A2>
653inline _LIBCPP_INLINE_VISIBILITY
654typename std::enable_if
655<
656 std::is_arithmetic<_A1>::value &&
657 std::is_arithmetic<_A2>::value,
658 bool
659>::type
660isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
661{
662 typedef typename std::__promote<_A1, _A2>::type type;
663 return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
664}
665
666#endif // isless
667
668// islessequal
669
670#ifdef islessequal
671
672template <class _A1, class _A2>
673_LIBCPP_INLINE_VISIBILITY
674bool
675__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
676{
677 return islessequal(__lcpp_x, __lcpp_y);
678}
679
680#undef islessequal
681
682template <class _A1, class _A2>
683inline _LIBCPP_INLINE_VISIBILITY
684typename std::enable_if
685<
686 std::is_arithmetic<_A1>::value &&
687 std::is_arithmetic<_A2>::value,
688 bool
689>::type
690islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
691{
692 typedef typename std::__promote<_A1, _A2>::type type;
693 return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
694}
695
696#endif // islessequal
697
698// islessgreater
699
700#ifdef islessgreater
701
702template <class _A1, class _A2>
703_LIBCPP_INLINE_VISIBILITY
704bool
705__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
706{
707 return islessgreater(__lcpp_x, __lcpp_y);
708}
709
710#undef islessgreater
711
712template <class _A1, class _A2>
713inline _LIBCPP_INLINE_VISIBILITY
714typename std::enable_if
715<
716 std::is_arithmetic<_A1>::value &&
717 std::is_arithmetic<_A2>::value,
718 bool
719>::type
720islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
721{
722 typedef typename std::__promote<_A1, _A2>::type type;
723 return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
724}
725
726#endif // islessgreater
727
728// isunordered
729
730#ifdef isunordered
731
732template <class _A1, class _A2>
733_LIBCPP_INLINE_VISIBILITY
734bool
735__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
736{
737 return isunordered(__lcpp_x, __lcpp_y);
738}
739
740#undef isunordered
741
742template <class _A1, class _A2>
743inline _LIBCPP_INLINE_VISIBILITY
744typename std::enable_if
745<
746 std::is_arithmetic<_A1>::value &&
747 std::is_arithmetic<_A2>::value,
748 bool
749>::type
750isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
751{
752 typedef typename std::__promote<_A1, _A2>::type type;
753 return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
754}
755
756#endif // isunordered
757
758// abs
759
760#undef abs
761#undef labs
762#ifndef _LIBCPP_HAS_NO_LONG_LONG
763#undef llabs
764#endif
765
766// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
767#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
768inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
769 return ::labs(__x);
770}
771#ifndef _LIBCPP_HAS_NO_LONG_LONG
772inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
773 return ::llabs(__x);
774}
775#endif // _LIBCPP_HAS_NO_LONG_LONG
776#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
777
778
779#if !(defined(_AIX) || defined(__sun__))
780inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
781 return ::fabsf(__lcpp_x);
782}
783
784inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
785 return ::fabs(__lcpp_x);
786}
787
788inline _LIBCPP_INLINE_VISIBILITY long double
789abs(long double __lcpp_x) _NOEXCEPT {
790 return ::fabsl(__lcpp_x);
791}
792#endif // !(defined(_AIX) || defined(__sun__))
793
794// div
795
796#undef div
797#undef ldiv
798#ifndef _LIBCPP_HAS_NO_LONG_LONG
799#undef lldiv
800#endif
801
802// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
803#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
804inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
805 return ::ldiv(__x, __y);
806}
807#ifndef _LIBCPP_HAS_NO_LONG_LONG
808inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
809 long long __y) _NOEXCEPT {
810 return ::lldiv(__x, __y);
811}
812#endif // _LIBCPP_HAS_NO_LONG_LONG
813#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
814
815// acos
816
817#if !(defined(_AIX) || defined(__sun__))
818inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
819inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
820#endif
821
822template <class _A1>
823inline _LIBCPP_INLINE_VISIBILITY
824typename std::enable_if<std::is_integral<_A1>::value, double>::type
825acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
826
827// asin
828
829#if !(defined(_AIX) || defined(__sun__))
830inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
831inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
832#endif
833
834template <class _A1>
835inline _LIBCPP_INLINE_VISIBILITY
836typename std::enable_if<std::is_integral<_A1>::value, double>::type
837asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
838
839// atan
840
841#if !(defined(_AIX) || defined(__sun__))
842inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
843inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
844#endif
845
846template <class _A1>
847inline _LIBCPP_INLINE_VISIBILITY
848typename std::enable_if<std::is_integral<_A1>::value, double>::type
849atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
850
851// atan2
852
853#if !(defined(_AIX) || defined(__sun__))
854inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
855inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
856#endif
857
858template <class _A1, class _A2>
859inline _LIBCPP_INLINE_VISIBILITY
860typename std::_EnableIf
861<
862 std::is_arithmetic<_A1>::value &&
863 std::is_arithmetic<_A2>::value,
864 std::__promote<_A1, _A2>
865>::type
866atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
867{
868 typedef typename std::__promote<_A1, _A2>::type __result_type;
869 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
870 std::_IsSame<_A2, __result_type>::value)), "");
871 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
872}
873
874// ceil
875
876#if !(defined(_AIX) || defined(__sun__))
877inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
878inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
879#endif
880
881template <class _A1>
882inline _LIBCPP_INLINE_VISIBILITY
883typename std::enable_if<std::is_integral<_A1>::value, double>::type
884ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
885
886// cos
887
888#if !(defined(_AIX) || defined(__sun__))
889inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
890inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}
891#endif
892
893template <class _A1>
894inline _LIBCPP_INLINE_VISIBILITY
895typename std::enable_if<std::is_integral<_A1>::value, double>::type
896cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
897
898// cosh
899
900#if !(defined(_AIX) || defined(__sun__))
901inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
902inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
903#endif
904
905template <class _A1>
906inline _LIBCPP_INLINE_VISIBILITY
907typename std::enable_if<std::is_integral<_A1>::value, double>::type
908cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
909
910// exp
911
912#if !(defined(_AIX) || defined(__sun__))
913inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
914inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
915#endif
916
917template <class _A1>
918inline _LIBCPP_INLINE_VISIBILITY
919typename std::enable_if<std::is_integral<_A1>::value, double>::type
920exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
921
922// fabs
923
924#if !(defined(_AIX) || defined(__sun__))
925inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
926inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
927#endif
928
929template <class _A1>
930inline _LIBCPP_INLINE_VISIBILITY
931typename std::enable_if<std::is_integral<_A1>::value, double>::type
932fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
933
934// floor
935
936#if !(defined(_AIX) || defined(__sun__))
937inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
938inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
939#endif
940
941template <class _A1>
942inline _LIBCPP_INLINE_VISIBILITY
943typename std::enable_if<std::is_integral<_A1>::value, double>::type
944floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
945
946// fmod
947
948#if !(defined(_AIX) || defined(__sun__))
949inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
950inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}
951#endif
952
953template <class _A1, class _A2>
954inline _LIBCPP_INLINE_VISIBILITY
955typename std::_EnableIf
956<
957 std::is_arithmetic<_A1>::value &&
958 std::is_arithmetic<_A2>::value,
959 std::__promote<_A1, _A2>
960>::type
961fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
962{
963 typedef typename std::__promote<_A1, _A2>::type __result_type;
964 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
965 std::_IsSame<_A2, __result_type>::value)), "");
966 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
967}
968
969// frexp
970
971#if !(defined(_AIX) || defined(__sun__))
972inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
973inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}
974#endif
975
976template <class _A1>
977inline _LIBCPP_INLINE_VISIBILITY
978typename std::enable_if<std::is_integral<_A1>::value, double>::type
979frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);}
980
981// ldexp
982
983#if !(defined(_AIX) || defined(__sun__))
984inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
985inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}
986#endif
987
988template <class _A1>
989inline _LIBCPP_INLINE_VISIBILITY
990typename std::enable_if<std::is_integral<_A1>::value, double>::type
991ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);}
992
993// log
994
995#if !(defined(_AIX) || defined(__sun__))
996inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
997inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
998#endif
999
1000template <class _A1>
1001inline _LIBCPP_INLINE_VISIBILITY
1002typename std::enable_if<std::is_integral<_A1>::value, double>::type
1003log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
1004
1005// log10
1006
1007#if !(defined(_AIX) || defined(__sun__))
1008inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
1009inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
1010#endif
1011
1012template <class _A1>
1013inline _LIBCPP_INLINE_VISIBILITY
1014typename std::enable_if<std::is_integral<_A1>::value, double>::type
1015log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
1016
1017// modf
1018
1019#if !(defined(_AIX) || defined(__sun__))
1020inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
1021inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}
1022#endif
1023
1024// pow
1025
1026#if !(defined(_AIX) || defined(__sun__))
1027inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
1028inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}
1029#endif
1030
1031template <class _A1, class _A2>
1032inline _LIBCPP_INLINE_VISIBILITY
1033typename std::_EnableIf
1034<
1035 std::is_arithmetic<_A1>::value &&
1036 std::is_arithmetic<_A2>::value,
1037 std::__promote<_A1, _A2>
1038>::type
1039pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1040{
1041 typedef typename std::__promote<_A1, _A2>::type __result_type;
1042 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1043 std::_IsSame<_A2, __result_type>::value)), "");
1044 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1045}
1046
1047// sin
1048
1049#if !(defined(_AIX) || defined(__sun__))
1050inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
1051inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
1052#endif
1053
1054template <class _A1>
1055inline _LIBCPP_INLINE_VISIBILITY
1056typename std::enable_if<std::is_integral<_A1>::value, double>::type
1057sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
1058
1059// sinh
1060
1061#if !(defined(_AIX) || defined(__sun__))
1062inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
1063inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
1064#endif
1065
1066template <class _A1>
1067inline _LIBCPP_INLINE_VISIBILITY
1068typename std::enable_if<std::is_integral<_A1>::value, double>::type
1069sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
1070
1071// sqrt
1072
1073#if !(defined(_AIX) || defined(__sun__))
1074inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
1075inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
1076#endif
1077
1078template <class _A1>
1079inline _LIBCPP_INLINE_VISIBILITY
1080typename std::enable_if<std::is_integral<_A1>::value, double>::type
1081sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
1082
1083// tan
1084
1085#if !(defined(_AIX) || defined(__sun__))
1086inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
1087inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
1088#endif
1089
1090template <class _A1>
1091inline _LIBCPP_INLINE_VISIBILITY
1092typename std::enable_if<std::is_integral<_A1>::value, double>::type
1093tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
1094
1095// tanh
1096
1097#if !(defined(_AIX) || defined(__sun__))
1098inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
1099inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
1100#endif
1101
1102template <class _A1>
1103inline _LIBCPP_INLINE_VISIBILITY
1104typename std::enable_if<std::is_integral<_A1>::value, double>::type
1105tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
1106
1107// acosh
1108
1109inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);}
1110inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_x);}
1111
1112template <class _A1>
1113inline _LIBCPP_INLINE_VISIBILITY
1114typename std::enable_if<std::is_integral<_A1>::value, double>::type
1115acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
1116
1117// asinh
1118
1119inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);}
1120inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_x);}
1121
1122template <class _A1>
1123inline _LIBCPP_INLINE_VISIBILITY
1124typename std::enable_if<std::is_integral<_A1>::value, double>::type
1125asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
1126
1127// atanh
1128
1129inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);}
1130inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_x);}
1131
1132template <class _A1>
1133inline _LIBCPP_INLINE_VISIBILITY
1134typename std::enable_if<std::is_integral<_A1>::value, double>::type
1135atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
1136
1137// cbrt
1138
1139inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);}
1140inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_x);}
1141
1142template <class _A1>
1143inline _LIBCPP_INLINE_VISIBILITY
1144typename std::enable_if<std::is_integral<_A1>::value, double>::type
1145cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
1146
1147// copysign
1148
1149inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x,
1150 float __lcpp_y) _NOEXCEPT {
1151 return ::copysignf(__lcpp_x, __lcpp_y);
1152}
1153inline _LIBCPP_INLINE_VISIBILITY long double
1154copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
1155 return ::copysignl(__lcpp_x, __lcpp_y);
1156}
1157
1158template <class _A1, class _A2>
1159inline _LIBCPP_INLINE_VISIBILITY
1160typename std::_EnableIf
1161<
1162 std::is_arithmetic<_A1>::value &&
1163 std::is_arithmetic<_A2>::value,
1164 std::__promote<_A1, _A2>
1165>::type
1166copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1167{
1168 typedef typename std::__promote<_A1, _A2>::type __result_type;
1169 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1170 std::_IsSame<_A2, __result_type>::value)), "");
1171 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1172}
1173
1174// erf
1175
1176inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return ::erff(__lcpp_x);}
1177inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return ::erfl(__lcpp_x);}
1178
1179template <class _A1>
1180inline _LIBCPP_INLINE_VISIBILITY
1181typename std::enable_if<std::is_integral<_A1>::value, double>::type
1182erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
1183
1184// erfc
1185
1186inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);}
1187inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__lcpp_x);}
1188
1189template <class _A1>
1190inline _LIBCPP_INLINE_VISIBILITY
1191typename std::enable_if<std::is_integral<_A1>::value, double>::type
1192erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
1193
1194// exp2
1195
1196inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);}
1197inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_x);}
1198
1199template <class _A1>
1200inline _LIBCPP_INLINE_VISIBILITY
1201typename std::enable_if<std::is_integral<_A1>::value, double>::type
1202exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
1203
1204// expm1
1205
1206inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);}
1207inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_x);}
1208
1209template <class _A1>
1210inline _LIBCPP_INLINE_VISIBILITY
1211typename std::enable_if<std::is_integral<_A1>::value, double>::type
1212expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
1213
1214// fdim
1215
1216inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);}
1217inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fdiml(__lcpp_x, __lcpp_y);}
1218
1219template <class _A1, class _A2>
1220inline _LIBCPP_INLINE_VISIBILITY
1221typename std::_EnableIf
1222<
1223 std::is_arithmetic<_A1>::value &&
1224 std::is_arithmetic<_A2>::value,
1225 std::__promote<_A1, _A2>
1226>::type
1227fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1228{
1229 typedef typename std::__promote<_A1, _A2>::type __result_type;
1230 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1231 std::_IsSame<_A2, __result_type>::value)), "");
1232 return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1233}
1234
1235// fma
1236
1237inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z);}
1238inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return ::fmal(__lcpp_x, __lcpp_y, __lcpp_z);}
1239
1240template <class _A1, class _A2, class _A3>
1241inline _LIBCPP_INLINE_VISIBILITY
1242typename std::_EnableIf
1243<
1244 std::is_arithmetic<_A1>::value &&
1245 std::is_arithmetic<_A2>::value &&
1246 std::is_arithmetic<_A3>::value,
1247 std::__promote<_A1, _A2, _A3>
1248>::type
1249fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
1250{
1251 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
1252 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1253 std::_IsSame<_A2, __result_type>::value &&
1254 std::_IsSame<_A3, __result_type>::value)), "");
1255 return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
1256}
1257
1258// fmax
1259
1260inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__lcpp_x, __lcpp_y);}
1261inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmaxl(__lcpp_x, __lcpp_y);}
1262
1263template <class _A1, class _A2>
1264inline _LIBCPP_INLINE_VISIBILITY
1265typename std::_EnableIf
1266<
1267 std::is_arithmetic<_A1>::value &&
1268 std::is_arithmetic<_A2>::value,
1269 std::__promote<_A1, _A2>
1270>::type
1271fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1272{
1273 typedef typename std::__promote<_A1, _A2>::type __result_type;
1274 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1275 std::_IsSame<_A2, __result_type>::value)), "");
1276 return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1277}
1278
1279// fmin
1280
1281inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__lcpp_x, __lcpp_y);}
1282inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fminl(__lcpp_x, __lcpp_y);}
1283
1284template <class _A1, class _A2>
1285inline _LIBCPP_INLINE_VISIBILITY
1286typename std::_EnableIf
1287<
1288 std::is_arithmetic<_A1>::value &&
1289 std::is_arithmetic<_A2>::value,
1290 std::__promote<_A1, _A2>
1291>::type
1292fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1293{
1294 typedef typename std::__promote<_A1, _A2>::type __result_type;
1295 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1296 std::_IsSame<_A2, __result_type>::value)), "");
1297 return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1298}
1299
1300// hypot
1301
1302inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);}
1303inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::hypotl(__lcpp_x, __lcpp_y);}
1304
1305template <class _A1, class _A2>
1306inline _LIBCPP_INLINE_VISIBILITY
1307typename std::_EnableIf
1308<
1309 std::is_arithmetic<_A1>::value &&
1310 std::is_arithmetic<_A2>::value,
1311 std::__promote<_A1, _A2>
1312>::type
1313hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1314{
1315 typedef typename std::__promote<_A1, _A2>::type __result_type;
1316 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1317 std::_IsSame<_A2, __result_type>::value)), "");
1318 return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1319}
1320
1321// ilogb
1322
1323inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);}
1324inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_x);}
1325
1326template <class _A1>
1327inline _LIBCPP_INLINE_VISIBILITY
1328typename std::enable_if<std::is_integral<_A1>::value, int>::type
1329ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
1330
1331// lgamma
1332
1333inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);}
1334inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_x);}
1335
1336template <class _A1>
1337inline _LIBCPP_INLINE_VISIBILITY
1338typename std::enable_if<std::is_integral<_A1>::value, double>::type
1339lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
1340
1341// llrint
1342
1343inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return ::llrintf(__lcpp_x);}
1344inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return ::llrintl(__lcpp_x);}
1345
1346template <class _A1>
1347inline _LIBCPP_INLINE_VISIBILITY
1348typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1349llrint(_A1 __lcpp_x) _NOEXCEPT {return ::llrint((double)__lcpp_x);}
1350
1351// llround
1352
1353inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return ::llroundf(__lcpp_x);}
1354inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return ::llroundl(__lcpp_x);}
1355
1356template <class _A1>
1357inline _LIBCPP_INLINE_VISIBILITY
1358typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1359llround(_A1 __lcpp_x) _NOEXCEPT {return ::llround((double)__lcpp_x);}
1360
1361// log1p
1362
1363inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);}
1364inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_x);}
1365
1366template <class _A1>
1367inline _LIBCPP_INLINE_VISIBILITY
1368typename std::enable_if<std::is_integral<_A1>::value, double>::type
1369log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
1370
1371// log2
1372
1373inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}
1374inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);}
1375
1376template <class _A1>
1377inline _LIBCPP_INLINE_VISIBILITY
1378typename std::enable_if<std::is_integral<_A1>::value, double>::type
1379log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
1380
1381// logb
1382
1383inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);}
1384inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_x);}
1385
1386template <class _A1>
1387inline _LIBCPP_INLINE_VISIBILITY
1388typename std::enable_if<std::is_integral<_A1>::value, double>::type
1389logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
1390
1391// lrint
1392
1393inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return ::lrintf(__lcpp_x);}
1394inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return ::lrintl(__lcpp_x);}
1395
1396template <class _A1>
1397inline _LIBCPP_INLINE_VISIBILITY
1398typename std::enable_if<std::is_integral<_A1>::value, long>::type
1399lrint(_A1 __lcpp_x) _NOEXCEPT {return ::lrint((double)__lcpp_x);}
1400
1401// lround
1402
1403inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return ::lroundf(__lcpp_x);}
1404inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return ::lroundl(__lcpp_x);}
1405
1406template <class _A1>
1407inline _LIBCPP_INLINE_VISIBILITY
1408typename std::enable_if<std::is_integral<_A1>::value, long>::type
1409lround(_A1 __lcpp_x) _NOEXCEPT {return ::lround((double)__lcpp_x);}
1410
1411// nan
1412
1413// nearbyint
1414
1415inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);}
1416inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_x);}
1417
1418template <class _A1>
1419inline _LIBCPP_INLINE_VISIBILITY
1420typename std::enable_if<std::is_integral<_A1>::value, double>::type
1421nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
1422
1423// nextafter
1424
1425inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);}
1426inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nextafterl(__lcpp_x, __lcpp_y);}
1427
1428template <class _A1, class _A2>
1429inline _LIBCPP_INLINE_VISIBILITY
1430typename std::_EnableIf
1431<
1432 std::is_arithmetic<_A1>::value &&
1433 std::is_arithmetic<_A2>::value,
1434 std::__promote<_A1, _A2>
1435>::type
1436nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1437{
1438 typedef typename std::__promote<_A1, _A2>::type __result_type;
1439 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1440 std::_IsSame<_A2, __result_type>::value)), "");
1441 return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1442}
1443
1444// nexttoward
1445
1446inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);}
1447inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardl(__lcpp_x, __lcpp_y);}
1448
1449template <class _A1>
1450inline _LIBCPP_INLINE_VISIBILITY
1451typename std::enable_if<std::is_integral<_A1>::value, double>::type
1452nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);}
1453
1454// remainder
1455
1456inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);}
1457inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::remainderl(__lcpp_x, __lcpp_y);}
1458
1459template <class _A1, class _A2>
1460inline _LIBCPP_INLINE_VISIBILITY
1461typename std::_EnableIf
1462<
1463 std::is_arithmetic<_A1>::value &&
1464 std::is_arithmetic<_A2>::value,
1465 std::__promote<_A1, _A2>
1466>::type
1467remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1468{
1469 typedef typename std::__promote<_A1, _A2>::type __result_type;
1470 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1471 std::_IsSame<_A2, __result_type>::value)), "");
1472 return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1473}
1474
1475// remquo
1476
1477inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
1478inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquol(__lcpp_x, __lcpp_y, __lcpp_z);}
1479
1480template <class _A1, class _A2>
1481inline _LIBCPP_INLINE_VISIBILITY
1482typename std::_EnableIf
1483<
1484 std::is_arithmetic<_A1>::value &&
1485 std::is_arithmetic<_A2>::value,
1486 std::__promote<_A1, _A2>
1487>::type
1488remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
1489{
1490 typedef typename std::__promote<_A1, _A2>::type __result_type;
1491 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1492 std::_IsSame<_A2, __result_type>::value)), "");
1493 return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
1494}
1495
1496// rint
1497
1498inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return ::rintf(__lcpp_x);}
1499inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return ::rintl(__lcpp_x);}
1500
1501template <class _A1>
1502inline _LIBCPP_INLINE_VISIBILITY
1503typename std::enable_if<std::is_integral<_A1>::value, double>::type
1504rint(_A1 __lcpp_x) _NOEXCEPT {return ::rint((double)__lcpp_x);}
1505
1506// round
1507
1508inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return ::roundf(__lcpp_x);}
1509inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return ::roundl(__lcpp_x);}
1510
1511template <class _A1>
1512inline _LIBCPP_INLINE_VISIBILITY
1513typename std::enable_if<std::is_integral<_A1>::value, double>::type
1514round(_A1 __lcpp_x) _NOEXCEPT {return ::round((double)__lcpp_x);}
1515
1516// scalbln
1517
1518inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);}
1519inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnl(__lcpp_x, __lcpp_y);}
1520
1521template <class _A1>
1522inline _LIBCPP_INLINE_VISIBILITY
1523typename std::enable_if<std::is_integral<_A1>::value, double>::type
1524scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);}
1525
1526// scalbn
1527
1528inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);}
1529inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnl(__lcpp_x, __lcpp_y);}
1530
1531template <class _A1>
1532inline _LIBCPP_INLINE_VISIBILITY
1533typename std::enable_if<std::is_integral<_A1>::value, double>::type
1534scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);}
1535
1536// tgamma
1537
1538inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);}
1539inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_x);}
1540
1541template <class _A1>
1542inline _LIBCPP_INLINE_VISIBILITY
1543typename std::enable_if<std::is_integral<_A1>::value, double>::type
1544tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
1545
1546// trunc
1547
1548inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return ::truncf(__lcpp_x);}
1549inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return ::truncl(__lcpp_x);}
1550
1551template <class _A1>
1552inline _LIBCPP_INLINE_VISIBILITY
1553typename std::enable_if<std::is_integral<_A1>::value, double>::type
1554trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
1555
1556} // extern "C++"
1557
1558#endif // __cplusplus
1559
1560#else // _LIBCPP_MATH_H
1561
1562// This include lives outside the header guard in order to support an MSVC
1563// extension which allows users to do:
1564//
1565// #define _USE_MATH_DEFINES
1566// #include <math.h>
1567//
1568// and receive the definitions of mathematical constants, even if <math.h>
1569// has previously been included.
1570#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1571#include_next <math.h>
1572#endif
1573
1574#endif // _LIBCPP_MATH_H
1575