blob: 9558321c52068cc3af31abb5dbc4fef660d38cfe [file] [log] [blame]
Richard Smith081bb592015-10-08 20:40:34 +00001// -*- C++ -*-
2//===---------------------------- math.h ----------------------------------===//
3//
Chandler Carruthd2012102019-01-19 10:56:40 +00004// 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
Richard Smith081bb592015-10-08 20:40:34 +00007//
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>
Richard Smith081bb592015-10-08 20:40:34 +0000295
296#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
297#pragma GCC system_header
298#endif
299
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000300#define _LIBCPP_STDLIB_INCLUDE_NEXT
301#include <stdlib.h>
302
Mikhail Maltsev34b4f972018-02-22 09:34:08 +0000303#include_next <math.h>
304
Richard Smith081bb592015-10-08 20:40:34 +0000305#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>
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000312#include <limits>
Richard Smith081bb592015-10-08 20:40:34 +0000313
Richard Smith081bb592015-10-08 20:40:34 +0000314// signbit
315
316#ifdef signbit
317
318template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000319_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000320bool
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
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000330typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000331signbit(_A1 __lcpp_x) _NOEXCEPT
332{
333 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
334}
335
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000336template <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
Shoaib Meenai159375f2017-04-07 02:20:52 +0000350#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000351
352template <typename _A1>
353inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000354typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000355signbit(_A1 __lcpp_x) _NOEXCEPT
356{
357 return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
358}
359
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000360template <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
Richard Smith081bb592015-10-08 20:40:34 +0000374#endif // signbit
375
376// fpclassify
377
378#ifdef fpclassify
379
380template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000381_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000382int
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
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000392typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
Richard Smith081bb592015-10-08 20:40:34 +0000393fpclassify(_A1 __lcpp_x) _NOEXCEPT
394{
395 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
396}
397
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000398template <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
Shoaib Meenai159375f2017-04-07 02:20:52 +0000404#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000405
406template <typename _A1>
407inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000408typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000409fpclassify(_A1 __lcpp_x) _NOEXCEPT
410{
411 return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
412}
413
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000414template <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
Richard Smith081bb592015-10-08 20:40:34 +0000420#endif // fpclassify
421
422// isfinite
423
424#ifdef isfinite
425
426template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000427_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000428bool
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
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000438typename std::enable_if<
439 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
440 bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000441isfinite(_A1 __lcpp_x) _NOEXCEPT
442{
443 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
444}
445
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000446template <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
Richard Smith081bb592015-10-08 20:40:34 +0000454#endif // isfinite
455
456// isinf
457
458#ifdef isinf
459
460template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000461_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000462bool
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
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000472typename std::enable_if<
473 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
474 bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000475isinf(_A1 __lcpp_x) _NOEXCEPT
476{
477 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
478}
479
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000480template <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
Richard Smithafccfd32018-05-01 03:05:40 +0000488#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
Richard Smith081bb592015-10-08 20:40:34 +0000502#endif // isinf
503
504// isnan
505
506#ifdef isnan
507
508template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000509_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000510bool
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
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000520typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000521isnan(_A1 __lcpp_x) _NOEXCEPT
522{
523 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
524}
525
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000526template <class _A1>
527inline _LIBCPP_INLINE_VISIBILITY
528typename std::enable_if<std::is_integral<_A1>::value, bool>::type
529isnan(_A1) _NOEXCEPT
530{ return false; }
531
Richard Smithafccfd32018-05-01 03:05:40 +0000532#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
Richard Smith081bb592015-10-08 20:40:34 +0000546#endif // isnan
547
548// isnormal
549
550#ifdef isnormal
551
552template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000553_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000554bool
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
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000564typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000565isnormal(_A1 __lcpp_x) _NOEXCEPT
566{
567 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
568}
569
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000570template <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
Richard Smith081bb592015-10-08 20:40:34 +0000576#endif // isnormal
577
578// isgreater
579
580#ifdef isgreater
581
582template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000583_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000584bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000613_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000614bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000643_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000644bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000673_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000674bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000703_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000704bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000733_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000734bool
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
Richard Smith081bb592015-10-08 20:40:34 +0000758// abs
759
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000760#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
Eric Fiselier7d1aac92016-08-15 18:58:57 +0000779#if !(defined(_AIX) || defined(__sun__))
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000780inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
781 return ::fabsf(__lcpp_x);
782}
Richard Smith081bb592015-10-08 20:40:34 +0000783
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000784inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
785 return ::fabs(__lcpp_x);
786}
Richard Smith081bb592015-10-08 20:40:34 +0000787
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000788inline _LIBCPP_INLINE_VISIBILITY long double
789abs(long double __lcpp_x) _NOEXCEPT {
790 return ::fabsl(__lcpp_x);
791}
Eric Fiselier7d1aac92016-08-15 18:58:57 +0000792#endif // !(defined(_AIX) || defined(__sun__))
Richard Smith081bb592015-10-08 20:40:34 +0000793
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000794// 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
Richard Smith081bb592015-10-08 20:40:34 +0000815// acos
816
Shoaib Meenai159375f2017-04-07 02:20:52 +0000817#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000818inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000820#endif
821
822template <class _A1>
823inline _LIBCPP_INLINE_VISIBILITY
824typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000825acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000826
827// asin
828
Shoaib Meenai159375f2017-04-07 02:20:52 +0000829#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000830inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000832#endif
833
834template <class _A1>
835inline _LIBCPP_INLINE_VISIBILITY
836typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000837asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000838
839// atan
840
Shoaib Meenai159375f2017-04-07 02:20:52 +0000841#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000842inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000844#endif
845
846template <class _A1>
847inline _LIBCPP_INLINE_VISIBILITY
848typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000849atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000850
851// atan2
852
Shoaib Meenai159375f2017-04-07 02:20:52 +0000853#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000854inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000856#endif
857
858template <class _A1, class _A2>
859inline _LIBCPP_INLINE_VISIBILITY
860typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
870 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000871 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
Richard Smith081bb592015-10-08 20:40:34 +0000872}
873
874// ceil
875
Shoaib Meenai159375f2017-04-07 02:20:52 +0000876#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000877inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000879#endif
880
881template <class _A1>
882inline _LIBCPP_INLINE_VISIBILITY
883typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000884ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000885
886// cos
887
Shoaib Meenai159375f2017-04-07 02:20:52 +0000888#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000889inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000891#endif
892
893template <class _A1>
894inline _LIBCPP_INLINE_VISIBILITY
895typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000896cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000897
898// cosh
899
Shoaib Meenai159375f2017-04-07 02:20:52 +0000900#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000901inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000903#endif
904
905template <class _A1>
906inline _LIBCPP_INLINE_VISIBILITY
907typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000908cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000909
910// exp
911
Shoaib Meenai159375f2017-04-07 02:20:52 +0000912#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000913inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000915#endif
916
917template <class _A1>
918inline _LIBCPP_INLINE_VISIBILITY
919typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000920exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000921
922// fabs
923
Shoaib Meenai159375f2017-04-07 02:20:52 +0000924#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000925inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000927#endif
928
929template <class _A1>
930inline _LIBCPP_INLINE_VISIBILITY
931typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000932fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000933
934// floor
935
Shoaib Meenai159375f2017-04-07 02:20:52 +0000936#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000937inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000939#endif
940
941template <class _A1>
942inline _LIBCPP_INLINE_VISIBILITY
943typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000944floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000945
946// fmod
947
Shoaib Meenai159375f2017-04-07 02:20:52 +0000948#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000949inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000951#endif
952
953template <class _A1, class _A2>
954inline _LIBCPP_INLINE_VISIBILITY
955typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
965 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000966 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +0000967}
968
969// frexp
970
Shoaib Meenai159375f2017-04-07 02:20:52 +0000971#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000972inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000974#endif
975
976template <class _A1>
977inline _LIBCPP_INLINE_VISIBILITY
978typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000979frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000980
981// ldexp
982
Shoaib Meenai159375f2017-04-07 02:20:52 +0000983#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000984inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000986#endif
987
988template <class _A1>
989inline _LIBCPP_INLINE_VISIBILITY
990typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000991ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000992
993// log
994
Shoaib Meenai159375f2017-04-07 02:20:52 +0000995#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000996inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000998#endif
999
1000template <class _A1>
1001inline _LIBCPP_INLINE_VISIBILITY
1002typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001003log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001004
1005// log10
1006
Shoaib Meenai159375f2017-04-07 02:20:52 +00001007#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001008inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001010#endif
1011
1012template <class _A1>
1013inline _LIBCPP_INLINE_VISIBILITY
1014typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001015log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001016
1017// modf
1018
Shoaib Meenai159375f2017-04-07 02:20:52 +00001019#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001020inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001022#endif
1023
1024// pow
1025
Shoaib Meenai159375f2017-04-07 02:20:52 +00001026#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001027inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001029#endif
1030
1031template <class _A1, class _A2>
1032inline _LIBCPP_INLINE_VISIBILITY
1033typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1043 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001044 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001045}
1046
1047// sin
1048
Shoaib Meenai159375f2017-04-07 02:20:52 +00001049#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001050inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001052#endif
1053
1054template <class _A1>
1055inline _LIBCPP_INLINE_VISIBILITY
1056typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001057sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001058
1059// sinh
1060
Shoaib Meenai159375f2017-04-07 02:20:52 +00001061#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001062inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001064#endif
1065
1066template <class _A1>
1067inline _LIBCPP_INLINE_VISIBILITY
1068typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001069sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001070
1071// sqrt
1072
Shoaib Meenai159375f2017-04-07 02:20:52 +00001073#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001074inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001076#endif
1077
Richard Smith081bb592015-10-08 20:40:34 +00001078template <class _A1>
1079inline _LIBCPP_INLINE_VISIBILITY
1080typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001081sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001082
1083// tan
1084
Shoaib Meenai159375f2017-04-07 02:20:52 +00001085#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001086inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001088#endif
1089
1090template <class _A1>
1091inline _LIBCPP_INLINE_VISIBILITY
1092typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001093tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001094
1095// tanh
1096
Shoaib Meenai159375f2017-04-07 02:20:52 +00001097#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001098inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001100#endif
1101
1102template <class _A1>
1103inline _LIBCPP_INLINE_VISIBILITY
1104typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001105tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001106
1107// acosh
1108
Mehdi Aminib3da6322017-02-10 02:44:23 +00001109inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001111
1112template <class _A1>
1113inline _LIBCPP_INLINE_VISIBILITY
1114typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001115acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001116
1117// asinh
1118
Mehdi Aminib3da6322017-02-10 02:44:23 +00001119inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001121
1122template <class _A1>
1123inline _LIBCPP_INLINE_VISIBILITY
1124typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001125asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001126
1127// atanh
1128
Mehdi Aminib3da6322017-02-10 02:44:23 +00001129inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001131
1132template <class _A1>
1133inline _LIBCPP_INLINE_VISIBILITY
1134typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001135atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001136
1137// cbrt
1138
Mehdi Aminib3da6322017-02-10 02:44:23 +00001139inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001141
1142template <class _A1>
1143inline _LIBCPP_INLINE_VISIBILITY
1144typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001145cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001146
1147// copysign
1148
Richard Smith081bb592015-10-08 20:40:34 +00001149inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x,
1150 float __lcpp_y) _NOEXCEPT {
Mehdi Aminib3da6322017-02-10 02:44:23 +00001151 return ::copysignf(__lcpp_x, __lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001152}
1153inline _LIBCPP_INLINE_VISIBILITY long double
1154copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
Mehdi Aminib3da6322017-02-10 02:44:23 +00001155 return ::copysignl(__lcpp_x, __lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001156}
Richard Smith081bb592015-10-08 20:40:34 +00001157
1158template <class _A1, class _A2>
1159inline _LIBCPP_INLINE_VISIBILITY
1160typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1170 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001171 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001172}
1173
Richard Smith081bb592015-10-08 20:40:34 +00001174// erf
1175
Mehdi Aminib3da6322017-02-10 02:44:23 +00001176inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001178
1179template <class _A1>
1180inline _LIBCPP_INLINE_VISIBILITY
1181typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001182erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001183
1184// erfc
1185
Mehdi Aminib3da6322017-02-10 02:44:23 +00001186inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001188
1189template <class _A1>
1190inline _LIBCPP_INLINE_VISIBILITY
1191typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001192erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001193
1194// exp2
1195
Mehdi Aminib3da6322017-02-10 02:44:23 +00001196inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001198
1199template <class _A1>
1200inline _LIBCPP_INLINE_VISIBILITY
1201typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001202exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001203
1204// expm1
1205
Mehdi Aminib3da6322017-02-10 02:44:23 +00001206inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001208
1209template <class _A1>
1210inline _LIBCPP_INLINE_VISIBILITY
1211typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001212expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001213
1214// fdim
1215
Mehdi Aminib3da6322017-02-10 02:44:23 +00001216inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001218
1219template <class _A1, class _A2>
1220inline _LIBCPP_INLINE_VISIBILITY
1221typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1231 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001232 return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001233}
1234
1235// fma
1236
Mehdi Aminib3da6322017-02-10 02:44:23 +00001237inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001239
1240template <class _A1, class _A2, class _A3>
1241inline _LIBCPP_INLINE_VISIBILITY
1242typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1253 std::is_same<_A2, __result_type>::value &&
1254 std::is_same<_A3, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001255 return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
Richard Smith081bb592015-10-08 20:40:34 +00001256}
1257
1258// fmax
1259
Mehdi Aminib3da6322017-02-10 02:44:23 +00001260inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001262
1263template <class _A1, class _A2>
1264inline _LIBCPP_INLINE_VISIBILITY
1265typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1275 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001276 return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001277}
1278
1279// fmin
1280
Mehdi Aminib3da6322017-02-10 02:44:23 +00001281inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001283
1284template <class _A1, class _A2>
1285inline _LIBCPP_INLINE_VISIBILITY
1286typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1296 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001297 return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001298}
1299
1300// hypot
1301
Mehdi Aminib3da6322017-02-10 02:44:23 +00001302inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001304
1305template <class _A1, class _A2>
1306inline _LIBCPP_INLINE_VISIBILITY
1307typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1317 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001318 return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001319}
1320
1321// ilogb
1322
Mehdi Aminib3da6322017-02-10 02:44:23 +00001323inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001325
1326template <class _A1>
1327inline _LIBCPP_INLINE_VISIBILITY
1328typename std::enable_if<std::is_integral<_A1>::value, int>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001329ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001330
1331// lgamma
1332
Mehdi Aminib3da6322017-02-10 02:44:23 +00001333inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001335
1336template <class _A1>
1337inline _LIBCPP_INLINE_VISIBILITY
1338typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001339lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001340
1341// llrint
1342
Mehdi Aminib3da6322017-02-10 02:44:23 +00001343inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001345
1346template <class _A1>
1347inline _LIBCPP_INLINE_VISIBILITY
1348typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001349llrint(_A1 __lcpp_x) _NOEXCEPT {return ::llrint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001350
1351// llround
1352
Mehdi Aminib3da6322017-02-10 02:44:23 +00001353inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001355
1356template <class _A1>
1357inline _LIBCPP_INLINE_VISIBILITY
1358typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001359llround(_A1 __lcpp_x) _NOEXCEPT {return ::llround((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001360
1361// log1p
1362
Mehdi Aminib3da6322017-02-10 02:44:23 +00001363inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001365
1366template <class _A1>
1367inline _LIBCPP_INLINE_VISIBILITY
1368typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001369log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001370
1371// log2
1372
Mehdi Aminib3da6322017-02-10 02:44:23 +00001373inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001375
1376template <class _A1>
1377inline _LIBCPP_INLINE_VISIBILITY
1378typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001379log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001380
1381// logb
1382
Mehdi Aminib3da6322017-02-10 02:44:23 +00001383inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001385
1386template <class _A1>
1387inline _LIBCPP_INLINE_VISIBILITY
1388typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001389logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001390
1391// lrint
1392
Mehdi Aminib3da6322017-02-10 02:44:23 +00001393inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001395
1396template <class _A1>
1397inline _LIBCPP_INLINE_VISIBILITY
1398typename std::enable_if<std::is_integral<_A1>::value, long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001399lrint(_A1 __lcpp_x) _NOEXCEPT {return ::lrint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001400
1401// lround
1402
Mehdi Aminib3da6322017-02-10 02:44:23 +00001403inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001405
1406template <class _A1>
1407inline _LIBCPP_INLINE_VISIBILITY
1408typename std::enable_if<std::is_integral<_A1>::value, long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001409lround(_A1 __lcpp_x) _NOEXCEPT {return ::lround((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001410
1411// nan
1412
1413// nearbyint
1414
Mehdi Aminib3da6322017-02-10 02:44:23 +00001415inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001417
1418template <class _A1>
1419inline _LIBCPP_INLINE_VISIBILITY
1420typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001421nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001422
1423// nextafter
1424
Mehdi Aminib3da6322017-02-10 02:44:23 +00001425inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001427
1428template <class _A1, class _A2>
1429inline _LIBCPP_INLINE_VISIBILITY
1430typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1440 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001441 return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001442}
1443
1444// nexttoward
1445
Mehdi Aminib3da6322017-02-10 02:44:23 +00001446inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001448
1449template <class _A1>
1450inline _LIBCPP_INLINE_VISIBILITY
1451typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001452nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001453
1454// remainder
1455
Mehdi Aminib3da6322017-02-10 02:44:23 +00001456inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001458
1459template <class _A1, class _A2>
1460inline _LIBCPP_INLINE_VISIBILITY
1461typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1471 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001472 return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001473}
1474
1475// remquo
1476
Mehdi Aminib3da6322017-02-10 02:44:23 +00001477inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001479
1480template <class _A1, class _A2>
1481inline _LIBCPP_INLINE_VISIBILITY
1482typename std::__lazy_enable_if
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::is_same<_A1, __result_type>::value &&
1492 std::is_same<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001493 return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
Richard Smith081bb592015-10-08 20:40:34 +00001494}
1495
1496// rint
1497
Mehdi Aminib3da6322017-02-10 02:44:23 +00001498inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001500
1501template <class _A1>
1502inline _LIBCPP_INLINE_VISIBILITY
1503typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001504rint(_A1 __lcpp_x) _NOEXCEPT {return ::rint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001505
1506// round
1507
Mehdi Aminib3da6322017-02-10 02:44:23 +00001508inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001510
1511template <class _A1>
1512inline _LIBCPP_INLINE_VISIBILITY
1513typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001514round(_A1 __lcpp_x) _NOEXCEPT {return ::round((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001515
1516// scalbln
1517
Mehdi Aminib3da6322017-02-10 02:44:23 +00001518inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001520
1521template <class _A1>
1522inline _LIBCPP_INLINE_VISIBILITY
1523typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001524scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001525
1526// scalbn
1527
Mehdi Aminib3da6322017-02-10 02:44:23 +00001528inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001530
1531template <class _A1>
1532inline _LIBCPP_INLINE_VISIBILITY
1533typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001534scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001535
1536// tgamma
1537
Mehdi Aminib3da6322017-02-10 02:44:23 +00001538inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001540
1541template <class _A1>
1542inline _LIBCPP_INLINE_VISIBILITY
1543typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001544tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001545
1546// trunc
1547
Mehdi Aminib3da6322017-02-10 02:44:23 +00001548inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001550
1551template <class _A1>
1552inline _LIBCPP_INLINE_VISIBILITY
1553typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001554trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001555
Richard Smith081bb592015-10-08 20:40:34 +00001556} // extern "C++"
1557
1558#endif // __cplusplus
1559
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001560#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
Richard Smith081bb592015-10-08 20:40:34 +00001574#endif // _LIBCPP_MATH_H