blob: bd6034413eef7346f6721e49ab750d74ce79922e [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- cmath -----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_CMATH
12#define _LIBCPP_CMATH
13
14/*
15 cmath synopsis
16
17Macros:
18
19 HUGE_VAL
20 HUGE_VALF // C99
21 HUGE_VALL // C99
22 INFINITY // C99
23 NAN // C99
24 FP_INFINITE // C99
25 FP_NAN // C99
26 FP_NORMAL // C99
27 FP_SUBNORMAL // C99
28 FP_ZERO // C99
29 FP_FAST_FMA // C99
30 FP_FAST_FMAF // C99
31 FP_FAST_FMAL // C99
32 FP_ILOGB0 // C99
33 FP_ILOGBNAN // C99
34 MATH_ERRNO // C99
35 MATH_ERREXCEPT // C99
36 math_errhandling // C99
37
38namespace std
39{
40
41Types:
42
43 float_t // C99
44 double_t // C99
45
46// C90
47
48floating_point abs(floating_point x);
49
50floating_point acos (arithmetic x);
51float acosf(float x);
52long double acosl(long double x);
53
54floating_point asin (arithmetic x);
55float asinf(float x);
56long double asinl(long double x);
57
58floating_point atan (arithmetic x);
59float atanf(float x);
60long double atanl(long double x);
61
62floating_point atan2 (arithmetic y, arithmetic x);
63float atan2f(float y, float x);
64long double atan2l(long double y, long double x);
65
66floating_point ceil (arithmetic x);
67float ceilf(float x);
68long double ceill(long double x);
69
70floating_point cos (arithmetic x);
71float cosf(float x);
72long double cosl(long double x);
73
74floating_point cosh (arithmetic x);
75float coshf(float x);
76long double coshl(long double x);
77
78floating_point exp (arithmetic x);
79float expf(float x);
80long double expl(long double x);
81
82floating_point fabs (arithmetic x);
83float fabsf(float x);
84long double fabsl(long double x);
85
86floating_point floor (arithmetic x);
87float floorf(float x);
88long double floorl(long double x);
89
90floating_point fmod (arithmetic x, arithmetic y);
91float fmodf(float x, float y);
92long double fmodl(long double x, long double y);
93
94floating_point frexp (arithmetic value, int* exp);
95float frexpf(float value, int* exp);
96long double frexpl(long double value, int* exp);
97
98floating_point ldexp (arithmetic value, int exp);
99float ldexpf(float value, int exp);
100long double ldexpl(long double value, int exp);
101
102floating_point log (arithmetic x);
103float logf(float x);
104long double logl(long double x);
105
106floating_point log10 (arithmetic x);
107float log10f(float x);
108long double log10l(long double x);
109
110floating_point modf (floating_point value, floating_point* iptr);
111float modff(float value, float* iptr);
112long double modfl(long double value, long double* iptr);
113
114floating_point pow (arithmetic x, arithmetic y);
115float powf(float x, float y);
116long double powl(long double x, long double y);
117
118floating_point sin (arithmetic x);
119float sinf(float x);
120long double sinl(long double x);
121
122floating_point sinh (arithmetic x);
123float sinhf(float x);
124long double sinhl(long double x);
125
126floating_point sqrt (arithmetic x);
127float sqrtf(float x);
128long double sqrtl(long double x);
129
130floating_point tan (arithmetic x);
131float tanf(float x);
132long double tanl(long double x);
133
134floating_point tanh (arithmetic x);
135float tanhf(float x);
136long double tanhl(long double x);
137
138// C99
139
Howard Hinnantb05a5562013-01-14 20:56:22 +0000140bool signbit(arithmetic x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000141
Howard Hinnantb05a5562013-01-14 20:56:22 +0000142int fpclassify(arithmetic x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000143
Howard Hinnantb05a5562013-01-14 20:56:22 +0000144bool isfinite(arithmetic x);
145bool isinf(arithmetic x);
146bool isnan(arithmetic x);
147bool isnormal(arithmetic x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000148
Howard Hinnantb05a5562013-01-14 20:56:22 +0000149bool isgreater(arithmetic x, arithmetic y);
150bool isgreaterequal(arithmetic x, arithmetic y);
151bool isless(arithmetic x, arithmetic y);
152bool islessequal(arithmetic x, arithmetic y);
153bool islessgreater(arithmetic x, arithmetic y);
154bool isunordered(arithmetic x, arithmetic y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000155
156floating_point acosh (arithmetic x);
157float acoshf(float x);
158long double acoshl(long double x);
159
160floating_point asinh (arithmetic x);
161float asinhf(float x);
162long double asinhl(long double x);
163
164floating_point atanh (arithmetic x);
165float atanhf(float x);
166long double atanhl(long double x);
167
168floating_point cbrt (arithmetic x);
169float cbrtf(float x);
170long double cbrtl(long double x);
171
172floating_point copysign (arithmetic x, arithmetic y);
173float copysignf(float x, float y);
174long double copysignl(long double x, long double y);
175
176floating_point erf (arithmetic x);
177float erff(float x);
178long double erfl(long double x);
179
180floating_point erfc (arithmetic x);
181float erfcf(float x);
182long double erfcl(long double x);
183
184floating_point exp2 (arithmetic x);
185float exp2f(float x);
186long double exp2l(long double x);
187
188floating_point expm1 (arithmetic x);
189float expm1f(float x);
190long double expm1l(long double x);
191
192floating_point fdim (arithmetic x, arithmetic y);
193float fdimf(float x, float y);
194long double fdiml(long double x, long double y);
195
196floating_point fma (arithmetic x, arithmetic y, arithmetic z);
197float fmaf(float x, float y, float z);
198long double fmal(long double x, long double y, long double z);
199
200floating_point fmax (arithmetic x, arithmetic y);
201float fmaxf(float x, float y);
202long double fmaxl(long double x, long double y);
203
204floating_point fmin (arithmetic x, arithmetic y);
205float fminf(float x, float y);
206long double fminl(long double x, long double y);
207
208floating_point hypot (arithmetic x, arithmetic y);
209float hypotf(float x, float y);
210long double hypotl(long double x, long double y);
211
212int ilogb (arithmetic x);
213int ilogbf(float x);
214int ilogbl(long double x);
215
216floating_point lgamma (arithmetic x);
217float lgammaf(float x);
218long double lgammal(long double x);
219
220long long llrint (arithmetic x);
221long long llrintf(float x);
222long long llrintl(long double x);
223
224long long llround (arithmetic x);
225long long llroundf(float x);
226long long llroundl(long double x);
227
228floating_point log1p (arithmetic x);
229float log1pf(float x);
230long double log1pl(long double x);
231
232floating_point log2 (arithmetic x);
233float log2f(float x);
234long double log2l(long double x);
235
236floating_point logb (arithmetic x);
237float logbf(float x);
238long double logbl(long double x);
239
240long lrint (arithmetic x);
241long lrintf(float x);
242long lrintl(long double x);
243
244long lround (arithmetic x);
245long lroundf(float x);
246long lroundl(long double x);
247
248double nan (const char* str);
249float nanf(const char* str);
250long double nanl(const char* str);
251
252floating_point nearbyint (arithmetic x);
253float nearbyintf(float x);
254long double nearbyintl(long double x);
255
256floating_point nextafter (arithmetic x, arithmetic y);
257float nextafterf(float x, float y);
258long double nextafterl(long double x, long double y);
259
260floating_point nexttoward (arithmetic x, long double y);
261float nexttowardf(float x, long double y);
262long double nexttowardl(long double x, long double y);
263
264floating_point remainder (arithmetic x, arithmetic y);
265float remainderf(float x, float y);
266long double remainderl(long double x, long double y);
267
268floating_point remquo (arithmetic x, arithmetic y, int* pquo);
269float remquof(float x, float y, int* pquo);
270long double remquol(long double x, long double y, int* pquo);
271
272floating_point rint (arithmetic x);
273float rintf(float x);
274long double rintl(long double x);
275
276floating_point round (arithmetic x);
277float roundf(float x);
278long double roundl(long double x);
279
280floating_point scalbln (arithmetic x, long ex);
281float scalblnf(float x, long ex);
282long double scalblnl(long double x, long ex);
283
284floating_point scalbn (arithmetic x, int ex);
285float scalbnf(float x, int ex);
286long double scalbnl(long double x, int ex);
287
288floating_point tgamma (arithmetic x);
289float tgammaf(float x);
290long double tgammal(long double x);
291
292floating_point trunc (arithmetic x);
293float truncf(float x);
294long double truncl(long double x);
295
296} // std
297
298*/
299
300#include <__config>
301#include <math.h>
302#include <type_traits>
303
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000304#ifdef _MSC_VER
305#include "support/win32/math_win32.h"
306#endif
307
Howard Hinnant08e17472011-10-17 20:05:10 +0000308#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000309#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000310#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000311
Howard Hinnant0a111112011-05-13 21:52:40 +0000312// signbit
313
314#ifdef signbit
315
316template <class _A1>
317_LIBCPP_ALWAYS_INLINE
318bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000319__libcpp_signbit(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000320{
321 return signbit(__x);
322}
323
324#undef signbit
325
326template <class _A1>
327inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb05a5562013-01-14 20:56:22 +0000328typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000329signbit(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000330{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000331 return __libcpp_signbit((typename std::__promote<_A1>::type)__x);
Howard Hinnant0a111112011-05-13 21:52:40 +0000332}
333
334#endif // signbit
335
336// fpclassify
337
338#ifdef fpclassify
339
340template <class _A1>
341_LIBCPP_ALWAYS_INLINE
342int
Howard Hinnantcac0c462012-07-06 19:13:50 +0000343__libcpp_fpclassify(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000344{
345 return fpclassify(__x);
346}
347
348#undef fpclassify
349
350template <class _A1>
351inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb05a5562013-01-14 20:56:22 +0000352typename std::enable_if<std::is_arithmetic<_A1>::value, int>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000353fpclassify(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000354{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000355 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__x);
Howard Hinnant0a111112011-05-13 21:52:40 +0000356}
357
358#endif // fpclassify
359
360// isfinite
361
362#ifdef isfinite
363
364template <class _A1>
365_LIBCPP_ALWAYS_INLINE
366bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000367__libcpp_isfinite(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000368{
369 return isfinite(__x);
370}
371
372#undef isfinite
373
374template <class _A1>
375inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb05a5562013-01-14 20:56:22 +0000376typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000377isfinite(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000378{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000379 return __libcpp_isfinite((typename std::__promote<_A1>::type)__x);
Howard Hinnant0a111112011-05-13 21:52:40 +0000380}
381
382#endif // isfinite
383
384// isinf
385
386#ifdef isinf
387
388template <class _A1>
389_LIBCPP_ALWAYS_INLINE
390bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000391__libcpp_isinf(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000392{
393 return isinf(__x);
394}
395
396#undef isinf
397
398template <class _A1>
399inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb05a5562013-01-14 20:56:22 +0000400typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000401isinf(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000402{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000403 return __libcpp_isinf((typename std::__promote<_A1>::type)__x);
Howard Hinnant0a111112011-05-13 21:52:40 +0000404}
405
406#endif // isinf
407
408// isnan
409
410#ifdef isnan
411
412template <class _A1>
413_LIBCPP_ALWAYS_INLINE
414bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000415__libcpp_isnan(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000416{
417 return isnan(__x);
418}
419
420#undef isnan
421
422template <class _A1>
423inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb05a5562013-01-14 20:56:22 +0000424typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000425isnan(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000426{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000427 return __libcpp_isnan((typename std::__promote<_A1>::type)__x);
Howard Hinnant0a111112011-05-13 21:52:40 +0000428}
429
430#endif // isnan
431
432// isnormal
433
434#ifdef isnormal
435
436template <class _A1>
437_LIBCPP_ALWAYS_INLINE
438bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000439__libcpp_isnormal(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000440{
441 return isnormal(__x);
442}
443
444#undef isnormal
445
446template <class _A1>
447inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantb05a5562013-01-14 20:56:22 +0000448typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000449isnormal(_A1 __x) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000450{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000451 return __libcpp_isnormal((typename std::__promote<_A1>::type)__x);
Howard Hinnant0a111112011-05-13 21:52:40 +0000452}
453
454#endif // isnormal
455
456// isgreater
457
458#ifdef isgreater
459
460template <class _A1, class _A2>
461_LIBCPP_ALWAYS_INLINE
462bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000463__libcpp_isgreater(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000464{
465 return isgreater(__x, __y);
466}
467
468#undef isgreater
469
470template <class _A1, class _A2>
471inline _LIBCPP_INLINE_VISIBILITY
472typename std::enable_if
473<
Howard Hinnantb05a5562013-01-14 20:56:22 +0000474 std::is_arithmetic<_A1>::value &&
475 std::is_arithmetic<_A2>::value,
Howard Hinnant0a111112011-05-13 21:52:40 +0000476 bool
477>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000478isgreater(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000479{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000480 typedef typename std::__promote<_A1, _A2>::type type;
481 return __libcpp_isgreater((type)__x, (type)__y);
Howard Hinnant0a111112011-05-13 21:52:40 +0000482}
483
484#endif // isgreater
485
486// isgreaterequal
487
488#ifdef isgreaterequal
489
490template <class _A1, class _A2>
491_LIBCPP_ALWAYS_INLINE
492bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000493__libcpp_isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000494{
495 return isgreaterequal(__x, __y);
496}
497
498#undef isgreaterequal
499
500template <class _A1, class _A2>
501inline _LIBCPP_INLINE_VISIBILITY
502typename std::enable_if
503<
Howard Hinnantb05a5562013-01-14 20:56:22 +0000504 std::is_arithmetic<_A1>::value &&
505 std::is_arithmetic<_A2>::value,
Howard Hinnant0a111112011-05-13 21:52:40 +0000506 bool
507>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000508isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000509{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000510 typedef typename std::__promote<_A1, _A2>::type type;
511 return __libcpp_isgreaterequal((type)__x, (type)__y);
Howard Hinnant0a111112011-05-13 21:52:40 +0000512}
513
514#endif // isgreaterequal
515
516// isless
517
518#ifdef isless
519
520template <class _A1, class _A2>
521_LIBCPP_ALWAYS_INLINE
522bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000523__libcpp_isless(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000524{
525 return isless(__x, __y);
526}
527
528#undef isless
529
530template <class _A1, class _A2>
531inline _LIBCPP_INLINE_VISIBILITY
532typename std::enable_if
533<
Howard Hinnantb05a5562013-01-14 20:56:22 +0000534 std::is_arithmetic<_A1>::value &&
535 std::is_arithmetic<_A2>::value,
Howard Hinnant0a111112011-05-13 21:52:40 +0000536 bool
537>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000538isless(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000539{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000540 typedef typename std::__promote<_A1, _A2>::type type;
541 return __libcpp_isless((type)__x, (type)__y);
Howard Hinnant0a111112011-05-13 21:52:40 +0000542}
543
544#endif // isless
545
546// islessequal
547
548#ifdef islessequal
549
550template <class _A1, class _A2>
551_LIBCPP_ALWAYS_INLINE
552bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000553__libcpp_islessequal(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000554{
555 return islessequal(__x, __y);
556}
557
558#undef islessequal
559
560template <class _A1, class _A2>
561inline _LIBCPP_INLINE_VISIBILITY
562typename std::enable_if
563<
Howard Hinnantb05a5562013-01-14 20:56:22 +0000564 std::is_arithmetic<_A1>::value &&
565 std::is_arithmetic<_A2>::value,
Howard Hinnant0a111112011-05-13 21:52:40 +0000566 bool
567>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000568islessequal(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000569{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000570 typedef typename std::__promote<_A1, _A2>::type type;
571 return __libcpp_islessequal((type)__x, (type)__y);
Howard Hinnant0a111112011-05-13 21:52:40 +0000572}
573
574#endif // islessequal
575
576// islessgreater
577
578#ifdef islessgreater
579
580template <class _A1, class _A2>
581_LIBCPP_ALWAYS_INLINE
582bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000583__libcpp_islessgreater(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000584{
585 return islessgreater(__x, __y);
586}
587
588#undef islessgreater
589
590template <class _A1, class _A2>
591inline _LIBCPP_INLINE_VISIBILITY
592typename std::enable_if
593<
Howard Hinnantb05a5562013-01-14 20:56:22 +0000594 std::is_arithmetic<_A1>::value &&
595 std::is_arithmetic<_A2>::value,
Howard Hinnant0a111112011-05-13 21:52:40 +0000596 bool
597>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000598islessgreater(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000599{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000600 typedef typename std::__promote<_A1, _A2>::type type;
601 return __libcpp_islessgreater((type)__x, (type)__y);
Howard Hinnant0a111112011-05-13 21:52:40 +0000602}
603
604#endif // islessgreater
605
606// isunordered
607
608#ifdef isunordered
609
610template <class _A1, class _A2>
611_LIBCPP_ALWAYS_INLINE
612bool
Howard Hinnantcac0c462012-07-06 19:13:50 +0000613__libcpp_isunordered(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000614{
615 return isunordered(__x, __y);
616}
617
618#undef isunordered
619
620template <class _A1, class _A2>
621inline _LIBCPP_INLINE_VISIBILITY
622typename std::enable_if
623<
Howard Hinnantb05a5562013-01-14 20:56:22 +0000624 std::is_arithmetic<_A1>::value &&
625 std::is_arithmetic<_A2>::value,
Howard Hinnant0a111112011-05-13 21:52:40 +0000626 bool
627>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000628isunordered(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnant0a111112011-05-13 21:52:40 +0000629{
Howard Hinnantb05a5562013-01-14 20:56:22 +0000630 typedef typename std::__promote<_A1, _A2>::type type;
631 return __libcpp_isunordered((type)__x, (type)__y);
Howard Hinnant0a111112011-05-13 21:52:40 +0000632}
633
634#endif // isunordered
635
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000636_LIBCPP_BEGIN_NAMESPACE_STD
637
Howard Hinnant0a111112011-05-13 21:52:40 +0000638using ::signbit;
639using ::fpclassify;
640using ::isfinite;
641using ::isinf;
642using ::isnan;
643using ::isnormal;
644using ::isgreater;
645using ::isgreaterequal;
646using ::isless;
647using ::islessequal;
648using ::islessgreater;
649using ::isunordered;
650using ::isunordered;
651
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000652using ::float_t;
653using ::double_t;
654
655// abs
656
Howard Hinnant422a53f2010-09-21 21:28:23 +0000657inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantf07a5292012-05-03 14:58:34 +0000658float
Howard Hinnantcac0c462012-07-06 19:13:50 +0000659abs(float __x) _NOEXCEPT {return fabsf(__x);}
Howard Hinnantf07a5292012-05-03 14:58:34 +0000660
661inline _LIBCPP_INLINE_VISIBILITY
662double
Howard Hinnantcac0c462012-07-06 19:13:50 +0000663abs(double __x) _NOEXCEPT {return fabs(__x);}
Howard Hinnantf07a5292012-05-03 14:58:34 +0000664
665inline _LIBCPP_INLINE_VISIBILITY
666long double
Howard Hinnantcac0c462012-07-06 19:13:50 +0000667abs(long double __x) _NOEXCEPT {return fabsl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000668
David Chisnall997e4542012-02-29 13:05:08 +0000669#ifndef __sun__
670
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000671// acos
672
673using ::acos;
674using ::acosf;
675
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000676#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000677inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) _NOEXCEPT {return acosf(__x);}
678inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) _NOEXCEPT {return acosl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000679#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000680
681template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000682inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000683typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000684acos(_A1 __x) _NOEXCEPT {return acos((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000685
686// asin
687
688using ::asin;
689using ::asinf;
690
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000691#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000692inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) _NOEXCEPT {return asinf(__x);}
693inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) _NOEXCEPT {return asinl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000694#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000695
696template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000697inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000698typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000699asin(_A1 __x) _NOEXCEPT {return asin((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000700
701// atan
702
703using ::atan;
704using ::atanf;
705
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000706#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000707inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) _NOEXCEPT {return atanf(__x);}
708inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) _NOEXCEPT {return atanl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000709#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000710
711template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000712inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000713typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000714atan(_A1 __x) _NOEXCEPT {return atan((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000715
716// atan2
717
718using ::atan2;
719using ::atan2f;
720
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000721#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000722inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) _NOEXCEPT {return atan2f(__y, __x);}
723inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) _NOEXCEPT {return atan2l(__y, __x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000724#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000725
726template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000727inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000728typename enable_if
729<
730 is_arithmetic<_A1>::value &&
731 is_arithmetic<_A2>::value,
732 typename __promote<_A1, _A2>::type
733>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000734atan2(_A1 __y, _A2 __x) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000735{
736 typedef typename __promote<_A1, _A2>::type __result_type;
737 static_assert((!(is_same<_A1, __result_type>::value &&
738 is_same<_A2, __result_type>::value)), "");
739 return atan2((__result_type)__y, (__result_type)__x);
740}
741
742// ceil
743
744using ::ceil;
745using ::ceilf;
746
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000747#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000748inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) _NOEXCEPT {return ceilf(__x);}
749inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) _NOEXCEPT {return ceill(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000750#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000751
752template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000753inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000754typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000755ceil(_A1 __x) _NOEXCEPT {return ceil((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000756
757// cos
758
759using ::cos;
760using ::cosf;
761
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000762#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000763inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) _NOEXCEPT {return cosf(__x);}
764inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) _NOEXCEPT {return cosl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000765#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000766
767template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000768inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000769typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000770cos(_A1 __x) _NOEXCEPT {return cos((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000771
772// cosh
773
774using ::cosh;
775using ::coshf;
776
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000777#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000778inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) _NOEXCEPT {return coshf(__x);}
779inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) _NOEXCEPT {return coshl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000780#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000781
782template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000783inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000784typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000785cosh(_A1 __x) _NOEXCEPT {return cosh((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000786
David Chisnall997e4542012-02-29 13:05:08 +0000787#endif // __sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000788// exp
789
790using ::exp;
791using ::expf;
792
David Chisnall997e4542012-02-29 13:05:08 +0000793#ifndef __sun__
794
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000795#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000796inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) _NOEXCEPT {return expf(__x);}
797inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) _NOEXCEPT {return expl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000798#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000799
David Chisnall997e4542012-02-29 13:05:08 +0000800
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000801template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000802inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000803typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000804exp(_A1 __x) _NOEXCEPT {return exp((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000805
806// fabs
807
808using ::fabs;
809using ::fabsf;
810
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000811#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000812inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) _NOEXCEPT {return fabsf(__x);}
813inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) _NOEXCEPT {return fabsl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000814#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000815
816template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000817inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000818typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000819fabs(_A1 __x) _NOEXCEPT {return fabs((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000820
821// floor
822
823using ::floor;
824using ::floorf;
825
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000826#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000827inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) _NOEXCEPT {return floorf(__x);}
828inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) _NOEXCEPT {return floorl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000829#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000830
831template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000832inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000833typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000834floor(_A1 __x) _NOEXCEPT {return floor((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000835
836// fmod
837
David Chisnall997e4542012-02-29 13:05:08 +0000838#endif //__sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000839using ::fmod;
840using ::fmodf;
David Chisnall997e4542012-02-29 13:05:08 +0000841#ifndef __sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000842
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000843#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000844inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) _NOEXCEPT {return fmodf(__x, __y);}
845inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) _NOEXCEPT {return fmodl(__x, __y);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000846#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000847
848template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000849inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000850typename enable_if
851<
852 is_arithmetic<_A1>::value &&
853 is_arithmetic<_A2>::value,
854 typename __promote<_A1, _A2>::type
855>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000856fmod(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000857{
858 typedef typename __promote<_A1, _A2>::type __result_type;
859 static_assert((!(is_same<_A1, __result_type>::value &&
860 is_same<_A2, __result_type>::value)), "");
861 return fmod((__result_type)__x, (__result_type)__y);
862}
863
David Chisnall997e4542012-02-29 13:05:08 +0000864
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000865// frexp
866
867using ::frexp;
868using ::frexpf;
869
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000870#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000871inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) _NOEXCEPT {return frexpf(__x, __e);}
872inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) _NOEXCEPT {return frexpl(__x, __e);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000873#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000874
875template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000876inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000877typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000878frexp(_A1 __x, int* __e) _NOEXCEPT {return frexp((double)__x, __e);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000879
880// ldexp
881
882using ::ldexp;
883using ::ldexpf;
884
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000885#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000886inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) _NOEXCEPT {return ldexpf(__x, __e);}
887inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) _NOEXCEPT {return ldexpl(__x, __e);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000888#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000889
890template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000891inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000892typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000893ldexp(_A1 __x, int __e) _NOEXCEPT {return ldexp((double)__x, __e);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000894
895// log
896
David Chisnall997e4542012-02-29 13:05:08 +0000897#endif // __sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000898using ::log;
899using ::logf;
David Chisnall997e4542012-02-29 13:05:08 +0000900#ifndef __sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000901
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000902#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000903inline _LIBCPP_INLINE_VISIBILITY float log(float __x) _NOEXCEPT {return logf(__x);}
904inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) _NOEXCEPT {return logl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000905#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000906
907template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000908inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000909typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000910log(_A1 __x) _NOEXCEPT {return log((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000911
David Chisnall997e4542012-02-29 13:05:08 +0000912
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000913// log10
914
915using ::log10;
916using ::log10f;
917
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000918#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000919inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) _NOEXCEPT {return log10f(__x);}
920inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) _NOEXCEPT {return log10l(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000921#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000922
923template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000924inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000925typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000926log10(_A1 __x) _NOEXCEPT {return log10((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000927
928// modf
929
930using ::modf;
931using ::modff;
932
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000933#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000934inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) _NOEXCEPT {return modff(__x, __y);}
935inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) _NOEXCEPT {return modfl(__x, __y);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000936#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000937
938// pow
939
David Chisnall997e4542012-02-29 13:05:08 +0000940#endif // __sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000941using ::pow;
942using ::powf;
943
David Chisnall997e4542012-02-29 13:05:08 +0000944#ifndef __sun__
945
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000946#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000947inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) _NOEXCEPT {return powf(__x, __y);}
948inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) _NOEXCEPT {return powl(__x, __y);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000949#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000950
951template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000952inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000953typename enable_if
954<
955 is_arithmetic<_A1>::value &&
956 is_arithmetic<_A2>::value,
957 typename __promote<_A1, _A2>::type
958>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000959pow(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000960{
961 typedef typename __promote<_A1, _A2>::type __result_type;
962 static_assert((!(is_same<_A1, __result_type>::value &&
963 is_same<_A2, __result_type>::value)), "");
964 return pow((__result_type)__x, (__result_type)__y);
965}
966
David Chisnall997e4542012-02-29 13:05:08 +0000967
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000968// sin
969
970using ::sin;
971using ::sinf;
972
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000973#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000974inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) _NOEXCEPT {return sinf(__x);}
975inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) _NOEXCEPT {return sinl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000976#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000977
978template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000979inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000980typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000981sin(_A1 __x) _NOEXCEPT {return sin((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000982
983// sinh
984
985using ::sinh;
986using ::sinhf;
987
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000988#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +0000989inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) _NOEXCEPT {return sinhf(__x);}
990inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) _NOEXCEPT {return sinhl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000991#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000992
993template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000994inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000995typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +0000996sinh(_A1 __x) _NOEXCEPT {return sinh((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000997
998// sqrt
999
David Chisnall997e4542012-02-29 13:05:08 +00001000#endif // __sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001001using ::sqrt;
1002using ::sqrtf;
1003
David Chisnall997e4542012-02-29 13:05:08 +00001004
1005#if !(defined(_MSC_VER) || defined(__sun__))
Howard Hinnantcac0c462012-07-06 19:13:50 +00001006inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) _NOEXCEPT {return sqrtf(__x);}
1007inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) _NOEXCEPT {return sqrtl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001008#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001009
1010template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001011inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001012typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001013sqrt(_A1 __x) _NOEXCEPT {return sqrt((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001014
1015// tan
1016
1017using ::tan;
1018using ::tanf;
David Chisnall997e4542012-02-29 13:05:08 +00001019#ifndef __sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001020
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001021#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +00001022inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) _NOEXCEPT {return tanf(__x);}
1023inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) _NOEXCEPT {return tanl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001024#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001025
1026template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001027inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001028typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001029tan(_A1 __x) _NOEXCEPT {return tan((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001030
1031// tanh
1032
1033using ::tanh;
1034using ::tanhf;
1035
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001036#ifndef _MSC_VER
Howard Hinnantcac0c462012-07-06 19:13:50 +00001037inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) _NOEXCEPT {return tanhf(__x);}
1038inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) _NOEXCEPT {return tanhl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001039#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001040
1041template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001042inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001043typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001044tanh(_A1 __x) _NOEXCEPT {return tanh((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001045
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001046// acosh
1047
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001048#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001049using ::acosh;
1050using ::acoshf;
1051
Howard Hinnantcac0c462012-07-06 19:13:50 +00001052inline _LIBCPP_INLINE_VISIBILITY float acosh(float __x) _NOEXCEPT {return acoshf(__x);}
1053inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __x) _NOEXCEPT {return acoshl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001054
1055template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001056inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001057typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001058acosh(_A1 __x) _NOEXCEPT {return acosh((double)__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001059#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001060
1061// asinh
1062
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001063#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001064using ::asinh;
1065using ::asinhf;
1066
Howard Hinnantcac0c462012-07-06 19:13:50 +00001067inline _LIBCPP_INLINE_VISIBILITY float asinh(float __x) _NOEXCEPT {return asinhf(__x);}
1068inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __x) _NOEXCEPT {return asinhl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001069
1070template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001071inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001072typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001073asinh(_A1 __x) _NOEXCEPT {return asinh((double)__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001074#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001075
1076// atanh
1077
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001078#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001079using ::atanh;
1080using ::atanhf;
1081
Howard Hinnantcac0c462012-07-06 19:13:50 +00001082inline _LIBCPP_INLINE_VISIBILITY float atanh(float __x) _NOEXCEPT {return atanhf(__x);}
1083inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __x) _NOEXCEPT {return atanhl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001084
1085template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001086inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001087typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001088atanh(_A1 __x) _NOEXCEPT {return atanh((double)__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001089#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001090
1091// cbrt
1092
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001093#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001094using ::cbrt;
1095using ::cbrtf;
1096
Howard Hinnantcac0c462012-07-06 19:13:50 +00001097inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __x) _NOEXCEPT {return cbrtf(__x);}
1098inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __x) _NOEXCEPT {return cbrtl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001099
1100template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001101inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001102typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001103cbrt(_A1 __x) _NOEXCEPT {return cbrt((double)__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001104#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001105
1106// copysign
1107
1108using ::copysign;
1109using ::copysignf;
1110
Howard Hinnantcac0c462012-07-06 19:13:50 +00001111inline _LIBCPP_INLINE_VISIBILITY float copysign(float __x, float __y) _NOEXCEPT {return copysignf(__x, __y);}
1112inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __x, long double __y) _NOEXCEPT {return copysignl(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001113
1114template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001115inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001116typename enable_if
1117<
1118 is_arithmetic<_A1>::value &&
1119 is_arithmetic<_A2>::value,
1120 typename __promote<_A1, _A2>::type
1121>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001122copysign(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001123{
1124 typedef typename __promote<_A1, _A2>::type __result_type;
1125 static_assert((!(is_same<_A1, __result_type>::value &&
1126 is_same<_A2, __result_type>::value)), "");
1127 return copysign((__result_type)__x, (__result_type)__y);
1128}
1129
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001130#ifndef _MSC_VER
1131
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001132// erf
1133
1134using ::erf;
1135using ::erff;
1136
Howard Hinnantcac0c462012-07-06 19:13:50 +00001137inline _LIBCPP_INLINE_VISIBILITY float erf(float __x) _NOEXCEPT {return erff(__x);}
1138inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __x) _NOEXCEPT {return erfl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001139
1140template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001141inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001142typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001143erf(_A1 __x) _NOEXCEPT {return erf((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001144
1145// erfc
1146
1147using ::erfc;
1148using ::erfcf;
1149
Howard Hinnantcac0c462012-07-06 19:13:50 +00001150inline _LIBCPP_INLINE_VISIBILITY float erfc(float __x) _NOEXCEPT {return erfcf(__x);}
1151inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __x) _NOEXCEPT {return erfcl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001152
1153template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001154inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001155typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001156erfc(_A1 __x) _NOEXCEPT {return erfc((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001157
1158// exp2
1159
1160using ::exp2;
1161using ::exp2f;
1162
Howard Hinnantcac0c462012-07-06 19:13:50 +00001163inline _LIBCPP_INLINE_VISIBILITY float exp2(float __x) _NOEXCEPT {return exp2f(__x);}
1164inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __x) _NOEXCEPT {return exp2l(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001165
1166template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001167inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001168typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001169exp2(_A1 __x) _NOEXCEPT {return exp2((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001170
1171// expm1
1172
1173using ::expm1;
1174using ::expm1f;
1175
Howard Hinnantcac0c462012-07-06 19:13:50 +00001176inline _LIBCPP_INLINE_VISIBILITY float expm1(float __x) _NOEXCEPT {return expm1f(__x);}
1177inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __x) _NOEXCEPT {return expm1l(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001178
1179template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001180inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001181typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001182expm1(_A1 __x) _NOEXCEPT {return expm1((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001183
1184// fdim
1185
1186using ::fdim;
1187using ::fdimf;
1188
Howard Hinnantcac0c462012-07-06 19:13:50 +00001189inline _LIBCPP_INLINE_VISIBILITY float fdim(float __x, float __y) _NOEXCEPT {return fdimf(__x, __y);}
1190inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __x, long double __y) _NOEXCEPT {return fdiml(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001191
1192template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001193inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001194typename enable_if
1195<
1196 is_arithmetic<_A1>::value &&
1197 is_arithmetic<_A2>::value,
1198 typename __promote<_A1, _A2>::type
1199>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001200fdim(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001201{
1202 typedef typename __promote<_A1, _A2>::type __result_type;
1203 static_assert((!(is_same<_A1, __result_type>::value &&
1204 is_same<_A2, __result_type>::value)), "");
1205 return fdim((__result_type)__x, (__result_type)__y);
1206}
1207
1208// fma
1209
Howard Hinnantcac0c462012-07-06 19:13:50 +00001210inline _LIBCPP_INLINE_VISIBILITY float fmaf(float __x, float __y, float __z) _NOEXCEPT {return (float)((double)__x*__y + __z);}
Howard Hinnant0919dba2012-11-06 21:55:44 +00001211#ifndef FP_FAST_FMAF
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001212#define FP_FAST_FMAF
Howard Hinnant0919dba2012-11-06 21:55:44 +00001213#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001214
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001215using ::fma;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001216
Howard Hinnantcac0c462012-07-06 19:13:50 +00001217inline _LIBCPP_INLINE_VISIBILITY float fma(float __x, float __y, float __z) _NOEXCEPT {return fmaf(__x, __y, __z);}
1218inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __x, long double __y, long double __z) _NOEXCEPT {return fmal(__x, __y, __z);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001219
1220template <class _A1, class _A2, class _A3>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001221inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001222typename enable_if
1223<
1224 is_arithmetic<_A1>::value &&
1225 is_arithmetic<_A2>::value &&
1226 is_arithmetic<_A3>::value,
1227 typename __promote<_A1, _A2, _A3>::type
1228>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001229fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001230{
1231 typedef typename __promote<_A1, _A2, _A3>::type __result_type;
1232 static_assert((!(is_same<_A1, __result_type>::value &&
1233 is_same<_A2, __result_type>::value &&
1234 is_same<_A3, __result_type>::value)), "");
1235 return fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
1236}
1237
1238// fmax
1239
1240using ::fmax;
1241using ::fmaxf;
1242
Howard Hinnantcac0c462012-07-06 19:13:50 +00001243inline _LIBCPP_INLINE_VISIBILITY float fmax(float __x, float __y) _NOEXCEPT {return fmaxf(__x, __y);}
1244inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __x, long double __y) _NOEXCEPT {return fmaxl(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001245
1246template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001247inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001248typename enable_if
1249<
1250 is_arithmetic<_A1>::value &&
1251 is_arithmetic<_A2>::value,
1252 typename __promote<_A1, _A2>::type
1253>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001254fmax(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001255{
1256 typedef typename __promote<_A1, _A2>::type __result_type;
1257 static_assert((!(is_same<_A1, __result_type>::value &&
1258 is_same<_A2, __result_type>::value)), "");
1259 return fmax((__result_type)__x, (__result_type)__y);
1260}
1261
1262// fmin
1263
1264using ::fmin;
1265using ::fminf;
1266
Howard Hinnantcac0c462012-07-06 19:13:50 +00001267inline _LIBCPP_INLINE_VISIBILITY float fmin(float __x, float __y) _NOEXCEPT {return fminf(__x, __y);}
1268inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __x, long double __y) _NOEXCEPT {return fminl(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001269
1270template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001271inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001272typename enable_if
1273<
1274 is_arithmetic<_A1>::value &&
1275 is_arithmetic<_A2>::value,
1276 typename __promote<_A1, _A2>::type
1277>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001278fmin(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001279{
1280 typedef typename __promote<_A1, _A2>::type __result_type;
1281 static_assert((!(is_same<_A1, __result_type>::value &&
1282 is_same<_A2, __result_type>::value)), "");
1283 return fmin((__result_type)__x, (__result_type)__y);
1284}
1285
1286// hypot
1287
1288using ::hypot;
1289using ::hypotf;
1290
Howard Hinnantcac0c462012-07-06 19:13:50 +00001291inline _LIBCPP_INLINE_VISIBILITY float hypot(float __x, float __y) _NOEXCEPT {return hypotf(__x, __y);}
1292inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __x, long double __y) _NOEXCEPT {return hypotl(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001293
1294template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001295inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001296typename enable_if
1297<
1298 is_arithmetic<_A1>::value &&
1299 is_arithmetic<_A2>::value,
1300 typename __promote<_A1, _A2>::type
1301>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001302hypot(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001303{
1304 typedef typename __promote<_A1, _A2>::type __result_type;
1305 static_assert((!(is_same<_A1, __result_type>::value &&
1306 is_same<_A2, __result_type>::value)), "");
1307 return hypot((__result_type)__x, (__result_type)__y);
1308}
1309
1310// ilogb
1311
1312using ::ilogb;
1313using ::ilogbf;
1314
Howard Hinnantcac0c462012-07-06 19:13:50 +00001315inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __x) _NOEXCEPT {return ilogbf(__x);}
1316inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __x) _NOEXCEPT {return ilogbl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001317
1318template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001319inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001320typename enable_if<is_integral<_A1>::value, int>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001321ilogb(_A1 __x) _NOEXCEPT {return ilogb((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001322
1323// lgamma
1324
1325using ::lgamma;
1326using ::lgammaf;
1327
Howard Hinnantcac0c462012-07-06 19:13:50 +00001328inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __x) _NOEXCEPT {return lgammaf(__x);}
1329inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __x) _NOEXCEPT {return lgammal(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001330
David Chisnall997e4542012-02-29 13:05:08 +00001331
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001332template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001333inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001334typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001335lgamma(_A1 __x) _NOEXCEPT {return lgamma((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001336
David Chisnall997e4542012-02-29 13:05:08 +00001337
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001338// llrint
1339
1340using ::llrint;
1341using ::llrintf;
1342
Howard Hinnantcac0c462012-07-06 19:13:50 +00001343inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __x) _NOEXCEPT {return llrintf(__x);}
1344inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __x) _NOEXCEPT {return llrintl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001345
1346template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001347inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001348typename enable_if<is_integral<_A1>::value, long long>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001349llrint(_A1 __x) _NOEXCEPT {return llrint((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001350
1351// llround
1352
1353using ::llround;
1354using ::llroundf;
1355
Howard Hinnantcac0c462012-07-06 19:13:50 +00001356inline _LIBCPP_INLINE_VISIBILITY long long llround(float __x) _NOEXCEPT {return llroundf(__x);}
1357inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __x) _NOEXCEPT {return llroundl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001358
1359template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001360inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001361typename enable_if<is_integral<_A1>::value, long long>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001362llround(_A1 __x) _NOEXCEPT {return llround((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001363
1364// log1p
1365
1366using ::log1p;
1367using ::log1pf;
1368
Howard Hinnantcac0c462012-07-06 19:13:50 +00001369inline _LIBCPP_INLINE_VISIBILITY float log1p(float __x) _NOEXCEPT {return log1pf(__x);}
1370inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __x) _NOEXCEPT {return log1pl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001371
1372template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001373inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001374typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001375log1p(_A1 __x) _NOEXCEPT {return log1p((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001376
1377// log2
1378
1379using ::log2;
1380using ::log2f;
1381
Howard Hinnantcac0c462012-07-06 19:13:50 +00001382inline _LIBCPP_INLINE_VISIBILITY float log2(float __x) _NOEXCEPT {return log2f(__x);}
1383inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __x) _NOEXCEPT {return log2l(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001384
1385template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001386inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001387typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001388log2(_A1 __x) _NOEXCEPT {return log2((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001389
1390// logb
1391
1392using ::logb;
1393using ::logbf;
1394
Howard Hinnantcac0c462012-07-06 19:13:50 +00001395inline _LIBCPP_INLINE_VISIBILITY float logb(float __x) _NOEXCEPT {return logbf(__x);}
1396inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __x) _NOEXCEPT {return logbl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001397
1398template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001399inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001400typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001401logb(_A1 __x) _NOEXCEPT {return logb((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001402
1403// lrint
1404
1405using ::lrint;
1406using ::lrintf;
1407
Howard Hinnantcac0c462012-07-06 19:13:50 +00001408inline _LIBCPP_INLINE_VISIBILITY long lrint(float __x) _NOEXCEPT {return lrintf(__x);}
1409inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __x) _NOEXCEPT {return lrintl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001410
1411template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001412inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001413typename enable_if<is_integral<_A1>::value, long>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001414lrint(_A1 __x) _NOEXCEPT {return lrint((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001415
1416// lround
1417
1418using ::lround;
1419using ::lroundf;
1420
Howard Hinnantcac0c462012-07-06 19:13:50 +00001421inline _LIBCPP_INLINE_VISIBILITY long lround(float __x) _NOEXCEPT {return lroundf(__x);}
1422inline _LIBCPP_INLINE_VISIBILITY long lround(long double __x) _NOEXCEPT {return lroundl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001423
1424template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001425inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001426typename enable_if<is_integral<_A1>::value, long>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001427lround(_A1 __x) _NOEXCEPT {return lround((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001428
1429// nan
David Chisnallb6e7c302012-02-29 16:41:21 +00001430#endif // _MSC_VER
David Chisnall997e4542012-02-29 13:05:08 +00001431#endif // __sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001432using ::nan;
1433using ::nanf;
David Chisnall997e4542012-02-29 13:05:08 +00001434#ifndef __sun__
David Chisnallb6e7c302012-02-29 16:41:21 +00001435#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001436
1437// nearbyint
1438
1439using ::nearbyint;
1440using ::nearbyintf;
1441
Howard Hinnantcac0c462012-07-06 19:13:50 +00001442inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __x) _NOEXCEPT {return nearbyintf(__x);}
1443inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __x) _NOEXCEPT {return nearbyintl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001444
1445template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001446inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001447typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001448nearbyint(_A1 __x) _NOEXCEPT {return nearbyint((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001449
1450// nextafter
1451
1452using ::nextafter;
1453using ::nextafterf;
1454
Howard Hinnantcac0c462012-07-06 19:13:50 +00001455inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __x, float __y) _NOEXCEPT {return nextafterf(__x, __y);}
1456inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __x, long double __y) _NOEXCEPT {return nextafterl(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001457
1458template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001459inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001460typename enable_if
1461<
1462 is_arithmetic<_A1>::value &&
1463 is_arithmetic<_A2>::value,
1464 typename __promote<_A1, _A2>::type
1465>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001466nextafter(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001467{
1468 typedef typename __promote<_A1, _A2>::type __result_type;
1469 static_assert((!(is_same<_A1, __result_type>::value &&
1470 is_same<_A2, __result_type>::value)), "");
1471 return nextafter((__result_type)__x, (__result_type)__y);
1472}
1473
1474// nexttoward
1475
1476using ::nexttoward;
1477using ::nexttowardf;
1478
Howard Hinnantcac0c462012-07-06 19:13:50 +00001479inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __x, long double __y) _NOEXCEPT {return nexttowardf(__x, __y);}
1480inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __x, long double __y) _NOEXCEPT {return nexttowardl(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001481
1482template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001483inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001484typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001485nexttoward(_A1 __x, long double __y) _NOEXCEPT {return nexttoward((double)__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001486
1487// remainder
1488
1489using ::remainder;
1490using ::remainderf;
1491
Howard Hinnantcac0c462012-07-06 19:13:50 +00001492inline _LIBCPP_INLINE_VISIBILITY float remainder(float __x, float __y) _NOEXCEPT {return remainderf(__x, __y);}
1493inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __x, long double __y) _NOEXCEPT {return remainderl(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001494
1495template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001496inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001497typename enable_if
1498<
1499 is_arithmetic<_A1>::value &&
1500 is_arithmetic<_A2>::value,
1501 typename __promote<_A1, _A2>::type
1502>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001503remainder(_A1 __x, _A2 __y) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001504{
1505 typedef typename __promote<_A1, _A2>::type __result_type;
1506 static_assert((!(is_same<_A1, __result_type>::value &&
1507 is_same<_A2, __result_type>::value)), "");
1508 return remainder((__result_type)__x, (__result_type)__y);
1509}
1510
1511// remquo
1512
1513using ::remquo;
1514using ::remquof;
1515
Howard Hinnantcac0c462012-07-06 19:13:50 +00001516inline _LIBCPP_INLINE_VISIBILITY float remquo(float __x, float __y, int* __z) _NOEXCEPT {return remquof(__x, __y, __z);}
1517inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return remquol(__x, __y, __z);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001518
1519template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001520inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001521typename enable_if
1522<
1523 is_arithmetic<_A1>::value &&
1524 is_arithmetic<_A2>::value,
1525 typename __promote<_A1, _A2>::type
1526>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001527remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001528{
1529 typedef typename __promote<_A1, _A2>::type __result_type;
1530 static_assert((!(is_same<_A1, __result_type>::value &&
1531 is_same<_A2, __result_type>::value)), "");
1532 return remquo((__result_type)__x, (__result_type)__y, __z);
1533}
1534
1535// rint
1536
1537using ::rint;
1538using ::rintf;
1539
Howard Hinnantcac0c462012-07-06 19:13:50 +00001540inline _LIBCPP_INLINE_VISIBILITY float rint(float __x) _NOEXCEPT {return rintf(__x);}
1541inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __x) _NOEXCEPT {return rintl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001542
1543template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001544inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001545typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001546rint(_A1 __x) _NOEXCEPT {return rint((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001547
1548// round
1549
1550using ::round;
1551using ::roundf;
1552
Howard Hinnantcac0c462012-07-06 19:13:50 +00001553inline _LIBCPP_INLINE_VISIBILITY float round(float __x) _NOEXCEPT {return roundf(__x);}
1554inline _LIBCPP_INLINE_VISIBILITY long double round(long double __x) _NOEXCEPT {return roundl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001555
1556template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001557inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001558typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001559round(_A1 __x) _NOEXCEPT {return round((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001560
1561// scalbln
1562
1563using ::scalbln;
1564using ::scalblnf;
1565
Howard Hinnantcac0c462012-07-06 19:13:50 +00001566inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __x, long __y) _NOEXCEPT {return scalblnf(__x, __y);}
1567inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __x, long __y) _NOEXCEPT {return scalblnl(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001568
1569template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001570inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001571typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001572scalbln(_A1 __x, long __y) _NOEXCEPT {return scalbln((double)__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001573
1574// scalbn
1575
1576using ::scalbn;
1577using ::scalbnf;
1578
Howard Hinnantcac0c462012-07-06 19:13:50 +00001579inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __x, int __y) _NOEXCEPT {return scalbnf(__x, __y);}
1580inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __x, int __y) _NOEXCEPT {return scalbnl(__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001581
1582template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001583inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001584typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001585scalbn(_A1 __x, int __y) _NOEXCEPT {return scalbn((double)__x, __y);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001586
1587// tgamma
1588
1589using ::tgamma;
1590using ::tgammaf;
1591
Howard Hinnantcac0c462012-07-06 19:13:50 +00001592inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __x) _NOEXCEPT {return tgammaf(__x);}
1593inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __x) _NOEXCEPT {return tgammal(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001594
1595template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001596inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001597typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001598tgamma(_A1 __x) _NOEXCEPT {return tgamma((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001599
1600// trunc
1601
1602using ::trunc;
1603using ::truncf;
1604
Howard Hinnantcac0c462012-07-06 19:13:50 +00001605inline _LIBCPP_INLINE_VISIBILITY float trunc(float __x) _NOEXCEPT {return truncf(__x);}
1606inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __x) _NOEXCEPT {return truncl(__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001607
1608template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001609inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001610typename enable_if<is_integral<_A1>::value, double>::type
Howard Hinnantcac0c462012-07-06 19:13:50 +00001611trunc(_A1 __x) _NOEXCEPT {return trunc((double)__x);}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001612
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001613#endif // !_MSC_VER
1614
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001615using ::acosl;
1616using ::asinl;
1617using ::atanl;
1618using ::atan2l;
1619using ::ceill;
1620using ::cosl;
1621using ::coshl;
1622using ::expl;
1623using ::fabsl;
1624using ::floorl;
1625using ::fmodl;
1626using ::frexpl;
1627using ::ldexpl;
1628using ::logl;
1629using ::log10l;
1630using ::modfl;
1631using ::powl;
1632using ::sinl;
1633using ::sinhl;
1634using ::sqrtl;
1635using ::tanl;
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001636#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001637using ::tanhl;
1638using ::acoshl;
1639using ::asinhl;
1640using ::atanhl;
1641using ::cbrtl;
Howard Hinnantec3773c2011-12-01 20:21:04 +00001642#endif // !_MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001643using ::copysignl;
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001644#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001645using ::erfl;
1646using ::erfcl;
1647using ::exp2l;
1648using ::expm1l;
1649using ::fdiml;
1650using ::fmal;
1651using ::fmaxl;
1652using ::fminl;
1653using ::hypotl;
1654using ::ilogbl;
1655using ::lgammal;
1656using ::llrintl;
1657using ::llroundl;
1658using ::log1pl;
1659using ::log2l;
1660using ::logbl;
1661using ::lrintl;
1662using ::lroundl;
1663using ::nanl;
1664using ::nearbyintl;
1665using ::nextafterl;
1666using ::nexttowardl;
1667using ::remainderl;
1668using ::remquol;
1669using ::rintl;
1670using ::roundl;
1671using ::scalblnl;
1672using ::scalbnl;
1673using ::tgammal;
1674using ::truncl;
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001675#endif // !_MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001676
David Chisnall997e4542012-02-29 13:05:08 +00001677#else
1678using ::lgamma;
1679using ::lgammaf;
1680#endif // __sun__
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001681_LIBCPP_END_NAMESPACE_STD
1682
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001683#endif // _LIBCPP_CMATH