blob: 1603d5748e2d4d44df646b36cfb664ec79b234cb [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
Mikhail Maltsev34b4f972018-02-22 09:34:08 +0000300#include_next <math.h>
301
Richard Smith081bb592015-10-08 20:40:34 +0000302#ifdef __cplusplus
303
304// We support including .h headers inside 'extern "C"' contexts, so switch
305// back to C++ linkage before including these C++ headers.
306extern "C++" {
307
Eric Fiselier3afa64f2020-02-15 18:55:07 -0500308#include <stdlib.h>
Richard Smith081bb592015-10-08 20:40:34 +0000309#include <type_traits>
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000310#include <limits>
Richard Smith081bb592015-10-08 20:40:34 +0000311
Richard Smith081bb592015-10-08 20:40:34 +0000312// signbit
313
314#ifdef signbit
315
316template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000317_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000318bool
319__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
320{
321 return signbit(__lcpp_x);
322}
323
324#undef signbit
325
326template <class _A1>
327inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000328typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000329signbit(_A1 __lcpp_x) _NOEXCEPT
330{
331 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
332}
333
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000334template <class _A1>
335inline _LIBCPP_INLINE_VISIBILITY
336typename std::enable_if<
337 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
338signbit(_A1 __lcpp_x) _NOEXCEPT
339{ return __lcpp_x < 0; }
340
341template <class _A1>
342inline _LIBCPP_INLINE_VISIBILITY
343typename std::enable_if<
344 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
345signbit(_A1) _NOEXCEPT
346{ return false; }
347
Shoaib Meenai159375f2017-04-07 02:20:52 +0000348#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000349
350template <typename _A1>
351inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000352typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000353signbit(_A1 __lcpp_x) _NOEXCEPT
354{
355 return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
356}
357
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000358template <class _A1>
359inline _LIBCPP_INLINE_VISIBILITY
360typename std::enable_if<
361 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
362signbit(_A1 __lcpp_x) _NOEXCEPT
363{ return __lcpp_x < 0; }
364
365template <class _A1>
366inline _LIBCPP_INLINE_VISIBILITY
367typename std::enable_if<
368 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
369signbit(_A1) _NOEXCEPT
370{ return false; }
371
Richard Smith081bb592015-10-08 20:40:34 +0000372#endif // signbit
373
374// fpclassify
375
376#ifdef fpclassify
377
378template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000379_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000380int
381__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
382{
383 return fpclassify(__lcpp_x);
384}
385
386#undef fpclassify
387
388template <class _A1>
389inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000390typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
Richard Smith081bb592015-10-08 20:40:34 +0000391fpclassify(_A1 __lcpp_x) _NOEXCEPT
392{
393 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
394}
395
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000396template <class _A1>
397inline _LIBCPP_INLINE_VISIBILITY
398typename std::enable_if<std::is_integral<_A1>::value, int>::type
399fpclassify(_A1 __lcpp_x) _NOEXCEPT
400{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
401
Shoaib Meenai159375f2017-04-07 02:20:52 +0000402#elif defined(_LIBCPP_MSVCRT)
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000403
404template <typename _A1>
405inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000406typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Saleem Abdulrasool257256b2017-02-18 19:28:38 +0000407fpclassify(_A1 __lcpp_x) _NOEXCEPT
408{
409 return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));
410}
411
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000412template <class _A1>
413inline _LIBCPP_INLINE_VISIBILITY
414typename std::enable_if<std::is_integral<_A1>::value, int>::type
415fpclassify(_A1 __lcpp_x) _NOEXCEPT
416{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
417
Richard Smith081bb592015-10-08 20:40:34 +0000418#endif // fpclassify
419
420// isfinite
421
422#ifdef isfinite
423
424template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000425_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000426bool
427__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
428{
429 return isfinite(__lcpp_x);
430}
431
432#undef isfinite
433
434template <class _A1>
435inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000436typename std::enable_if<
437 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
438 bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000439isfinite(_A1 __lcpp_x) _NOEXCEPT
440{
441 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
442}
443
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000444template <class _A1>
445inline _LIBCPP_INLINE_VISIBILITY
446typename std::enable_if<
447 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
448 bool>::type
449isfinite(_A1) _NOEXCEPT
450{ return true; }
451
Richard Smith081bb592015-10-08 20:40:34 +0000452#endif // isfinite
453
454// isinf
455
456#ifdef isinf
457
458template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000459_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000460bool
461__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
462{
463 return isinf(__lcpp_x);
464}
465
466#undef isinf
467
468template <class _A1>
469inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000470typename std::enable_if<
471 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
472 bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000473isinf(_A1 __lcpp_x) _NOEXCEPT
474{
475 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
476}
477
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000478template <class _A1>
479inline _LIBCPP_INLINE_VISIBILITY
480typename std::enable_if<
481 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
482 bool>::type
483isinf(_A1) _NOEXCEPT
484{ return false; }
485
Richard Smithafccfd32018-05-01 03:05:40 +0000486#ifdef _LIBCPP_PREFERRED_OVERLOAD
487inline _LIBCPP_INLINE_VISIBILITY
488bool
489isinf(float __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
490
491inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
492bool
493isinf(double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
494
495inline _LIBCPP_INLINE_VISIBILITY
496bool
497isinf(long double __lcpp_x) _NOEXCEPT { return __libcpp_isinf(__lcpp_x); }
498#endif
499
Richard Smith081bb592015-10-08 20:40:34 +0000500#endif // isinf
501
502// isnan
503
504#ifdef isnan
505
506template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000507_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000508bool
509__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
510{
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500511#if __has_builtin(__builtin_isnan)
512 return __builtin_isnan(__lcpp_x);
513#else
Richard Smith081bb592015-10-08 20:40:34 +0000514 return isnan(__lcpp_x);
Ilya Tokar6caf83a2019-11-15 12:29:02 -0500515#endif
Richard Smith081bb592015-10-08 20:40:34 +0000516}
517
518#undef isnan
519
520template <class _A1>
521inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000522typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000523isnan(_A1 __lcpp_x) _NOEXCEPT
524{
525 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
526}
527
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000528template <class _A1>
529inline _LIBCPP_INLINE_VISIBILITY
530typename std::enable_if<std::is_integral<_A1>::value, bool>::type
531isnan(_A1) _NOEXCEPT
532{ return false; }
533
Richard Smithafccfd32018-05-01 03:05:40 +0000534#ifdef _LIBCPP_PREFERRED_OVERLOAD
535inline _LIBCPP_INLINE_VISIBILITY
536bool
537isnan(float __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
538
539inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD
540bool
541isnan(double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
542
543inline _LIBCPP_INLINE_VISIBILITY
544bool
545isnan(long double __lcpp_x) _NOEXCEPT { return __libcpp_isnan(__lcpp_x); }
546#endif
547
Richard Smith081bb592015-10-08 20:40:34 +0000548#endif // isnan
549
550// isnormal
551
552#ifdef isnormal
553
554template <class _A1>
Louis Dionne16fe2952018-07-11 23:14:33 +0000555_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000556bool
557__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
558{
559 return isnormal(__lcpp_x);
560}
561
562#undef isnormal
563
564template <class _A1>
565inline _LIBCPP_INLINE_VISIBILITY
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000566typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
Richard Smith081bb592015-10-08 20:40:34 +0000567isnormal(_A1 __lcpp_x) _NOEXCEPT
568{
569 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
570}
571
Duncan P. N. Exon Smith321d6bf2017-04-21 23:14:55 +0000572template <class _A1>
573inline _LIBCPP_INLINE_VISIBILITY
574typename std::enable_if<std::is_integral<_A1>::value, bool>::type
575isnormal(_A1 __lcpp_x) _NOEXCEPT
576{ return __lcpp_x != 0; }
577
Richard Smith081bb592015-10-08 20:40:34 +0000578#endif // isnormal
579
580// isgreater
581
582#ifdef isgreater
583
584template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000585_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000586bool
587__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
588{
589 return isgreater(__lcpp_x, __lcpp_y);
590}
591
592#undef isgreater
593
594template <class _A1, class _A2>
595inline _LIBCPP_INLINE_VISIBILITY
596typename std::enable_if
597<
598 std::is_arithmetic<_A1>::value &&
599 std::is_arithmetic<_A2>::value,
600 bool
601>::type
602isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
603{
604 typedef typename std::__promote<_A1, _A2>::type type;
605 return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);
606}
607
608#endif // isgreater
609
610// isgreaterequal
611
612#ifdef isgreaterequal
613
614template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000615_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000616bool
617__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
618{
619 return isgreaterequal(__lcpp_x, __lcpp_y);
620}
621
622#undef isgreaterequal
623
624template <class _A1, class _A2>
625inline _LIBCPP_INLINE_VISIBILITY
626typename std::enable_if
627<
628 std::is_arithmetic<_A1>::value &&
629 std::is_arithmetic<_A2>::value,
630 bool
631>::type
632isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
633{
634 typedef typename std::__promote<_A1, _A2>::type type;
635 return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
636}
637
638#endif // isgreaterequal
639
640// isless
641
642#ifdef isless
643
644template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000645_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000646bool
647__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
648{
649 return isless(__lcpp_x, __lcpp_y);
650}
651
652#undef isless
653
654template <class _A1, class _A2>
655inline _LIBCPP_INLINE_VISIBILITY
656typename std::enable_if
657<
658 std::is_arithmetic<_A1>::value &&
659 std::is_arithmetic<_A2>::value,
660 bool
661>::type
662isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
663{
664 typedef typename std::__promote<_A1, _A2>::type type;
665 return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
666}
667
668#endif // isless
669
670// islessequal
671
672#ifdef islessequal
673
674template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000675_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000676bool
677__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
678{
679 return islessequal(__lcpp_x, __lcpp_y);
680}
681
682#undef islessequal
683
684template <class _A1, class _A2>
685inline _LIBCPP_INLINE_VISIBILITY
686typename std::enable_if
687<
688 std::is_arithmetic<_A1>::value &&
689 std::is_arithmetic<_A2>::value,
690 bool
691>::type
692islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
693{
694 typedef typename std::__promote<_A1, _A2>::type type;
695 return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
696}
697
698#endif // islessequal
699
700// islessgreater
701
702#ifdef islessgreater
703
704template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000705_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000706bool
707__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
708{
709 return islessgreater(__lcpp_x, __lcpp_y);
710}
711
712#undef islessgreater
713
714template <class _A1, class _A2>
715inline _LIBCPP_INLINE_VISIBILITY
716typename std::enable_if
717<
718 std::is_arithmetic<_A1>::value &&
719 std::is_arithmetic<_A2>::value,
720 bool
721>::type
722islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
723{
724 typedef typename std::__promote<_A1, _A2>::type type;
725 return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
726}
727
728#endif // islessgreater
729
730// isunordered
731
732#ifdef isunordered
733
734template <class _A1, class _A2>
Louis Dionne16fe2952018-07-11 23:14:33 +0000735_LIBCPP_INLINE_VISIBILITY
Richard Smith081bb592015-10-08 20:40:34 +0000736bool
737__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
738{
739 return isunordered(__lcpp_x, __lcpp_y);
740}
741
742#undef isunordered
743
744template <class _A1, class _A2>
745inline _LIBCPP_INLINE_VISIBILITY
746typename std::enable_if
747<
748 std::is_arithmetic<_A1>::value &&
749 std::is_arithmetic<_A2>::value,
750 bool
751>::type
752isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
753{
754 typedef typename std::__promote<_A1, _A2>::type type;
755 return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
756}
757
758#endif // isunordered
759
Richard Smith081bb592015-10-08 20:40:34 +0000760// abs
Eric Fiselier3afa64f2020-02-15 18:55:07 -0500761//
762// handled in stdlib.h
Richard Smith081bb592015-10-08 20:40:34 +0000763
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000764// div
Eric Fiselier3afa64f2020-02-15 18:55:07 -0500765//
766// handled in stdlib.h
Eric Fiselier2b85c6e2019-04-23 18:01:58 +0000767
Richard Smith081bb592015-10-08 20:40:34 +0000768// acos
769
Shoaib Meenai159375f2017-04-07 02:20:52 +0000770#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000771inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
772inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000773#endif
774
775template <class _A1>
776inline _LIBCPP_INLINE_VISIBILITY
777typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000778acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000779
780// asin
781
Shoaib Meenai159375f2017-04-07 02:20:52 +0000782#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000783inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
784inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000785#endif
786
787template <class _A1>
788inline _LIBCPP_INLINE_VISIBILITY
789typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000790asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000791
792// atan
793
Shoaib Meenai159375f2017-04-07 02:20:52 +0000794#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000795inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
796inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000797#endif
798
799template <class _A1>
800inline _LIBCPP_INLINE_VISIBILITY
801typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000802atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000803
804// atan2
805
Shoaib Meenai159375f2017-04-07 02:20:52 +0000806#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000807inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
808inline _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 +0000809#endif
810
811template <class _A1, class _A2>
812inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +0000813typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +0000814<
815 std::is_arithmetic<_A1>::value &&
816 std::is_arithmetic<_A2>::value,
817 std::__promote<_A1, _A2>
818>::type
819atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
820{
821 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000822 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
823 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000824 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
Richard Smith081bb592015-10-08 20:40:34 +0000825}
826
827// ceil
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 ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
831inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__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 +0000837ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000838
839// cos
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 cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
843inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__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 +0000849cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000850
851// cosh
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 cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
855inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000856#endif
857
858template <class _A1>
859inline _LIBCPP_INLINE_VISIBILITY
860typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000861cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000862
863// exp
864
Shoaib Meenai159375f2017-04-07 02:20:52 +0000865#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000866inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
867inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000868#endif
869
870template <class _A1>
871inline _LIBCPP_INLINE_VISIBILITY
872typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000873exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000874
875// fabs
876
Shoaib Meenai159375f2017-04-07 02:20:52 +0000877#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000878inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
879inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000880#endif
881
882template <class _A1>
883inline _LIBCPP_INLINE_VISIBILITY
884typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000885fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000886
887// floor
888
Shoaib Meenai159375f2017-04-07 02:20:52 +0000889#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000890inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
891inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000892#endif
893
894template <class _A1>
895inline _LIBCPP_INLINE_VISIBILITY
896typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000897floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000898
899// fmod
900
Shoaib Meenai159375f2017-04-07 02:20:52 +0000901#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000902inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
903inline _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 +0000904#endif
905
906template <class _A1, class _A2>
907inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +0000908typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +0000909<
910 std::is_arithmetic<_A1>::value &&
911 std::is_arithmetic<_A2>::value,
912 std::__promote<_A1, _A2>
913>::type
914fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
915{
916 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000917 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
918 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000919 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +0000920}
921
922// frexp
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 frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
926inline _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 +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 +0000932frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000933
934// ldexp
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 ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
938inline _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 +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 +0000944ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __lcpp_e);}
Richard Smith081bb592015-10-08 20:40:34 +0000945
946// log
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 log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
950inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000951#endif
952
953template <class _A1>
954inline _LIBCPP_INLINE_VISIBILITY
955typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000956log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000957
958// log10
959
Shoaib Meenai159375f2017-04-07 02:20:52 +0000960#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000961inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
962inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000963#endif
964
965template <class _A1>
966inline _LIBCPP_INLINE_VISIBILITY
967typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +0000968log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +0000969
970// modf
971
Shoaib Meenai159375f2017-04-07 02:20:52 +0000972#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000973inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
974inline _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 +0000975#endif
976
977// pow
978
Shoaib Meenai159375f2017-04-07 02:20:52 +0000979#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +0000980inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
981inline _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 +0000982#endif
983
984template <class _A1, class _A2>
985inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +0000986typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +0000987<
988 std::is_arithmetic<_A1>::value &&
989 std::is_arithmetic<_A2>::value,
990 std::__promote<_A1, _A2>
991>::type
992pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
993{
994 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +0000995 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
996 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +0000997 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +0000998}
999
1000// sin
1001
Shoaib Meenai159375f2017-04-07 02:20:52 +00001002#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001003inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
1004inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001005#endif
1006
1007template <class _A1>
1008inline _LIBCPP_INLINE_VISIBILITY
1009typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001010sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001011
1012// sinh
1013
Shoaib Meenai159375f2017-04-07 02:20:52 +00001014#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001015inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
1016inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001017#endif
1018
1019template <class _A1>
1020inline _LIBCPP_INLINE_VISIBILITY
1021typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001022sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001023
1024// sqrt
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 sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
1028inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001029#endif
1030
Richard Smith081bb592015-10-08 20:40:34 +00001031template <class _A1>
1032inline _LIBCPP_INLINE_VISIBILITY
1033typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001034sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001035
1036// tan
1037
Shoaib Meenai159375f2017-04-07 02:20:52 +00001038#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001039inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
1040inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001041#endif
1042
1043template <class _A1>
1044inline _LIBCPP_INLINE_VISIBILITY
1045typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001046tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001047
1048// tanh
1049
Shoaib Meenai159375f2017-04-07 02:20:52 +00001050#if !(defined(_AIX) || defined(__sun__))
Mehdi Aminib3da6322017-02-10 02:44:23 +00001051inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
1052inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001053#endif
1054
1055template <class _A1>
1056inline _LIBCPP_INLINE_VISIBILITY
1057typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001058tanh(_A1 __lcpp_x) _NOEXCEPT {return ::tanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001059
1060// acosh
1061
Mehdi Aminib3da6322017-02-10 02:44:23 +00001062inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return ::acoshf(__lcpp_x);}
1063inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return ::acoshl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001064
1065template <class _A1>
1066inline _LIBCPP_INLINE_VISIBILITY
1067typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001068acosh(_A1 __lcpp_x) _NOEXCEPT {return ::acosh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001069
1070// asinh
1071
Mehdi Aminib3da6322017-02-10 02:44:23 +00001072inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return ::asinhf(__lcpp_x);}
1073inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return ::asinhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001074
1075template <class _A1>
1076inline _LIBCPP_INLINE_VISIBILITY
1077typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001078asinh(_A1 __lcpp_x) _NOEXCEPT {return ::asinh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001079
1080// atanh
1081
Mehdi Aminib3da6322017-02-10 02:44:23 +00001082inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return ::atanhf(__lcpp_x);}
1083inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return ::atanhl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001084
1085template <class _A1>
1086inline _LIBCPP_INLINE_VISIBILITY
1087typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001088atanh(_A1 __lcpp_x) _NOEXCEPT {return ::atanh((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001089
1090// cbrt
1091
Mehdi Aminib3da6322017-02-10 02:44:23 +00001092inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return ::cbrtf(__lcpp_x);}
1093inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return ::cbrtl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001094
1095template <class _A1>
1096inline _LIBCPP_INLINE_VISIBILITY
1097typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001098cbrt(_A1 __lcpp_x) _NOEXCEPT {return ::cbrt((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001099
1100// copysign
1101
Richard Smith081bb592015-10-08 20:40:34 +00001102inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x,
1103 float __lcpp_y) _NOEXCEPT {
Mehdi Aminib3da6322017-02-10 02:44:23 +00001104 return ::copysignf(__lcpp_x, __lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001105}
1106inline _LIBCPP_INLINE_VISIBILITY long double
1107copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
Mehdi Aminib3da6322017-02-10 02:44:23 +00001108 return ::copysignl(__lcpp_x, __lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001109}
Richard Smith081bb592015-10-08 20:40:34 +00001110
1111template <class _A1, class _A2>
1112inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001113typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001114<
1115 std::is_arithmetic<_A1>::value &&
1116 std::is_arithmetic<_A2>::value,
1117 std::__promote<_A1, _A2>
1118>::type
1119copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1120{
1121 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001122 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1123 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001124 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001125}
1126
Richard Smith081bb592015-10-08 20:40:34 +00001127// erf
1128
Mehdi Aminib3da6322017-02-10 02:44:23 +00001129inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return ::erff(__lcpp_x);}
1130inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return ::erfl(__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 +00001135erf(_A1 __lcpp_x) _NOEXCEPT {return ::erf((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001136
1137// erfc
1138
Mehdi Aminib3da6322017-02-10 02:44:23 +00001139inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return ::erfcf(__lcpp_x);}
1140inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return ::erfcl(__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 +00001145erfc(_A1 __lcpp_x) _NOEXCEPT {return ::erfc((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001146
1147// exp2
1148
Mehdi Aminib3da6322017-02-10 02:44:23 +00001149inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return ::exp2f(__lcpp_x);}
1150inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return ::exp2l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001151
1152template <class _A1>
1153inline _LIBCPP_INLINE_VISIBILITY
1154typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001155exp2(_A1 __lcpp_x) _NOEXCEPT {return ::exp2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001156
1157// expm1
1158
Mehdi Aminib3da6322017-02-10 02:44:23 +00001159inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return ::expm1f(__lcpp_x);}
1160inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return ::expm1l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001161
1162template <class _A1>
1163inline _LIBCPP_INLINE_VISIBILITY
1164typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001165expm1(_A1 __lcpp_x) _NOEXCEPT {return ::expm1((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001166
1167// fdim
1168
Mehdi Aminib3da6322017-02-10 02:44:23 +00001169inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fdimf(__lcpp_x, __lcpp_y);}
1170inline _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 +00001171
1172template <class _A1, class _A2>
1173inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001174typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001175<
1176 std::is_arithmetic<_A1>::value &&
1177 std::is_arithmetic<_A2>::value,
1178 std::__promote<_A1, _A2>
1179>::type
1180fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1181{
1182 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001183 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1184 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001185 return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001186}
1187
1188// fma
1189
Mehdi Aminib3da6322017-02-10 02:44:23 +00001190inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return ::fmaf(__lcpp_x, __lcpp_y, __lcpp_z);}
1191inline _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 +00001192
1193template <class _A1, class _A2, class _A3>
1194inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001195typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001196<
1197 std::is_arithmetic<_A1>::value &&
1198 std::is_arithmetic<_A2>::value &&
1199 std::is_arithmetic<_A3>::value,
1200 std::__promote<_A1, _A2, _A3>
1201>::type
1202fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
1203{
1204 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001205 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1206 std::_IsSame<_A2, __result_type>::value &&
1207 std::_IsSame<_A3, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001208 return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
Richard Smith081bb592015-10-08 20:40:34 +00001209}
1210
1211// fmax
1212
Mehdi Aminib3da6322017-02-10 02:44:23 +00001213inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmaxf(__lcpp_x, __lcpp_y);}
1214inline _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 +00001215
1216template <class _A1, class _A2>
1217inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001218typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001219<
1220 std::is_arithmetic<_A1>::value &&
1221 std::is_arithmetic<_A2>::value,
1222 std::__promote<_A1, _A2>
1223>::type
1224fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1225{
1226 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001227 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1228 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001229 return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001230}
1231
1232// fmin
1233
Mehdi Aminib3da6322017-02-10 02:44:23 +00001234inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fminf(__lcpp_x, __lcpp_y);}
1235inline _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 +00001236
1237template <class _A1, class _A2>
1238inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001239typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001240<
1241 std::is_arithmetic<_A1>::value &&
1242 std::is_arithmetic<_A2>::value,
1243 std::__promote<_A1, _A2>
1244>::type
1245fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1246{
1247 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001248 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1249 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001250 return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001251}
1252
1253// hypot
1254
Mehdi Aminib3da6322017-02-10 02:44:23 +00001255inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::hypotf(__lcpp_x, __lcpp_y);}
1256inline _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 +00001257
1258template <class _A1, class _A2>
1259inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001260typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001261<
1262 std::is_arithmetic<_A1>::value &&
1263 std::is_arithmetic<_A2>::value,
1264 std::__promote<_A1, _A2>
1265>::type
1266hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1267{
1268 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001269 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1270 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001271 return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001272}
1273
1274// ilogb
1275
Mehdi Aminib3da6322017-02-10 02:44:23 +00001276inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ::ilogbf(__lcpp_x);}
1277inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ::ilogbl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001278
1279template <class _A1>
1280inline _LIBCPP_INLINE_VISIBILITY
1281typename std::enable_if<std::is_integral<_A1>::value, int>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001282ilogb(_A1 __lcpp_x) _NOEXCEPT {return ::ilogb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001283
1284// lgamma
1285
Mehdi Aminib3da6322017-02-10 02:44:23 +00001286inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return ::lgammaf(__lcpp_x);}
1287inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return ::lgammal(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001288
1289template <class _A1>
1290inline _LIBCPP_INLINE_VISIBILITY
1291typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001292lgamma(_A1 __lcpp_x) _NOEXCEPT {return ::lgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001293
1294// llrint
1295
Mehdi Aminib3da6322017-02-10 02:44:23 +00001296inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return ::llrintf(__lcpp_x);}
1297inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return ::llrintl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001298
1299template <class _A1>
1300inline _LIBCPP_INLINE_VISIBILITY
1301typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001302llrint(_A1 __lcpp_x) _NOEXCEPT {return ::llrint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001303
1304// llround
1305
Mehdi Aminib3da6322017-02-10 02:44:23 +00001306inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return ::llroundf(__lcpp_x);}
1307inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return ::llroundl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001308
1309template <class _A1>
1310inline _LIBCPP_INLINE_VISIBILITY
1311typename std::enable_if<std::is_integral<_A1>::value, long long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001312llround(_A1 __lcpp_x) _NOEXCEPT {return ::llround((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001313
1314// log1p
1315
Mehdi Aminib3da6322017-02-10 02:44:23 +00001316inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return ::log1pf(__lcpp_x);}
1317inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return ::log1pl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001318
1319template <class _A1>
1320inline _LIBCPP_INLINE_VISIBILITY
1321typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001322log1p(_A1 __lcpp_x) _NOEXCEPT {return ::log1p((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001323
1324// log2
1325
Mehdi Aminib3da6322017-02-10 02:44:23 +00001326inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return ::log2f(__lcpp_x);}
1327inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return ::log2l(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001328
1329template <class _A1>
1330inline _LIBCPP_INLINE_VISIBILITY
1331typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001332log2(_A1 __lcpp_x) _NOEXCEPT {return ::log2((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001333
1334// logb
1335
Mehdi Aminib3da6322017-02-10 02:44:23 +00001336inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return ::logbf(__lcpp_x);}
1337inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return ::logbl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001338
1339template <class _A1>
1340inline _LIBCPP_INLINE_VISIBILITY
1341typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001342logb(_A1 __lcpp_x) _NOEXCEPT {return ::logb((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001343
1344// lrint
1345
Mehdi Aminib3da6322017-02-10 02:44:23 +00001346inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return ::lrintf(__lcpp_x);}
1347inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return ::lrintl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001348
1349template <class _A1>
1350inline _LIBCPP_INLINE_VISIBILITY
1351typename std::enable_if<std::is_integral<_A1>::value, long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001352lrint(_A1 __lcpp_x) _NOEXCEPT {return ::lrint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001353
1354// lround
1355
Mehdi Aminib3da6322017-02-10 02:44:23 +00001356inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return ::lroundf(__lcpp_x);}
1357inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return ::lroundl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001358
1359template <class _A1>
1360inline _LIBCPP_INLINE_VISIBILITY
1361typename std::enable_if<std::is_integral<_A1>::value, long>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001362lround(_A1 __lcpp_x) _NOEXCEPT {return ::lround((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001363
1364// nan
1365
1366// nearbyint
1367
Mehdi Aminib3da6322017-02-10 02:44:23 +00001368inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return ::nearbyintf(__lcpp_x);}
1369inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return ::nearbyintl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001370
1371template <class _A1>
1372inline _LIBCPP_INLINE_VISIBILITY
1373typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001374nearbyint(_A1 __lcpp_x) _NOEXCEPT {return ::nearbyint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001375
1376// nextafter
1377
Mehdi Aminib3da6322017-02-10 02:44:23 +00001378inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::nextafterf(__lcpp_x, __lcpp_y);}
1379inline _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 +00001380
1381template <class _A1, class _A2>
1382inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001383typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001384<
1385 std::is_arithmetic<_A1>::value &&
1386 std::is_arithmetic<_A2>::value,
1387 std::__promote<_A1, _A2>
1388>::type
1389nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1390{
1391 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001392 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1393 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001394 return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001395}
1396
1397// nexttoward
1398
Mehdi Aminib3da6322017-02-10 02:44:23 +00001399inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttowardf(__lcpp_x, __lcpp_y);}
1400inline _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 +00001401
1402template <class _A1>
1403inline _LIBCPP_INLINE_VISIBILITY
1404typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001405nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::nexttoward((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001406
1407// remainder
1408
Mehdi Aminib3da6322017-02-10 02:44:23 +00001409inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::remainderf(__lcpp_x, __lcpp_y);}
1410inline _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 +00001411
1412template <class _A1, class _A2>
1413inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001414typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001415<
1416 std::is_arithmetic<_A1>::value &&
1417 std::is_arithmetic<_A2>::value,
1418 std::__promote<_A1, _A2>
1419>::type
1420remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1421{
1422 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001423 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1424 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001425 return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
Richard Smith081bb592015-10-08 20:40:34 +00001426}
1427
1428// remquo
1429
Mehdi Aminib3da6322017-02-10 02:44:23 +00001430inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return ::remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
1431inline _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 +00001432
1433template <class _A1, class _A2>
1434inline _LIBCPP_INLINE_VISIBILITY
Eric Fiselier3906a132019-06-23 20:28:29 +00001435typename std::_EnableIf
Richard Smith081bb592015-10-08 20:40:34 +00001436<
1437 std::is_arithmetic<_A1>::value &&
1438 std::is_arithmetic<_A2>::value,
1439 std::__promote<_A1, _A2>
1440>::type
1441remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
1442{
1443 typedef typename std::__promote<_A1, _A2>::type __result_type;
Eric Fiselier3906a132019-06-23 20:28:29 +00001444 static_assert((!(std::_IsSame<_A1, __result_type>::value &&
1445 std::_IsSame<_A2, __result_type>::value)), "");
Mehdi Aminib3da6322017-02-10 02:44:23 +00001446 return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
Richard Smith081bb592015-10-08 20:40:34 +00001447}
1448
1449// rint
1450
Mehdi Aminib3da6322017-02-10 02:44:23 +00001451inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return ::rintf(__lcpp_x);}
1452inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return ::rintl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001453
1454template <class _A1>
1455inline _LIBCPP_INLINE_VISIBILITY
1456typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001457rint(_A1 __lcpp_x) _NOEXCEPT {return ::rint((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001458
1459// round
1460
Mehdi Aminib3da6322017-02-10 02:44:23 +00001461inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return ::roundf(__lcpp_x);}
1462inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return ::roundl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001463
1464template <class _A1>
1465inline _LIBCPP_INLINE_VISIBILITY
1466typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001467round(_A1 __lcpp_x) _NOEXCEPT {return ::round((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001468
1469// scalbln
1470
Mehdi Aminib3da6322017-02-10 02:44:23 +00001471inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalblnf(__lcpp_x, __lcpp_y);}
1472inline _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 +00001473
1474template <class _A1>
1475inline _LIBCPP_INLINE_VISIBILITY
1476typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001477scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return ::scalbln((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001478
1479// scalbn
1480
Mehdi Aminib3da6322017-02-10 02:44:23 +00001481inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbnf(__lcpp_x, __lcpp_y);}
1482inline _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 +00001483
1484template <class _A1>
1485inline _LIBCPP_INLINE_VISIBILITY
1486typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001487scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return ::scalbn((double)__lcpp_x, __lcpp_y);}
Richard Smith081bb592015-10-08 20:40:34 +00001488
1489// tgamma
1490
Mehdi Aminib3da6322017-02-10 02:44:23 +00001491inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return ::tgammaf(__lcpp_x);}
1492inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return ::tgammal(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001493
1494template <class _A1>
1495inline _LIBCPP_INLINE_VISIBILITY
1496typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001497tgamma(_A1 __lcpp_x) _NOEXCEPT {return ::tgamma((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001498
1499// trunc
1500
Mehdi Aminib3da6322017-02-10 02:44:23 +00001501inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return ::truncf(__lcpp_x);}
1502inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return ::truncl(__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001503
1504template <class _A1>
1505inline _LIBCPP_INLINE_VISIBILITY
1506typename std::enable_if<std::is_integral<_A1>::value, double>::type
Mehdi Aminib3da6322017-02-10 02:44:23 +00001507trunc(_A1 __lcpp_x) _NOEXCEPT {return ::trunc((double)__lcpp_x);}
Richard Smith081bb592015-10-08 20:40:34 +00001508
Richard Smith081bb592015-10-08 20:40:34 +00001509} // extern "C++"
1510
1511#endif // __cplusplus
1512
Mikhail Maltsev34b4f972018-02-22 09:34:08 +00001513#else // _LIBCPP_MATH_H
1514
1515// This include lives outside the header guard in order to support an MSVC
1516// extension which allows users to do:
1517//
1518// #define _USE_MATH_DEFINES
1519// #include <math.h>
1520//
1521// and receive the definitions of mathematical constants, even if <math.h>
1522// has previously been included.
1523#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
1524#include_next <math.h>
1525#endif
1526
Richard Smith081bb592015-10-08 20:40:34 +00001527#endif // _LIBCPP_MATH_H