blob: c9b4733e9c446cfaeb69ac85f803c1b24beed9ae [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{
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500513#if __has_builtin(__builtin_isnan)
514 return __builtin_isnan(__lcpp_x);
515#else
Richard Smith081bb592015-10-08 20:40:34 +0000516 return isnan(__lcpp_x);
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500517#endif
Richard Smith081bb592015-10-08 20:40:34 +0000518}
519
520#undef isnan
521
522template <class _A1>
523inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000524typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000525isnan(_A1 __lcpp_x) _NOEXCEPT
526{
527 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
528}
529
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000530template <class _A1>
531inline _LIBCPP_INLINE_VISIBILITY
532typename std::enable_if<std::is_integral<_A1>::value, bool>::type
533isnan(_A1) _NOEXCEPT
534{ return false; }
535
Richard Smithafccfd32018-05-01 03:05:40 +0000536#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
Richard Smith081bb592015-10-08 20:40:34 +0000550#endif // isnan
551
552// isnormal
553
554#ifdef isnormal
555
556template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000557_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000558bool
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
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000568typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000569isnormal(_A1 __lcpp_x) _NOEXCEPT
570{
571 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
572}
573
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000574template <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
Richard Smith081bb592015-10-08 20:40:34 +0000580#endif // isnormal
581
582// isgreater
583
584#ifdef isgreater
585
586template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000587_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000588bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000617_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000618bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000647_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000648bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000677_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000678bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000707_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000708bool
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>
Louis Dionne16fe2952018-07-11 23:14:33 +0000737_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000738bool
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
Richard Smith081bb592015-10-08 20:40:34 +0000762// abs
763
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000764#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
Eric Fiselier7d1aac92016-08-15 18:58:57 +0000783#if !(defined(_AIX) || defined(__sun__))
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000784inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
785 return ::fabsf(__lcpp_x);
786}
Richard Smith081bb592015-10-08 20:40:34 +0000787
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000788inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
789 return ::fabs(__lcpp_x);
790}
Richard Smith081bb592015-10-08 20:40:34 +0000791
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000792inline _LIBCPP_INLINE_VISIBILITY long double
793abs(long double __lcpp_x) _NOEXCEPT {
794 return ::fabsl(__lcpp_x);
795}
Eric Fiselier7d1aac92016-08-15 18:58:57 +0000796#endif // !(defined(_AIX) || defined(__sun__))
Richard Smith081bb592015-10-08 20:40:34 +0000797
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000798// 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
Richard Smith081bb592015-10-08 20:40:34 +0000819// acos
820
Shoaib Meenai159375f2017-04-07 02:20:52 +0000821#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000822inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000824#endif
825
826template <class _A1>
827inline _LIBCPP_INLINE_VISIBILITY
828typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000829acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000830
831// asin
832
Shoaib Meenai159375f2017-04-07 02:20:52 +0000833#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000834inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000836#endif
837
838template <class _A1>
839inline _LIBCPP_INLINE_VISIBILITY
840typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000841asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000842
843// atan
844
Shoaib Meenai159375f2017-04-07 02:20:52 +0000845#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000846inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000848#endif
849
850template <class _A1>
851inline _LIBCPP_INLINE_VISIBILITY
852typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000853atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000854
855// atan2
856
Shoaib Meenai159375f2017-04-07 02:20:52 +0000857#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000858inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000860#endif
861
862template <class _A1, class _A2>
863inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +0000864typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +0000865<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +0000873 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
874 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000875 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
Richard Smith081bb592015-10-08 20:40:34 +0000876}
877
878// ceil
879
Shoaib Meenai159375f2017-04-07 02:20:52 +0000880#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000881inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000883#endif
884
885template <class _A1>
886inline _LIBCPP_INLINE_VISIBILITY
887typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000888ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000889
890// cos
891
Shoaib Meenai159375f2017-04-07 02:20:52 +0000892#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000893inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000895#endif
896
897template <class _A1>
898inline _LIBCPP_INLINE_VISIBILITY
899typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000900cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000901
902// cosh
903
Shoaib Meenai159375f2017-04-07 02:20:52 +0000904#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000905inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000907#endif
908
909template <class _A1>
910inline _LIBCPP_INLINE_VISIBILITY
911typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000912cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000913
914// exp
915
Shoaib Meenai159375f2017-04-07 02:20:52 +0000916#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000917inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000919#endif
920
921template <class _A1>
922inline _LIBCPP_INLINE_VISIBILITY
923typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000924exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000925
926// fabs
927
Shoaib Meenai159375f2017-04-07 02:20:52 +0000928#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000929inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000931#endif
932
933template <class _A1>
934inline _LIBCPP_INLINE_VISIBILITY
935typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000936fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000937
938// floor
939
Shoaib Meenai159375f2017-04-07 02:20:52 +0000940#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000941inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000943#endif
944
945template <class _A1>
946inline _LIBCPP_INLINE_VISIBILITY
947typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000948floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000949
950// fmod
951
Shoaib Meenai159375f2017-04-07 02:20:52 +0000952#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000953inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000955#endif
956
957template <class _A1, class _A2>
958inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +0000959typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +0000960<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +0000968 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
969 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000970 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +0000971}
972
973// frexp
974
Shoaib Meenai159375f2017-04-07 02:20:52 +0000975#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000976inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000978#endif
979
980template <class _A1>
981inline _LIBCPP_INLINE_VISIBILITY
982typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000983frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000984
985// ldexp
986
Shoaib Meenai159375f2017-04-07 02:20:52 +0000987#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000988inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +0000990#endif
991
992template <class _A1>
993inline _LIBCPP_INLINE_VISIBILITY
994typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000995ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000996
997// log
998
Shoaib Meenai159375f2017-04-07 02:20:52 +0000999#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001000inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001002#endif
1003
1004template <class _A1>
1005inline _LIBCPP_INLINE_VISIBILITY
1006typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001007log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001008
1009// log10
1010
Shoaib Meenai159375f2017-04-07 02:20:52 +00001011#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001012inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001014#endif
1015
1016template <class _A1>
1017inline _LIBCPP_INLINE_VISIBILITY
1018typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001019log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001020
1021// modf
1022
Shoaib Meenai159375f2017-04-07 02:20:52 +00001023#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001024inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001026#endif
1027
1028// pow
1029
Shoaib Meenai159375f2017-04-07 02:20:52 +00001030#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001031inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001033#endif
1034
1035template <class _A1, class _A2>
1036inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001037typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001038<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001046 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1047 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001048 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001049}
1050
1051// sin
1052
Shoaib Meenai159375f2017-04-07 02:20:52 +00001053#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001054inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001056#endif
1057
1058template <class _A1>
1059inline _LIBCPP_INLINE_VISIBILITY
1060typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001061sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001062
1063// sinh
1064
Shoaib Meenai159375f2017-04-07 02:20:52 +00001065#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001066inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001068#endif
1069
1070template <class _A1>
1071inline _LIBCPP_INLINE_VISIBILITY
1072typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001073sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001074
1075// sqrt
1076
Shoaib Meenai159375f2017-04-07 02:20:52 +00001077#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001078inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001080#endif
1081
Richard Smith081bb592015-10-08 20:40:34 +00001082template <class _A1>
1083inline _LIBCPP_INLINE_VISIBILITY
1084typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001085sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001086
1087// tan
1088
Shoaib Meenai159375f2017-04-07 02:20:52 +00001089#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001090inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001092#endif
1093
1094template <class _A1>
1095inline _LIBCPP_INLINE_VISIBILITY
1096typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001097tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001098
1099// tanh
1100
Shoaib Meenai159375f2017-04-07 02:20:52 +00001101#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001102inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001104#endif
1105
1106template <class _A1>
1107inline _LIBCPP_INLINE_VISIBILITY
1108typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001109tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001110
1111// acosh
1112
Mehdi Aminib3da6322017-02-10 02:44:23 +00001113inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001115
1116template <class _A1>
1117inline _LIBCPP_INLINE_VISIBILITY
1118typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001119acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001120
1121// asinh
1122
Mehdi Aminib3da6322017-02-10 02:44:23 +00001123inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001125
1126template <class _A1>
1127inline _LIBCPP_INLINE_VISIBILITY
1128typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001129asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001130
1131// atanh
1132
Mehdi Aminib3da6322017-02-10 02:44:23 +00001133inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001135
1136template <class _A1>
1137inline _LIBCPP_INLINE_VISIBILITY
1138typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001139atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001140
1141// cbrt
1142
Mehdi Aminib3da6322017-02-10 02:44:23 +00001143inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001145
1146template <class _A1>
1147inline _LIBCPP_INLINE_VISIBILITY
1148typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001149cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001150
1151// copysign
1152
Richard Smith081bb592015-10-08 20:40:34 +00001153inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x,
1154 float __lcpp_y) _NOEXCEPT {
Mehdi Aminib3da6322017-02-10 02:44:23 +00001155 return ::copysignf(__lcpp_x, __lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001156}
1157inline _LIBCPP_INLINE_VISIBILITY long double
1158copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
Mehdi Aminib3da6322017-02-10 02:44:23 +00001159 return ::copysignl(__lcpp_x, __lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001160}
Richard Smith081bb592015-10-08 20:40:34 +00001161
1162template <class _A1, class _A2>
1163inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001164typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001165<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001173 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1174 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001175 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001176}
1177
Richard Smith081bb592015-10-08 20:40:34 +00001178// erf
1179
Mehdi Aminib3da6322017-02-10 02:44:23 +00001180inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001182
1183template <class _A1>
1184inline _LIBCPP_INLINE_VISIBILITY
1185typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001186erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001187
1188// erfc
1189
Mehdi Aminib3da6322017-02-10 02:44:23 +00001190inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001192
1193template <class _A1>
1194inline _LIBCPP_INLINE_VISIBILITY
1195typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001196erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001197
1198// exp2
1199
Mehdi Aminib3da6322017-02-10 02:44:23 +00001200inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001202
1203template <class _A1>
1204inline _LIBCPP_INLINE_VISIBILITY
1205typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001206exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001207
1208// expm1
1209
Mehdi Aminib3da6322017-02-10 02:44:23 +00001210inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001212
1213template <class _A1>
1214inline _LIBCPP_INLINE_VISIBILITY
1215typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001216expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001217
1218// fdim
1219
Mehdi Aminib3da6322017-02-10 02:44:23 +00001220inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001222
1223template <class _A1, class _A2>
1224inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001225typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001226<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001234 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1235 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001236 return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001237}
1238
1239// fma
1240
Mehdi Aminib3da6322017-02-10 02:44:23 +00001241inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001243
1244template <class _A1, class _A2, class _A3>
1245inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001246typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001247<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001256 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1257 std::_IsSame<_A2, __result_type>::value &&
1258 std::_IsSame<_A3, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001259 return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
Richard Smith081bb592015-10-08 20:40:34 +00001260}
1261
1262// fmax
1263
Mehdi Aminib3da6322017-02-10 02:44:23 +00001264inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001266
1267template <class _A1, class _A2>
1268inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001269typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001270<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001278 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1279 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001280 return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001281}
1282
1283// fmin
1284
Mehdi Aminib3da6322017-02-10 02:44:23 +00001285inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001287
1288template <class _A1, class _A2>
1289inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001290typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001291<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001299 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1300 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001301 return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001302}
1303
1304// hypot
1305
Mehdi Aminib3da6322017-02-10 02:44:23 +00001306inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001308
1309template <class _A1, class _A2>
1310inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001311typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001312<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001320 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1321 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001322 return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001323}
1324
1325// ilogb
1326
Mehdi Aminib3da6322017-02-10 02:44:23 +00001327inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001329
1330template <class _A1>
1331inline _LIBCPP_INLINE_VISIBILITY
1332typename std::enable_if<std::is_integral<_A1>::value, int>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001333ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001334
1335// lgamma
1336
Mehdi Aminib3da6322017-02-10 02:44:23 +00001337inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001339
1340template <class _A1>
1341inline _LIBCPP_INLINE_VISIBILITY
1342typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001343lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001344
1345// llrint
1346
Mehdi Aminib3da6322017-02-10 02:44:23 +00001347inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001349
1350template <class _A1>
1351inline _LIBCPP_INLINE_VISIBILITY
1352typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001353llrint(_A1 __lcpp_x) _NOEXCEPT {return ::llrint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001354
1355// llround
1356
Mehdi Aminib3da6322017-02-10 02:44:23 +00001357inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001359
1360template <class _A1>
1361inline _LIBCPP_INLINE_VISIBILITY
1362typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001363llround(_A1 __lcpp_x) _NOEXCEPT {return ::llround((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001364
1365// log1p
1366
Mehdi Aminib3da6322017-02-10 02:44:23 +00001367inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001369
1370template <class _A1>
1371inline _LIBCPP_INLINE_VISIBILITY
1372typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001373log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001374
1375// log2
1376
Mehdi Aminib3da6322017-02-10 02:44:23 +00001377inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001379
1380template <class _A1>
1381inline _LIBCPP_INLINE_VISIBILITY
1382typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001383log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001384
1385// logb
1386
Mehdi Aminib3da6322017-02-10 02:44:23 +00001387inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001389
1390template <class _A1>
1391inline _LIBCPP_INLINE_VISIBILITY
1392typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001393logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001394
1395// lrint
1396
Mehdi Aminib3da6322017-02-10 02:44:23 +00001397inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001399
1400template <class _A1>
1401inline _LIBCPP_INLINE_VISIBILITY
1402typename std::enable_if<std::is_integral<_A1>::value, long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001403lrint(_A1 __lcpp_x) _NOEXCEPT {return ::lrint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001404
1405// lround
1406
Mehdi Aminib3da6322017-02-10 02:44:23 +00001407inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001409
1410template <class _A1>
1411inline _LIBCPP_INLINE_VISIBILITY
1412typename std::enable_if<std::is_integral<_A1>::value, long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001413lround(_A1 __lcpp_x) _NOEXCEPT {return ::lround((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001414
1415// nan
1416
1417// nearbyint
1418
Mehdi Aminib3da6322017-02-10 02:44:23 +00001419inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001421
1422template <class _A1>
1423inline _LIBCPP_INLINE_VISIBILITY
1424typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001425nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001426
1427// nextafter
1428
Mehdi Aminib3da6322017-02-10 02:44:23 +00001429inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001431
1432template <class _A1, class _A2>
1433inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001434typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001435<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001443 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1444 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001445 return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001446}
1447
1448// nexttoward
1449
Mehdi Aminib3da6322017-02-10 02:44:23 +00001450inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001452
1453template <class _A1>
1454inline _LIBCPP_INLINE_VISIBILITY
1455typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001456nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001457
1458// remainder
1459
Mehdi Aminib3da6322017-02-10 02:44:23 +00001460inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001462
1463template <class _A1, class _A2>
1464inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001465typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001466<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001474 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1475 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001476 return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001477}
1478
1479// remquo
1480
Mehdi Aminib3da6322017-02-10 02:44:23 +00001481inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001483
1484template <class _A1, class _A2>
1485inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001486typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001487<
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;
Eric Fiselier3906a132019-06-23 20:28:29 +00001495 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1496 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001497 return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
Richard Smith081bb592015-10-08 20:40:34 +00001498}
1499
1500// rint
1501
Mehdi Aminib3da6322017-02-10 02:44:23 +00001502inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001504
1505template <class _A1>
1506inline _LIBCPP_INLINE_VISIBILITY
1507typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001508rint(_A1 __lcpp_x) _NOEXCEPT {return ::rint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001509
1510// round
1511
Mehdi Aminib3da6322017-02-10 02:44:23 +00001512inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001514
1515template <class _A1>
1516inline _LIBCPP_INLINE_VISIBILITY
1517typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001518round(_A1 __lcpp_x) _NOEXCEPT {return ::round((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001519
1520// scalbln
1521
Mehdi Aminib3da6322017-02-10 02:44:23 +00001522inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001524
1525template <class _A1>
1526inline _LIBCPP_INLINE_VISIBILITY
1527typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001528scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001529
1530// scalbn
1531
Mehdi Aminib3da6322017-02-10 02:44:23 +00001532inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001534
1535template <class _A1>
1536inline _LIBCPP_INLINE_VISIBILITY
1537typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001538scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001539
1540// tgamma
1541
Mehdi Aminib3da6322017-02-10 02:44:23 +00001542inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001544
1545template <class _A1>
1546inline _LIBCPP_INLINE_VISIBILITY
1547typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001548tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001549
1550// trunc
1551
Mehdi Aminib3da6322017-02-10 02:44:23 +00001552inline _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);}
Richard Smith081bb592015-10-08 20:40:34 +00001554
1555template <class _A1>
1556inline _LIBCPP_INLINE_VISIBILITY
1557typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001558trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001559
Richard Smith081bb592015-10-08 20:40:34 +00001560} // extern "C++"
1561
1562#endif // __cplusplus
1563
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001564#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
Richard Smith081bb592015-10-08 20:40:34 +00001578#endif // _LIBCPP_MATH_H