blob: ab67112ef1720da5403d40bd959c72407fed002c [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
140bool signbit(floating_point x);
141
142int fpclassify(floating_point x);
143
Howard Hinnant324bb032010-08-22 00:02:43 +0000144bool isfinite(floating_point x);
145bool isinf(floating_point x);
146bool isnan(floating_point x);
147bool isnormal(floating_point x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000148
Howard Hinnant324bb032010-08-22 00:02:43 +0000149bool isgreater(floating_point x, floating_point y);
150bool isgreaterequal(floating_point x, floating_point y);
151bool isless(floating_point x, floating_point y);
152bool islessequal(floating_point x, floating_point y);
153bool islessgreater(floating_point x, floating_point y);
154bool isunordered(floating_point x, floating_point 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
319__libcpp_signbit(_A1 __x)
320{
321 return signbit(__x);
322}
323
324#undef signbit
325
326template <class _A1>
327inline _LIBCPP_INLINE_VISIBILITY
328typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
329signbit(_A1 __x)
330{
331 return __libcpp_signbit(__x);
332}
333
334#endif // signbit
335
336// fpclassify
337
338#ifdef fpclassify
339
340template <class _A1>
341_LIBCPP_ALWAYS_INLINE
342int
343__libcpp_fpclassify(_A1 __x)
344{
345 return fpclassify(__x);
346}
347
348#undef fpclassify
349
350template <class _A1>
351inline _LIBCPP_INLINE_VISIBILITY
352typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
353fpclassify(_A1 __x)
354{
355 return __libcpp_fpclassify(__x);
356}
357
358#endif // fpclassify
359
360// isfinite
361
362#ifdef isfinite
363
364template <class _A1>
365_LIBCPP_ALWAYS_INLINE
366bool
367__libcpp_isfinite(_A1 __x)
368{
369 return isfinite(__x);
370}
371
372#undef isfinite
373
374template <class _A1>
375inline _LIBCPP_INLINE_VISIBILITY
376typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
377isfinite(_A1 __x)
378{
379 return __libcpp_isfinite(__x);
380}
381
382#endif // isfinite
383
384// isinf
385
386#ifdef isinf
387
388template <class _A1>
389_LIBCPP_ALWAYS_INLINE
390bool
391__libcpp_isinf(_A1 __x)
392{
393 return isinf(__x);
394}
395
396#undef isinf
397
398template <class _A1>
399inline _LIBCPP_INLINE_VISIBILITY
400typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
401isinf(_A1 __x)
402{
403 return __libcpp_isinf(__x);
404}
405
406#endif // isinf
407
408// isnan
409
410#ifdef isnan
411
412template <class _A1>
413_LIBCPP_ALWAYS_INLINE
414bool
415__libcpp_isnan(_A1 __x)
416{
417 return isnan(__x);
418}
419
420#undef isnan
421
422template <class _A1>
423inline _LIBCPP_INLINE_VISIBILITY
424typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
425isnan(_A1 __x)
426{
427 return __libcpp_isnan(__x);
428}
429
430#endif // isnan
431
432// isnormal
433
434#ifdef isnormal
435
436template <class _A1>
437_LIBCPP_ALWAYS_INLINE
438bool
439__libcpp_isnormal(_A1 __x)
440{
441 return isnormal(__x);
442}
443
444#undef isnormal
445
446template <class _A1>
447inline _LIBCPP_INLINE_VISIBILITY
448typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
449isnormal(_A1 __x)
450{
451 return __libcpp_isnormal(__x);
452}
453
454#endif // isnormal
455
456// isgreater
457
458#ifdef isgreater
459
460template <class _A1, class _A2>
461_LIBCPP_ALWAYS_INLINE
462bool
463__libcpp_isgreater(_A1 __x, _A2 __y)
464{
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<
474 std::is_floating_point<_A1>::value &&
475 std::is_floating_point<_A2>::value,
476 bool
477>::type
478isgreater(_A1 __x, _A2 __y)
479{
480 return __libcpp_isgreater(__x, __y);
481}
482
483#endif // isgreater
484
485// isgreaterequal
486
487#ifdef isgreaterequal
488
489template <class _A1, class _A2>
490_LIBCPP_ALWAYS_INLINE
491bool
492__libcpp_isgreaterequal(_A1 __x, _A2 __y)
493{
494 return isgreaterequal(__x, __y);
495}
496
497#undef isgreaterequal
498
499template <class _A1, class _A2>
500inline _LIBCPP_INLINE_VISIBILITY
501typename std::enable_if
502<
503 std::is_floating_point<_A1>::value &&
504 std::is_floating_point<_A2>::value,
505 bool
506>::type
507isgreaterequal(_A1 __x, _A2 __y)
508{
509 return __libcpp_isgreaterequal(__x, __y);
510}
511
512#endif // isgreaterequal
513
514// isless
515
516#ifdef isless
517
518template <class _A1, class _A2>
519_LIBCPP_ALWAYS_INLINE
520bool
521__libcpp_isless(_A1 __x, _A2 __y)
522{
523 return isless(__x, __y);
524}
525
526#undef isless
527
528template <class _A1, class _A2>
529inline _LIBCPP_INLINE_VISIBILITY
530typename std::enable_if
531<
532 std::is_floating_point<_A1>::value &&
533 std::is_floating_point<_A2>::value,
534 bool
535>::type
536isless(_A1 __x, _A2 __y)
537{
538 return __libcpp_isless(__x, __y);
539}
540
541#endif // isless
542
543// islessequal
544
545#ifdef islessequal
546
547template <class _A1, class _A2>
548_LIBCPP_ALWAYS_INLINE
549bool
550__libcpp_islessequal(_A1 __x, _A2 __y)
551{
552 return islessequal(__x, __y);
553}
554
555#undef islessequal
556
557template <class _A1, class _A2>
558inline _LIBCPP_INLINE_VISIBILITY
559typename std::enable_if
560<
561 std::is_floating_point<_A1>::value &&
562 std::is_floating_point<_A2>::value,
563 bool
564>::type
565islessequal(_A1 __x, _A2 __y)
566{
567 return __libcpp_islessequal(__x, __y);
568}
569
570#endif // islessequal
571
572// islessgreater
573
574#ifdef islessgreater
575
576template <class _A1, class _A2>
577_LIBCPP_ALWAYS_INLINE
578bool
579__libcpp_islessgreater(_A1 __x, _A2 __y)
580{
581 return islessgreater(__x, __y);
582}
583
584#undef islessgreater
585
586template <class _A1, class _A2>
587inline _LIBCPP_INLINE_VISIBILITY
588typename std::enable_if
589<
590 std::is_floating_point<_A1>::value &&
591 std::is_floating_point<_A2>::value,
592 bool
593>::type
594islessgreater(_A1 __x, _A2 __y)
595{
596 return __libcpp_islessgreater(__x, __y);
597}
598
599#endif // islessgreater
600
601// isunordered
602
603#ifdef isunordered
604
605template <class _A1, class _A2>
606_LIBCPP_ALWAYS_INLINE
607bool
608__libcpp_isunordered(_A1 __x, _A2 __y)
609{
610 return isunordered(__x, __y);
611}
612
613#undef isunordered
614
615template <class _A1, class _A2>
616inline _LIBCPP_INLINE_VISIBILITY
617typename std::enable_if
618<
619 std::is_floating_point<_A1>::value &&
620 std::is_floating_point<_A2>::value,
621 bool
622>::type
623isunordered(_A1 __x, _A2 __y)
624{
625 return __libcpp_isunordered(__x, __y);
626}
627
628#endif // isunordered
629
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000630_LIBCPP_BEGIN_NAMESPACE_STD
631
Howard Hinnant0a111112011-05-13 21:52:40 +0000632using ::signbit;
633using ::fpclassify;
634using ::isfinite;
635using ::isinf;
636using ::isnan;
637using ::isnormal;
638using ::isgreater;
639using ::isgreaterequal;
640using ::isless;
641using ::islessequal;
642using ::islessgreater;
643using ::isunordered;
644using ::isunordered;
645
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000646using ::float_t;
647using ::double_t;
648
649// abs
650
651template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000652inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000653typename enable_if<is_floating_point<_A1>::value, _A1>::type
654abs(_A1 __x) {return fabs(__x);}
655
656// acos
657
658using ::acos;
659using ::acosf;
660
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000661#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000662inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) {return acosf(__x);}
663inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) {return acosl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000664#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000665
666template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000667inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000668typename enable_if<is_integral<_A1>::value, double>::type
669acos(_A1 __x) {return acos((double)__x);}
670
671// asin
672
673using ::asin;
674using ::asinf;
675
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000676#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000677inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) {return asinf(__x);}
678inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) {return asinl(__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
684asin(_A1 __x) {return asin((double)__x);}
685
686// atan
687
688using ::atan;
689using ::atanf;
690
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000691#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000692inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) {return atanf(__x);}
693inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) {return atanl(__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
699atan(_A1 __x) {return atan((double)__x);}
700
701// atan2
702
703using ::atan2;
704using ::atan2f;
705
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000706#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000707inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) {return atan2f(__y, __x);}
708inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) {return atan2l(__y, __x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000709#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000710
711template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000712inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000713typename enable_if
714<
715 is_arithmetic<_A1>::value &&
716 is_arithmetic<_A2>::value,
717 typename __promote<_A1, _A2>::type
718>::type
719atan2(_A1 __y, _A2 __x)
720{
721 typedef typename __promote<_A1, _A2>::type __result_type;
722 static_assert((!(is_same<_A1, __result_type>::value &&
723 is_same<_A2, __result_type>::value)), "");
724 return atan2((__result_type)__y, (__result_type)__x);
725}
726
727// ceil
728
729using ::ceil;
730using ::ceilf;
731
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000732#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000733inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) {return ceilf(__x);}
734inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) {return ceill(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000735#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000736
737template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000738inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000739typename enable_if<is_integral<_A1>::value, double>::type
740ceil(_A1 __x) {return ceil((double)__x);}
741
742// cos
743
744using ::cos;
745using ::cosf;
746
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000747#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000748inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) {return cosf(__x);}
749inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) {return cosl(__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_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000754typename enable_if<is_integral<_A1>::value, double>::type
755cos(_A1 __x) {return cos((double)__x);}
756
757// cosh
758
759using ::cosh;
760using ::coshf;
761
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000762#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000763inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) {return coshf(__x);}
764inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) {return coshl(__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_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000769typename enable_if<is_integral<_A1>::value, double>::type
770cosh(_A1 __x) {return cosh((double)__x);}
771
772// exp
773
774using ::exp;
775using ::expf;
776
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000777#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000778inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) {return expf(__x);}
779inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) {return expl(__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
785exp(_A1 __x) {return exp((double)__x);}
786
787// fabs
788
789using ::fabs;
790using ::fabsf;
791
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000792#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000793inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) {return fabsf(__x);}
794inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) {return fabsl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000795#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000796
797template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000798inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000799typename enable_if<is_integral<_A1>::value, double>::type
800fabs(_A1 __x) {return fabs((double)__x);}
801
802// floor
803
804using ::floor;
805using ::floorf;
806
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000807#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000808inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) {return floorf(__x);}
809inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) {return floorl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000810#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000811
812template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000813inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000814typename enable_if<is_integral<_A1>::value, double>::type
815floor(_A1 __x) {return floor((double)__x);}
816
817// fmod
818
819using ::fmod;
820using ::fmodf;
821
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000822#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000823inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) {return fmodf(__x, __y);}
824inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) {return fmodl(__x, __y);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000825#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000826
827template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000828inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000829typename enable_if
830<
831 is_arithmetic<_A1>::value &&
832 is_arithmetic<_A2>::value,
833 typename __promote<_A1, _A2>::type
834>::type
835fmod(_A1 __x, _A2 __y)
836{
837 typedef typename __promote<_A1, _A2>::type __result_type;
838 static_assert((!(is_same<_A1, __result_type>::value &&
839 is_same<_A2, __result_type>::value)), "");
840 return fmod((__result_type)__x, (__result_type)__y);
841}
842
843// frexp
844
845using ::frexp;
846using ::frexpf;
847
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000848#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000849inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) {return frexpf(__x, __e);}
850inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) {return frexpl(__x, __e);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000851#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000852
853template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000854inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000855typename enable_if<is_integral<_A1>::value, double>::type
856frexp(_A1 __x, int* __e) {return frexp((double)__x, __e);}
857
858// ldexp
859
860using ::ldexp;
861using ::ldexpf;
862
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000863#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000864inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) {return ldexpf(__x, __e);}
865inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) {return ldexpl(__x, __e);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000866#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000867
868template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000869inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000870typename enable_if<is_integral<_A1>::value, double>::type
871ldexp(_A1 __x, int __e) {return ldexp((double)__x, __e);}
872
873// log
874
875using ::log;
876using ::logf;
877
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000878#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000879inline _LIBCPP_INLINE_VISIBILITY float log(float __x) {return logf(__x);}
880inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) {return logl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000881#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000882
883template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000884inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000885typename enable_if<is_integral<_A1>::value, double>::type
886log(_A1 __x) {return log((double)__x);}
887
888// log10
889
890using ::log10;
891using ::log10f;
892
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000893#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000894inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) {return log10f(__x);}
895inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) {return log10l(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000896#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000897
898template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000899inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000900typename enable_if<is_integral<_A1>::value, double>::type
901log10(_A1 __x) {return log10((double)__x);}
902
903// modf
904
905using ::modf;
906using ::modff;
907
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000908#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000909inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) {return modff(__x, __y);}
910inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) {return modfl(__x, __y);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000911#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000912
913// pow
914
915using ::pow;
916using ::powf;
917
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000918#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000919inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) {return powf(__x, __y);}
920inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) {return powl(__x, __y);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000921#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000922
923template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000924inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000925typename enable_if
926<
927 is_arithmetic<_A1>::value &&
928 is_arithmetic<_A2>::value,
929 typename __promote<_A1, _A2>::type
930>::type
931pow(_A1 __x, _A2 __y)
932{
933 typedef typename __promote<_A1, _A2>::type __result_type;
934 static_assert((!(is_same<_A1, __result_type>::value &&
935 is_same<_A2, __result_type>::value)), "");
936 return pow((__result_type)__x, (__result_type)__y);
937}
938
939// sin
940
941using ::sin;
942using ::sinf;
943
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000944#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000945inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) {return sinf(__x);}
946inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) {return sinl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000947#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000948
949template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000950inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000951typename enable_if<is_integral<_A1>::value, double>::type
952sin(_A1 __x) {return sin((double)__x);}
953
954// sinh
955
956using ::sinh;
957using ::sinhf;
958
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000959#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000960inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) {return sinhf(__x);}
961inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) {return sinhl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000962#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000963
964template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000965inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000966typename enable_if<is_integral<_A1>::value, double>::type
967sinh(_A1 __x) {return sinh((double)__x);}
968
969// sqrt
970
971using ::sqrt;
972using ::sqrtf;
973
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000974#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000975inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) {return sqrtf(__x);}
976inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) {return sqrtl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000977#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000978
979template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000980inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000981typename enable_if<is_integral<_A1>::value, double>::type
982sqrt(_A1 __x) {return sqrt((double)__x);}
983
984// tan
985
986using ::tan;
987using ::tanf;
988
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000989#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000990inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) {return tanf(__x);}
991inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) {return tanl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +0000992#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000993
994template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000995inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000996typename enable_if<is_integral<_A1>::value, double>::type
997tan(_A1 __x) {return tan((double)__x);}
998
999// tanh
1000
1001using ::tanh;
1002using ::tanhf;
1003
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001004#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001005inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) {return tanhf(__x);}
1006inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) {return tanhl(__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001007#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001008
1009template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001010inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001011typename enable_if<is_integral<_A1>::value, double>::type
1012tanh(_A1 __x) {return tanh((double)__x);}
1013
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001014// acosh
1015
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001016#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001017using ::acosh;
1018using ::acoshf;
1019
1020inline _LIBCPP_INLINE_VISIBILITY float acosh(float __x) {return acoshf(__x);}
1021inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __x) {return acoshl(__x);}
1022
1023template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001024inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001025typename enable_if<is_integral<_A1>::value, double>::type
1026acosh(_A1 __x) {return acosh((double)__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001027#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001028
1029// asinh
1030
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001031#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001032using ::asinh;
1033using ::asinhf;
1034
1035inline _LIBCPP_INLINE_VISIBILITY float asinh(float __x) {return asinhf(__x);}
1036inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __x) {return asinhl(__x);}
1037
1038template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001039inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001040typename enable_if<is_integral<_A1>::value, double>::type
1041asinh(_A1 __x) {return asinh((double)__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001042#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001043
1044// atanh
1045
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001046#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001047using ::atanh;
1048using ::atanhf;
1049
1050inline _LIBCPP_INLINE_VISIBILITY float atanh(float __x) {return atanhf(__x);}
1051inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __x) {return atanhl(__x);}
1052
1053template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001054inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001055typename enable_if<is_integral<_A1>::value, double>::type
1056atanh(_A1 __x) {return atanh((double)__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001057#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001058
1059// cbrt
1060
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001061#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001062using ::cbrt;
1063using ::cbrtf;
1064
1065inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __x) {return cbrtf(__x);}
1066inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __x) {return cbrtl(__x);}
1067
1068template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001069inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001070typename enable_if<is_integral<_A1>::value, double>::type
1071cbrt(_A1 __x) {return cbrt((double)__x);}
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001072#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001073
1074// copysign
1075
1076using ::copysign;
1077using ::copysignf;
1078
1079inline _LIBCPP_INLINE_VISIBILITY float copysign(float __x, float __y) {return copysignf(__x, __y);}
1080inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __x, long double __y) {return copysignl(__x, __y);}
1081
1082template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001083inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001084typename enable_if
1085<
1086 is_arithmetic<_A1>::value &&
1087 is_arithmetic<_A2>::value,
1088 typename __promote<_A1, _A2>::type
1089>::type
1090copysign(_A1 __x, _A2 __y)
1091{
1092 typedef typename __promote<_A1, _A2>::type __result_type;
1093 static_assert((!(is_same<_A1, __result_type>::value &&
1094 is_same<_A2, __result_type>::value)), "");
1095 return copysign((__result_type)__x, (__result_type)__y);
1096}
1097
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001098#ifndef _MSC_VER
1099
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001100// erf
1101
1102using ::erf;
1103using ::erff;
1104
1105inline _LIBCPP_INLINE_VISIBILITY float erf(float __x) {return erff(__x);}
1106inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __x) {return erfl(__x);}
1107
1108template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001109inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001110typename enable_if<is_integral<_A1>::value, double>::type
1111erf(_A1 __x) {return erf((double)__x);}
1112
1113// erfc
1114
1115using ::erfc;
1116using ::erfcf;
1117
1118inline _LIBCPP_INLINE_VISIBILITY float erfc(float __x) {return erfcf(__x);}
1119inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __x) {return erfcl(__x);}
1120
1121template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001122inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001123typename enable_if<is_integral<_A1>::value, double>::type
1124erfc(_A1 __x) {return erfc((double)__x);}
1125
1126// exp2
1127
1128using ::exp2;
1129using ::exp2f;
1130
1131inline _LIBCPP_INLINE_VISIBILITY float exp2(float __x) {return exp2f(__x);}
1132inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __x) {return exp2l(__x);}
1133
1134template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001135inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001136typename enable_if<is_integral<_A1>::value, double>::type
1137exp2(_A1 __x) {return exp2((double)__x);}
1138
1139// expm1
1140
1141using ::expm1;
1142using ::expm1f;
1143
1144inline _LIBCPP_INLINE_VISIBILITY float expm1(float __x) {return expm1f(__x);}
1145inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __x) {return expm1l(__x);}
1146
1147template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001148inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001149typename enable_if<is_integral<_A1>::value, double>::type
1150expm1(_A1 __x) {return expm1((double)__x);}
1151
1152// fdim
1153
1154using ::fdim;
1155using ::fdimf;
1156
1157inline _LIBCPP_INLINE_VISIBILITY float fdim(float __x, float __y) {return fdimf(__x, __y);}
1158inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __x, long double __y) {return fdiml(__x, __y);}
1159
1160template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001161inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001162typename enable_if
1163<
1164 is_arithmetic<_A1>::value &&
1165 is_arithmetic<_A2>::value,
1166 typename __promote<_A1, _A2>::type
1167>::type
1168fdim(_A1 __x, _A2 __y)
1169{
1170 typedef typename __promote<_A1, _A2>::type __result_type;
1171 static_assert((!(is_same<_A1, __result_type>::value &&
1172 is_same<_A2, __result_type>::value)), "");
1173 return fdim((__result_type)__x, (__result_type)__y);
1174}
1175
1176// fma
1177
1178inline _LIBCPP_INLINE_VISIBILITY float fmaf(float __x, float __y, float __z) {return (float)((double)__x*__y + __z);}
1179#define FP_FAST_FMAF
1180
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001181using ::fma;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001182
1183inline _LIBCPP_INLINE_VISIBILITY float fma(float __x, float __y, float __z) {return fmaf(__x, __y, __z);}
1184inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __x, long double __y, long double __z) {return fmal(__x, __y, __z);}
1185
1186template <class _A1, class _A2, class _A3>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001187inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001188typename enable_if
1189<
1190 is_arithmetic<_A1>::value &&
1191 is_arithmetic<_A2>::value &&
1192 is_arithmetic<_A3>::value,
1193 typename __promote<_A1, _A2, _A3>::type
1194>::type
1195fma(_A1 __x, _A2 __y, _A3 __z)
1196{
1197 typedef typename __promote<_A1, _A2, _A3>::type __result_type;
1198 static_assert((!(is_same<_A1, __result_type>::value &&
1199 is_same<_A2, __result_type>::value &&
1200 is_same<_A3, __result_type>::value)), "");
1201 return fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
1202}
1203
1204// fmax
1205
1206using ::fmax;
1207using ::fmaxf;
1208
1209inline _LIBCPP_INLINE_VISIBILITY float fmax(float __x, float __y) {return fmaxf(__x, __y);}
1210inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __x, long double __y) {return fmaxl(__x, __y);}
1211
1212template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001213inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001214typename enable_if
1215<
1216 is_arithmetic<_A1>::value &&
1217 is_arithmetic<_A2>::value,
1218 typename __promote<_A1, _A2>::type
1219>::type
1220fmax(_A1 __x, _A2 __y)
1221{
1222 typedef typename __promote<_A1, _A2>::type __result_type;
1223 static_assert((!(is_same<_A1, __result_type>::value &&
1224 is_same<_A2, __result_type>::value)), "");
1225 return fmax((__result_type)__x, (__result_type)__y);
1226}
1227
1228// fmin
1229
1230using ::fmin;
1231using ::fminf;
1232
1233inline _LIBCPP_INLINE_VISIBILITY float fmin(float __x, float __y) {return fminf(__x, __y);}
1234inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __x, long double __y) {return fminl(__x, __y);}
1235
1236template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001237inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001238typename enable_if
1239<
1240 is_arithmetic<_A1>::value &&
1241 is_arithmetic<_A2>::value,
1242 typename __promote<_A1, _A2>::type
1243>::type
1244fmin(_A1 __x, _A2 __y)
1245{
1246 typedef typename __promote<_A1, _A2>::type __result_type;
1247 static_assert((!(is_same<_A1, __result_type>::value &&
1248 is_same<_A2, __result_type>::value)), "");
1249 return fmin((__result_type)__x, (__result_type)__y);
1250}
1251
1252// hypot
1253
1254using ::hypot;
1255using ::hypotf;
1256
1257inline _LIBCPP_INLINE_VISIBILITY float hypot(float __x, float __y) {return hypotf(__x, __y);}
1258inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __x, long double __y) {return hypotl(__x, __y);}
1259
1260template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001261inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001262typename enable_if
1263<
1264 is_arithmetic<_A1>::value &&
1265 is_arithmetic<_A2>::value,
1266 typename __promote<_A1, _A2>::type
1267>::type
1268hypot(_A1 __x, _A2 __y)
1269{
1270 typedef typename __promote<_A1, _A2>::type __result_type;
1271 static_assert((!(is_same<_A1, __result_type>::value &&
1272 is_same<_A2, __result_type>::value)), "");
1273 return hypot((__result_type)__x, (__result_type)__y);
1274}
1275
1276// ilogb
1277
1278using ::ilogb;
1279using ::ilogbf;
1280
1281inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __x) {return ilogbf(__x);}
1282inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __x) {return ilogbl(__x);}
1283
1284template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001285inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001286typename enable_if<is_integral<_A1>::value, int>::type
1287ilogb(_A1 __x) {return ilogb((double)__x);}
1288
1289// lgamma
1290
1291using ::lgamma;
1292using ::lgammaf;
1293
1294inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __x) {return lgammaf(__x);}
1295inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __x) {return lgammal(__x);}
1296
1297template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001298inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001299typename enable_if<is_integral<_A1>::value, double>::type
1300lgamma(_A1 __x) {return lgamma((double)__x);}
1301
1302// llrint
1303
1304using ::llrint;
1305using ::llrintf;
1306
1307inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __x) {return llrintf(__x);}
1308inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __x) {return llrintl(__x);}
1309
1310template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001311inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001312typename enable_if<is_integral<_A1>::value, long long>::type
1313llrint(_A1 __x) {return llrint((double)__x);}
1314
1315// llround
1316
1317using ::llround;
1318using ::llroundf;
1319
1320inline _LIBCPP_INLINE_VISIBILITY long long llround(float __x) {return llroundf(__x);}
1321inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __x) {return llroundl(__x);}
1322
1323template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001324inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001325typename enable_if<is_integral<_A1>::value, long long>::type
1326llround(_A1 __x) {return llround((double)__x);}
1327
1328// log1p
1329
1330using ::log1p;
1331using ::log1pf;
1332
1333inline _LIBCPP_INLINE_VISIBILITY float log1p(float __x) {return log1pf(__x);}
1334inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __x) {return log1pl(__x);}
1335
1336template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001337inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001338typename enable_if<is_integral<_A1>::value, double>::type
1339log1p(_A1 __x) {return log1p((double)__x);}
1340
1341// log2
1342
1343using ::log2;
1344using ::log2f;
1345
1346inline _LIBCPP_INLINE_VISIBILITY float log2(float __x) {return log2f(__x);}
1347inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __x) {return log2l(__x);}
1348
1349template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001350inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001351typename enable_if<is_integral<_A1>::value, double>::type
1352log2(_A1 __x) {return log2((double)__x);}
1353
1354// logb
1355
1356using ::logb;
1357using ::logbf;
1358
1359inline _LIBCPP_INLINE_VISIBILITY float logb(float __x) {return logbf(__x);}
1360inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __x) {return logbl(__x);}
1361
1362template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001363inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001364typename enable_if<is_integral<_A1>::value, double>::type
1365logb(_A1 __x) {return logb((double)__x);}
1366
1367// lrint
1368
1369using ::lrint;
1370using ::lrintf;
1371
1372inline _LIBCPP_INLINE_VISIBILITY long lrint(float __x) {return lrintf(__x);}
1373inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __x) {return lrintl(__x);}
1374
1375template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001376inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001377typename enable_if<is_integral<_A1>::value, long>::type
1378lrint(_A1 __x) {return lrint((double)__x);}
1379
1380// lround
1381
1382using ::lround;
1383using ::lroundf;
1384
1385inline _LIBCPP_INLINE_VISIBILITY long lround(float __x) {return lroundf(__x);}
1386inline _LIBCPP_INLINE_VISIBILITY long lround(long double __x) {return lroundl(__x);}
1387
1388template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001389inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001390typename enable_if<is_integral<_A1>::value, long>::type
1391lround(_A1 __x) {return lround((double)__x);}
1392
1393// nan
1394
1395using ::nan;
1396using ::nanf;
1397
1398// nearbyint
1399
1400using ::nearbyint;
1401using ::nearbyintf;
1402
1403inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __x) {return nearbyintf(__x);}
1404inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __x) {return nearbyintl(__x);}
1405
1406template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001407inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001408typename enable_if<is_integral<_A1>::value, double>::type
1409nearbyint(_A1 __x) {return nearbyint((double)__x);}
1410
1411// nextafter
1412
1413using ::nextafter;
1414using ::nextafterf;
1415
1416inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __x, float __y) {return nextafterf(__x, __y);}
1417inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __x, long double __y) {return nextafterl(__x, __y);}
1418
1419template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001420inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001421typename enable_if
1422<
1423 is_arithmetic<_A1>::value &&
1424 is_arithmetic<_A2>::value,
1425 typename __promote<_A1, _A2>::type
1426>::type
1427nextafter(_A1 __x, _A2 __y)
1428{
1429 typedef typename __promote<_A1, _A2>::type __result_type;
1430 static_assert((!(is_same<_A1, __result_type>::value &&
1431 is_same<_A2, __result_type>::value)), "");
1432 return nextafter((__result_type)__x, (__result_type)__y);
1433}
1434
1435// nexttoward
1436
1437using ::nexttoward;
1438using ::nexttowardf;
1439
1440inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __x, long double __y) {return nexttowardf(__x, __y);}
1441inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __x, long double __y) {return nexttowardl(__x, __y);}
1442
1443template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001444inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001445typename enable_if<is_integral<_A1>::value, double>::type
1446nexttoward(_A1 __x, long double __y) {return nexttoward((double)__x, __y);}
1447
1448// remainder
1449
1450using ::remainder;
1451using ::remainderf;
1452
1453inline _LIBCPP_INLINE_VISIBILITY float remainder(float __x, float __y) {return remainderf(__x, __y);}
1454inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __x, long double __y) {return remainderl(__x, __y);}
1455
1456template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001457inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001458typename enable_if
1459<
1460 is_arithmetic<_A1>::value &&
1461 is_arithmetic<_A2>::value,
1462 typename __promote<_A1, _A2>::type
1463>::type
1464remainder(_A1 __x, _A2 __y)
1465{
1466 typedef typename __promote<_A1, _A2>::type __result_type;
1467 static_assert((!(is_same<_A1, __result_type>::value &&
1468 is_same<_A2, __result_type>::value)), "");
1469 return remainder((__result_type)__x, (__result_type)__y);
1470}
1471
1472// remquo
1473
1474using ::remquo;
1475using ::remquof;
1476
1477inline _LIBCPP_INLINE_VISIBILITY float remquo(float __x, float __y, int* __z) {return remquof(__x, __y, __z);}
1478inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __x, long double __y, int* __z) {return remquol(__x, __y, __z);}
1479
1480template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001481inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001482typename enable_if
1483<
1484 is_arithmetic<_A1>::value &&
1485 is_arithmetic<_A2>::value,
1486 typename __promote<_A1, _A2>::type
1487>::type
1488remquo(_A1 __x, _A2 __y, int* __z)
1489{
1490 typedef typename __promote<_A1, _A2>::type __result_type;
1491 static_assert((!(is_same<_A1, __result_type>::value &&
1492 is_same<_A2, __result_type>::value)), "");
1493 return remquo((__result_type)__x, (__result_type)__y, __z);
1494}
1495
1496// rint
1497
1498using ::rint;
1499using ::rintf;
1500
1501inline _LIBCPP_INLINE_VISIBILITY float rint(float __x) {return rintf(__x);}
1502inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __x) {return rintl(__x);}
1503
1504template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001505inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001506typename enable_if<is_integral<_A1>::value, double>::type
1507rint(_A1 __x) {return rint((double)__x);}
1508
1509// round
1510
1511using ::round;
1512using ::roundf;
1513
1514inline _LIBCPP_INLINE_VISIBILITY float round(float __x) {return roundf(__x);}
1515inline _LIBCPP_INLINE_VISIBILITY long double round(long double __x) {return roundl(__x);}
1516
1517template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001518inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001519typename enable_if<is_integral<_A1>::value, double>::type
1520round(_A1 __x) {return round((double)__x);}
1521
1522// scalbln
1523
1524using ::scalbln;
1525using ::scalblnf;
1526
1527inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __x, long __y) {return scalblnf(__x, __y);}
1528inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __x, long __y) {return scalblnl(__x, __y);}
1529
1530template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001531inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001532typename enable_if<is_integral<_A1>::value, double>::type
1533scalbln(_A1 __x, long __y) {return scalbln((double)__x, __y);}
1534
1535// scalbn
1536
1537using ::scalbn;
1538using ::scalbnf;
1539
1540inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __x, int __y) {return scalbnf(__x, __y);}
1541inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __x, int __y) {return scalbnl(__x, __y);}
1542
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
1546scalbn(_A1 __x, int __y) {return scalbn((double)__x, __y);}
1547
1548// tgamma
1549
1550using ::tgamma;
1551using ::tgammaf;
1552
1553inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __x) {return tgammaf(__x);}
1554inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __x) {return tgammal(__x);}
1555
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
1559tgamma(_A1 __x) {return tgamma((double)__x);}
1560
1561// trunc
1562
1563using ::trunc;
1564using ::truncf;
1565
1566inline _LIBCPP_INLINE_VISIBILITY float trunc(float __x) {return truncf(__x);}
1567inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __x) {return truncl(__x);}
1568
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
1572trunc(_A1 __x) {return trunc((double)__x);}
1573
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001574#endif // !_MSC_VER
1575
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001576using ::acosl;
1577using ::asinl;
1578using ::atanl;
1579using ::atan2l;
1580using ::ceill;
1581using ::cosl;
1582using ::coshl;
1583using ::expl;
1584using ::fabsl;
1585using ::floorl;
1586using ::fmodl;
1587using ::frexpl;
1588using ::ldexpl;
1589using ::logl;
1590using ::log10l;
1591using ::modfl;
1592using ::powl;
1593using ::sinl;
1594using ::sinhl;
1595using ::sqrtl;
1596using ::tanl;
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001597#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001598using ::tanhl;
1599using ::acoshl;
1600using ::asinhl;
1601using ::atanhl;
1602using ::cbrtl;
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001603#endif !_MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001604using ::copysignl;
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001605#ifndef _MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001606using ::erfl;
1607using ::erfcl;
1608using ::exp2l;
1609using ::expm1l;
1610using ::fdiml;
1611using ::fmal;
1612using ::fmaxl;
1613using ::fminl;
1614using ::hypotl;
1615using ::ilogbl;
1616using ::lgammal;
1617using ::llrintl;
1618using ::llroundl;
1619using ::log1pl;
1620using ::log2l;
1621using ::logbl;
1622using ::lrintl;
1623using ::lroundl;
1624using ::nanl;
1625using ::nearbyintl;
1626using ::nextafterl;
1627using ::nexttowardl;
1628using ::remainderl;
1629using ::remquol;
1630using ::rintl;
1631using ::roundl;
1632using ::scalblnl;
1633using ::scalbnl;
1634using ::tgammal;
1635using ::truncl;
Howard Hinnant9f8884e2011-10-27 16:24:42 +00001636#endif // !_MSC_VER
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001637
1638_LIBCPP_END_NAMESPACE_STD
1639
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001640#endif // _LIBCPP_CMATH