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#if __has_builtin(__builtin_isnan)
514 return __builtin_isnan(__lcpp_x);
515#else
516 return isnan(__lcpp_x);
517#endif
518}
519
520#undef isnan
521
522template <class _A1>
523inline _LIBCPP_INLINE_VISIBILITY
524typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
525isnan(_A1 __lcpp_x) _NOEXCEPT
526{
527 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
528}
529
530template <class _A1>
531inline _LIBCPP_INLINE_VISIBILITY
532typename std::enable_if<std::is_integral<_A1>::value, bool>::type
533isnan(_A1) _NOEXCEPT
534{ return false; }
535
536#ifdef _LIBCPP_PREFERRED_OVERLOAD
537inline _LIBCPP_INLINE_VISIBILITY
538bool
539isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
540
541inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
542bool
543isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
544
545inline _LIBCPP_INLINE_VISIBILITY
546bool
547isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
548#endif
549
550#endif // isnan
551
552// isnormal
553
554#ifdef isnormal
555
556template <class _A1>
557_LIBCPP_INLINE_VISIBILITY
558bool
559__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
560{
561 return isnormal(__lcpp_x);
562}
563
564#undef isnormal
565
566template <class _A1>
567inline _LIBCPP_INLINE_VISIBILITY
568typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
569isnormal(_A1 __lcpp_x) _NOEXCEPT
570{
571 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
572}
573
574template <class _A1>
575inline _LIBCPP_INLINE_VISIBILITY
576typename std::enable_if<std::is_integral<_A1>::value, bool>::type
577isnormal(_A1 __lcpp_x) _NOEXCEPT
578{ return __lcpp_x != 0; }
579
580#endif // isnormal
581
582// isgreater
583
584#ifdef isgreater
585
586template <class _A1, class _A2>
587_LIBCPP_INLINE_VISIBILITY
588bool
589__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
590{
591 return isgreater(__lcpp_x, __lcpp_y);
592}
593
594#undef isgreater
595
596template <class _A1, class _A2>
597inline _LIBCPP_INLINE_VISIBILITY
598typename std::enable_if
599<
600 std::is_arithmetic<_A1>::value &&
601 std::is_arithmetic<_A2>::value,
602 bool
603>::type
604isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
605{
606 typedef typename std::__promote<_A1, _A2>::type type;
607 return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
608}
609
610#endif // isgreater
611
612// isgreaterequal
613
614#ifdef isgreaterequal
615
616template <class _A1, class _A2>
617_LIBCPP_INLINE_VISIBILITY
618bool
619__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
620{
621 return isgreaterequal(__lcpp_x, __lcpp_y);
622}
623
624#undef isgreaterequal
625
626template <class _A1, class _A2>
627inline _LIBCPP_INLINE_VISIBILITY
628typename std::enable_if
629<
630 std::is_arithmetic<_A1>::value &&
631 std::is_arithmetic<_A2>::value,
632 bool
633>::type
634isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
635{
636 typedef typename std::__promote<_A1, _A2>::type type;
637 return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
638}
639
640#endif // isgreaterequal
641
642// isless
643
644#ifdef isless
645
646template <class _A1, class _A2>
647_LIBCPP_INLINE_VISIBILITY
648bool
649__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
650{
651 return isless(__lcpp_x, __lcpp_y);
652}
653
654#undef isless
655
656template <class _A1, class _A2>
657inline _LIBCPP_INLINE_VISIBILITY
658typename std::enable_if
659<
660 std::is_arithmetic<_A1>::value &&
661 std::is_arithmetic<_A2>::value,
662 bool
663>::type
664isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
665{
666 typedef typename std::__promote<_A1, _A2>::type type;
667 return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
668}
669
670#endif // isless
671
672// islessequal
673
674#ifdef islessequal
675
676template <class _A1, class _A2>
677_LIBCPP_INLINE_VISIBILITY
678bool
679__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
680{
681 return islessequal(__lcpp_x, __lcpp_y);
682}
683
684#undef islessequal
685
686template <class _A1, class _A2>
687inline _LIBCPP_INLINE_VISIBILITY
688typename std::enable_if
689<
690 std::is_arithmetic<_A1>::value &&
691 std::is_arithmetic<_A2>::value,
692 bool
693>::type
694islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
695{
696 typedef typename std::__promote<_A1, _A2>::type type;
697 return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
698}
699
700#endif // islessequal
701
702// islessgreater
703
704#ifdef islessgreater
705
706template <class _A1, class _A2>
707_LIBCPP_INLINE_VISIBILITY
708bool
709__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
710{
711 return islessgreater(__lcpp_x, __lcpp_y);
712}
713
714#undef islessgreater
715
716template <class _A1, class _A2>
717inline _LIBCPP_INLINE_VISIBILITY
718typename std::enable_if
719<
720 std::is_arithmetic<_A1>::value &&
721 std::is_arithmetic<_A2>::value,
722 bool
723>::type
724islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
725{
726 typedef typename std::__promote<_A1, _A2>::type type;
727 return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
728}
729
730#endif // islessgreater
731
732// isunordered
733
734#ifdef isunordered
735
736template <class _A1, class _A2>
737_LIBCPP_INLINE_VISIBILITY
738bool
739__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
740{
741 return isunordered(__lcpp_x, __lcpp_y);
742}
743
744#undef isunordered
745
746template <class _A1, class _A2>
747inline _LIBCPP_INLINE_VISIBILITY
748typename std::enable_if
749<
750 std::is_arithmetic<_A1>::value &&
751 std::is_arithmetic<_A2>::value,
752 bool
753>::type
754isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
755{
756 typedef typename std::__promote<_A1, _A2>::type type;
757 return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
758}
759
760#endif // isunordered
761
762// abs
763
764#undef abs
765#undef labs
766#ifndef _LIBCPP_HAS_NO_LONG_LONG
767#undef llabs
768#endif
769
770// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
771#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
772inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
773 return ::labs(__x);
774}
775#ifndef _LIBCPP_HAS_NO_LONG_LONG
776inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
777 return ::llabs(__x);
778}
779#endif // _LIBCPP_HAS_NO_LONG_LONG
780#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
781
782
783#if !(defined(_AIX) || defined(__sun__))
784inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
785 return ::fabsf(__lcpp_x);
786}
787
788inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
789 return ::fabs(__lcpp_x);
790}
791
792inline _LIBCPP_INLINE_VISIBILITY long double
793abs(long double __lcpp_x) _NOEXCEPT {
794 return ::fabsl(__lcpp_x);
795}
796#endif // !(defined(_AIX) || defined(__sun__))
797
798// div
799
800#undef div
801#undef ldiv
802#ifndef _LIBCPP_HAS_NO_LONG_LONG
803#undef lldiv
804#endif
805
806// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
807#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
808inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
809 return ::ldiv(__x, __y);
810}
811#ifndef _LIBCPP_HAS_NO_LONG_LONG
812inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
813 long long __y) _NOEXCEPT {
814 return ::lldiv(__x, __y);
815}
816#endif // _LIBCPP_HAS_NO_LONG_LONG
817#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
818
819// acos
820
821#if !(defined(_AIX) || defined(__sun__))
822inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
823inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
824#endif
825
826template <class _A1>
827inline _LIBCPP_INLINE_VISIBILITY
828typename std::enable_if<std::is_integral<_A1>::value, double>::type
829acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
830
831// asin
832
833#if !(defined(_AIX) || defined(__sun__))
834inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
835inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
836#endif
837
838template <class _A1>
839inline _LIBCPP_INLINE_VISIBILITY
840typename std::enable_if<std::is_integral<_A1>::value, double>::type
841asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
842
843// atan
844
845#if !(defined(_AIX) || defined(__sun__))
846inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
847inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
848#endif
849
850template <class _A1>
851inline _LIBCPP_INLINE_VISIBILITY
852typename std::enable_if<std::is_integral<_A1>::value, double>::type
853atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
854
855// atan2
856
857#if !(defined(_AIX) || defined(__sun__))
858inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
859inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
860#endif
861
862template <class _A1, class _A2>
863inline _LIBCPP_INLINE_VISIBILITY
864typename std::_EnableIf
865<
866 std::is_arithmetic<_A1>::value &&
867 std::is_arithmetic<_A2>::value,
868 std::__promote<_A1, _A2>
869>::type
870atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
871{
872 typedef typename std::__promote<_A1, _A2>::type __result_type;
873 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
874 std::_IsSame<_A2, __result_type>::value)), "");
875 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
876}
877
878// ceil
879
880#if !(defined(_AIX) || defined(__sun__))
881inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
882inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
883#endif
884
885template <class _A1>
886inline _LIBCPP_INLINE_VISIBILITY
887typename std::enable_if<std::is_integral<_A1>::value, double>::type
888ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
889
890// cos
891
892#if !(defined(_AIX) || defined(__sun__))
893inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
894inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}
895#endif
896
897template <class _A1>
898inline _LIBCPP_INLINE_VISIBILITY
899typename std::enable_if<std::is_integral<_A1>::value, double>::type
900cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
901
902// cosh
903
904#if !(defined(_AIX) || defined(__sun__))
905inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
906inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
907#endif
908
909template <class _A1>
910inline _LIBCPP_INLINE_VISIBILITY
911typename std::enable_if<std::is_integral<_A1>::value, double>::type
912cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
913
914// exp
915
916#if !(defined(_AIX) || defined(__sun__))
917inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
918inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
919#endif
920
921template <class _A1>
922inline _LIBCPP_INLINE_VISIBILITY
923typename std::enable_if<std::is_integral<_A1>::value, double>::type
924exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
925
926// fabs
927
928#if !(defined(_AIX) || defined(__sun__))
929inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
930inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
931#endif
932
933template <class _A1>
934inline _LIBCPP_INLINE_VISIBILITY
935typename std::enable_if<std::is_integral<_A1>::value, double>::type
936fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
937
938// floor
939
940#if !(defined(_AIX) || defined(__sun__))
941inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
942inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
943#endif
944
945template <class _A1>
946inline _LIBCPP_INLINE_VISIBILITY
947typename std::enable_if<std::is_integral<_A1>::value, double>::type
948floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
949
950// fmod
951
952#if !(defined(_AIX) || defined(__sun__))
953inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
954inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}
955#endif
956
957template <class _A1, class _A2>
958inline _LIBCPP_INLINE_VISIBILITY
959typename std::_EnableIf
960<
961 std::is_arithmetic<_A1>::value &&
962 std::is_arithmetic<_A2>::value,
963 std::__promote<_A1, _A2>
964>::type
965fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
966{
967 typedef typename std::__promote<_A1, _A2>::type __result_type;
968 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
969 std::_IsSame<_A2, __result_type>::value)), "");
970 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
971}
972
973// frexp
974
975#if !(defined(_AIX) || defined(__sun__))
976inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
977inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}
978#endif
979
980template <class _A1>
981inline _LIBCPP_INLINE_VISIBILITY
982typename std::enable_if<std::is_integral<_A1>::value, double>::type
983frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);}
984
985// ldexp
986
987#if !(defined(_AIX) || defined(__sun__))
988inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
989inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}
990#endif
991
992template <class _A1>
993inline _LIBCPP_INLINE_VISIBILITY
994typename std::enable_if<std::is_integral<_A1>::value, double>::type
995ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);}
996
997// log
998
999#if !(defined(_AIX) || defined(__sun__))
1000inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
1001inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
1002#endif
1003
1004template <class _A1>
1005inline _LIBCPP_INLINE_VISIBILITY
1006typename std::enable_if<std::is_integral<_A1>::value, double>::type
1007log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
1008
1009// log10
1010
1011#if !(defined(_AIX) || defined(__sun__))
1012inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
1013inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
1014#endif
1015
1016template <class _A1>
1017inline _LIBCPP_INLINE_VISIBILITY
1018typename std::enable_if<std::is_integral<_A1>::value, double>::type
1019log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
1020
1021// modf
1022
1023#if !(defined(_AIX) || defined(__sun__))
1024inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
1025inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}
1026#endif
1027
1028// pow
1029
1030#if !(defined(_AIX) || defined(__sun__))
1031inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
1032inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}
1033#endif
1034
1035template <class _A1, class _A2>
1036inline _LIBCPP_INLINE_VISIBILITY
1037typename std::_EnableIf
1038<
1039 std::is_arithmetic<_A1>::value &&
1040 std::is_arithmetic<_A2>::value,
1041 std::__promote<_A1, _A2>
1042>::type
1043pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1044{
1045 typedef typename std::__promote<_A1, _A2>::type __result_type;
1046 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1047 std::_IsSame<_A2, __result_type>::value)), "");
1048 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1049}
1050
1051// sin
1052
1053#if !(defined(_AIX) || defined(__sun__))
1054inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
1055inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
1056#endif
1057
1058template <class _A1>
1059inline _LIBCPP_INLINE_VISIBILITY
1060typename std::enable_if<std::is_integral<_A1>::value, double>::type
1061sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
1062
1063// sinh
1064
1065#if !(defined(_AIX) || defined(__sun__))
1066inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
1067inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
1068#endif
1069
1070template <class _A1>
1071inline _LIBCPP_INLINE_VISIBILITY
1072typename std::enable_if<std::is_integral<_A1>::value, double>::type
1073sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
1074
1075// sqrt
1076
1077#if !(defined(_AIX) || defined(__sun__))
1078inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
1079inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
1080#endif
1081
1082template <class _A1>
1083inline _LIBCPP_INLINE_VISIBILITY
1084typename std::enable_if<std::is_integral<_A1>::value, double>::type
1085sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
1086
1087// tan
1088
1089#if !(defined(_AIX) || defined(__sun__))
1090inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
1091inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
1092#endif
1093
1094template <class _A1>
1095inline _LIBCPP_INLINE_VISIBILITY
1096typename std::enable_if<std::is_integral<_A1>::value, double>::type
1097tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
1098
1099// tanh
1100
1101#if !(defined(_AIX) || defined(__sun__))
1102inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
1103inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
1104#endif
1105
1106template <class _A1>
1107inline _LIBCPP_INLINE_VISIBILITY
1108typename std::enable_if<std::is_integral<_A1>::value, double>::type
1109tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
1110
1111// acosh
1112
1113inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);}
1114inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_x);}
1115
1116template <class _A1>
1117inline _LIBCPP_INLINE_VISIBILITY
1118typename std::enable_if<std::is_integral<_A1>::value, double>::type
1119acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
1120
1121// asinh
1122
1123inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);}
1124inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_x);}
1125
1126template <class _A1>
1127inline _LIBCPP_INLINE_VISIBILITY
1128typename std::enable_if<std::is_integral<_A1>::value, double>::type
1129asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
1130
1131// atanh
1132
1133inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);}
1134inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_x);}
1135
1136template <class _A1>
1137inline _LIBCPP_INLINE_VISIBILITY
1138typename std::enable_if<std::is_integral<_A1>::value, double>::type
1139atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
1140
1141// cbrt
1142
1143inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);}
1144inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_x);}
1145
1146template <class _A1>
1147inline _LIBCPP_INLINE_VISIBILITY
1148typename std::enable_if<std::is_integral<_A1>::value, double>::type
1149cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
1150
1151// copysign
1152
1153inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x,
1154 float __lcpp_y) _NOEXCEPT {
1155 return ::copysignf(__lcpp_x, __lcpp_y);
1156}
1157inline _LIBCPP_INLINE_VISIBILITY long double
1158copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
1159 return ::copysignl(__lcpp_x, __lcpp_y);
1160}
1161
1162template <class _A1, class _A2>
1163inline _LIBCPP_INLINE_VISIBILITY
1164typename std::_EnableIf
1165<
1166 std::is_arithmetic<_A1>::value &&
1167 std::is_arithmetic<_A2>::value,
1168 std::__promote<_A1, _A2>
1169>::type
1170copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1171{
1172 typedef typename std::__promote<_A1, _A2>::type __result_type;
1173 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1174 std::_IsSame<_A2, __result_type>::value)), "");
1175 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1176}
1177
1178// erf
1179
1180inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return ::erff(__lcpp_x);}
1181inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return ::erfl(__lcpp_x);}
1182
1183template <class _A1>
1184inline _LIBCPP_INLINE_VISIBILITY
1185typename std::enable_if<std::is_integral<_A1>::value, double>::type
1186erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
1187
1188// erfc
1189
1190inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);}
1191inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__lcpp_x);}
1192
1193template <class _A1>
1194inline _LIBCPP_INLINE_VISIBILITY
1195typename std::enable_if<std::is_integral<_A1>::value, double>::type
1196erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
1197
1198// exp2
1199
1200inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);}
1201inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_x);}
1202
1203template <class _A1>
1204inline _LIBCPP_INLINE_VISIBILITY
1205typename std::enable_if<std::is_integral<_A1>::value, double>::type
1206exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
1207
1208// expm1
1209
1210inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);}
1211inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_x);}
1212
1213template <class _A1>
1214inline _LIBCPP_INLINE_VISIBILITY
1215typename std::enable_if<std::is_integral<_A1>::value, double>::type
1216expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
1217
1218// fdim
1219
1220inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);}
1221inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fdiml(__lcpp_x, __lcpp_y);}
1222
1223template <class _A1, class _A2>
1224inline _LIBCPP_INLINE_VISIBILITY
1225typename std::_EnableIf
1226<
1227 std::is_arithmetic<_A1>::value &&
1228 std::is_arithmetic<_A2>::value,
1229 std::__promote<_A1, _A2>
1230>::type
1231fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1232{
1233 typedef typename std::__promote<_A1, _A2>::type __result_type;
1234 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1235 std::_IsSame<_A2, __result_type>::value)), "");
1236 return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1237}
1238
1239// fma
1240
1241inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z);}
1242inline _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);}
1243
1244template <class _A1, class _A2, class _A3>
1245inline _LIBCPP_INLINE_VISIBILITY
1246typename std::_EnableIf
1247<
1248 std::is_arithmetic<_A1>::value &&
1249 std::is_arithmetic<_A2>::value &&
1250 std::is_arithmetic<_A3>::value,
1251 std::__promote<_A1, _A2, _A3>
1252>::type
1253fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
1254{
1255 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
1256 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1257 std::_IsSame<_A2, __result_type>::value &&
1258 std::_IsSame<_A3, __result_type>::value)), "");
1259 return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
1260}
1261
1262// fmax
1263
1264inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__lcpp_x, __lcpp_y);}
1265inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmaxl(__lcpp_x, __lcpp_y);}
1266
1267template <class _A1, class _A2>
1268inline _LIBCPP_INLINE_VISIBILITY
1269typename std::_EnableIf
1270<
1271 std::is_arithmetic<_A1>::value &&
1272 std::is_arithmetic<_A2>::value,
1273 std::__promote<_A1, _A2>
1274>::type
1275fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1276{
1277 typedef typename std::__promote<_A1, _A2>::type __result_type;
1278 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1279 std::_IsSame<_A2, __result_type>::value)), "");
1280 return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1281}
1282
1283// fmin
1284
1285inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__lcpp_x, __lcpp_y);}
1286inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fminl(__lcpp_x, __lcpp_y);}
1287
1288template <class _A1, class _A2>
1289inline _LIBCPP_INLINE_VISIBILITY
1290typename std::_EnableIf
1291<
1292 std::is_arithmetic<_A1>::value &&
1293 std::is_arithmetic<_A2>::value,
1294 std::__promote<_A1, _A2>
1295>::type
1296fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1297{
1298 typedef typename std::__promote<_A1, _A2>::type __result_type;
1299 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1300 std::_IsSame<_A2, __result_type>::value)), "");
1301 return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1302}
1303
1304// hypot
1305
1306inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);}
1307inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::hypotl(__lcpp_x, __lcpp_y);}
1308
1309template <class _A1, class _A2>
1310inline _LIBCPP_INLINE_VISIBILITY
1311typename std::_EnableIf
1312<
1313 std::is_arithmetic<_A1>::value &&
1314 std::is_arithmetic<_A2>::value,
1315 std::__promote<_A1, _A2>
1316>::type
1317hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1318{
1319 typedef typename std::__promote<_A1, _A2>::type __result_type;
1320 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1321 std::_IsSame<_A2, __result_type>::value)), "");
1322 return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1323}
1324
1325// ilogb
1326
1327inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);}
1328inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_x);}
1329
1330template <class _A1>
1331inline _LIBCPP_INLINE_VISIBILITY
1332typename std::enable_if<std::is_integral<_A1>::value, int>::type
1333ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
1334
1335// lgamma
1336
1337inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);}
1338inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_x);}
1339
1340template <class _A1>
1341inline _LIBCPP_INLINE_VISIBILITY
1342typename std::enable_if<std::is_integral<_A1>::value, double>::type
1343lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
1344
1345// llrint
1346
1347inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return ::llrintf(__lcpp_x);}
1348inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return ::llrintl(__lcpp_x);}
1349
1350template <class _A1>
1351inline _LIBCPP_INLINE_VISIBILITY
1352typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1353llrint(_A1 __lcpp_x) _NOEXCEPT {return ::llrint((double)__lcpp_x);}
1354
1355// llround
1356
1357inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return ::llroundf(__lcpp_x);}
1358inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return ::llroundl(__lcpp_x);}
1359
1360template <class _A1>
1361inline _LIBCPP_INLINE_VISIBILITY
1362typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1363llround(_A1 __lcpp_x) _NOEXCEPT {return ::llround((double)__lcpp_x);}
1364
1365// log1p
1366
1367inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);}
1368inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_x);}
1369
1370template <class _A1>
1371inline _LIBCPP_INLINE_VISIBILITY
1372typename std::enable_if<std::is_integral<_A1>::value, double>::type
1373log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
1374
1375// log2
1376
1377inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}
1378inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);}
1379
1380template <class _A1>
1381inline _LIBCPP_INLINE_VISIBILITY
1382typename std::enable_if<std::is_integral<_A1>::value, double>::type
1383log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
1384
1385// logb
1386
1387inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);}
1388inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_x);}
1389
1390template <class _A1>
1391inline _LIBCPP_INLINE_VISIBILITY
1392typename std::enable_if<std::is_integral<_A1>::value, double>::type
1393logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
1394
1395// lrint
1396
1397inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return ::lrintf(__lcpp_x);}
1398inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return ::lrintl(__lcpp_x);}
1399
1400template <class _A1>
1401inline _LIBCPP_INLINE_VISIBILITY
1402typename std::enable_if<std::is_integral<_A1>::value, long>::type
1403lrint(_A1 __lcpp_x) _NOEXCEPT {return ::lrint((double)__lcpp_x);}
1404
1405// lround
1406
1407inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return ::lroundf(__lcpp_x);}
1408inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return ::lroundl(__lcpp_x);}
1409
1410template <class _A1>
1411inline _LIBCPP_INLINE_VISIBILITY
1412typename std::enable_if<std::is_integral<_A1>::value, long>::type
1413lround(_A1 __lcpp_x) _NOEXCEPT {return ::lround((double)__lcpp_x);}
1414
1415// nan
1416
1417// nearbyint
1418
1419inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);}
1420inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_x);}
1421
1422template <class _A1>
1423inline _LIBCPP_INLINE_VISIBILITY
1424typename std::enable_if<std::is_integral<_A1>::value, double>::type
1425nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
1426
1427// nextafter
1428
1429inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);}
1430inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nextafterl(__lcpp_x, __lcpp_y);}
1431
1432template <class _A1, class _A2>
1433inline _LIBCPP_INLINE_VISIBILITY
1434typename std::_EnableIf
1435<
1436 std::is_arithmetic<_A1>::value &&
1437 std::is_arithmetic<_A2>::value,
1438 std::__promote<_A1, _A2>
1439>::type
1440nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1441{
1442 typedef typename std::__promote<_A1, _A2>::type __result_type;
1443 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1444 std::_IsSame<_A2, __result_type>::value)), "");
1445 return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1446}
1447
1448// nexttoward
1449
1450inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);}
1451inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardl(__lcpp_x, __lcpp_y);}
1452
1453template <class _A1>
1454inline _LIBCPP_INLINE_VISIBILITY
1455typename std::enable_if<std::is_integral<_A1>::value, double>::type
1456nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);}
1457
1458// remainder
1459
1460inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);}
1461inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::remainderl(__lcpp_x, __lcpp_y);}
1462
1463template <class _A1, class _A2>
1464inline _LIBCPP_INLINE_VISIBILITY
1465typename std::_EnableIf
1466<
1467 std::is_arithmetic<_A1>::value &&
1468 std::is_arithmetic<_A2>::value,
1469 std::__promote<_A1, _A2>
1470>::type
1471remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1472{
1473 typedef typename std::__promote<_A1, _A2>::type __result_type;
1474 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1475 std::_IsSame<_A2, __result_type>::value)), "");
1476 return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1477}
1478
1479// remquo
1480
1481inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
1482inline _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);}
1483
1484template <class _A1, class _A2>
1485inline _LIBCPP_INLINE_VISIBILITY
1486typename std::_EnableIf
1487<
1488 std::is_arithmetic<_A1>::value &&
1489 std::is_arithmetic<_A2>::value,
1490 std::__promote<_A1, _A2>
1491>::type
1492remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
1493{
1494 typedef typename std::__promote<_A1, _A2>::type __result_type;
1495 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1496 std::_IsSame<_A2, __result_type>::value)), "");
1497 return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
1498}
1499
1500// rint
1501
1502inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return ::rintf(__lcpp_x);}
1503inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return ::rintl(__lcpp_x);}
1504
1505template <class _A1>
1506inline _LIBCPP_INLINE_VISIBILITY
1507typename std::enable_if<std::is_integral<_A1>::value, double>::type
1508rint(_A1 __lcpp_x) _NOEXCEPT {return ::rint((double)__lcpp_x);}
1509
1510// round
1511
1512inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return ::roundf(__lcpp_x);}
1513inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return ::roundl(__lcpp_x);}
1514
1515template <class _A1>
1516inline _LIBCPP_INLINE_VISIBILITY
1517typename std::enable_if<std::is_integral<_A1>::value, double>::type
1518round(_A1 __lcpp_x) _NOEXCEPT {return ::round((double)__lcpp_x);}
1519
1520// scalbln
1521
1522inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);}
1523inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnl(__lcpp_x, __lcpp_y);}
1524
1525template <class _A1>
1526inline _LIBCPP_INLINE_VISIBILITY
1527typename std::enable_if<std::is_integral<_A1>::value, double>::type
1528scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);}
1529
1530// scalbn
1531
1532inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);}
1533inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnl(__lcpp_x, __lcpp_y);}
1534
1535template <class _A1>
1536inline _LIBCPP_INLINE_VISIBILITY
1537typename std::enable_if<std::is_integral<_A1>::value, double>::type
1538scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);}
1539
1540// tgamma
1541
1542inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);}
1543inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_x);}
1544
1545template <class _A1>
1546inline _LIBCPP_INLINE_VISIBILITY
1547typename std::enable_if<std::is_integral<_A1>::value, double>::type
1548tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
1549
1550// trunc
1551
1552inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return ::truncf(__lcpp_x);}
1553inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return ::truncl(__lcpp_x);}
1554
1555template <class _A1>
1556inline _LIBCPP_INLINE_VISIBILITY
1557typename std::enable_if<std::is_integral<_A1>::value, double>::type
1558trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
1559
1560} // extern "C++"
1561
1562#endif // __cplusplus
1563
1564#else // _LIBCPP_MATH_H
1565
1566// This include lives outside the header guard in order to support an MSVC
1567// extension which allows users to do:
1568//
1569// #define _USE_MATH_DEFINES
1570// #include <math.h>
1571//
1572// and receive the definitions of mathematical constants, even if <math.h>
1573// has previously been included.
1574#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1575#include_next <math.h>
1576#endif
1577
1578#endif // _LIBCPP_MATH_H
1579