blob: 51d519d1ca6a8b29c777e050dfe4decd0dfe66b2 [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//
6// This file is distributed under the University of Illinois Open Source
7// License. See LICENSE.TXT for details.
8//
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
Howard Hinnant324bb032010-08-22 00:02:43 +0000300// FIXME: work around for Clang with -std=C++0x on OSX/iOS
Howard Hinnant60a0a8e2010-08-10 20:48:29 +0000301#if defined(__clang__) && defined(__APPLE__)
302# pragma push_macro("__STRICT_ANSI__")
303# undef __STRICT_ANSI__
Howard Hinnant324bb032010-08-22 00:02:43 +0000304#endif // defined(__clang__) && defined(__APPLE__)
Howard Hinnant60a0a8e2010-08-10 20:48:29 +0000305
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000306#include <__config>
307#include <math.h>
308#include <type_traits>
309
310#pragma GCC system_header
311
312_LIBCPP_BEGIN_NAMESPACE_STD
313
314using ::float_t;
315using ::double_t;
316
317// abs
318
319template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000320_LIBCPP_INLINE_VISIBILITY
321typename enable_if<is_floating_point<_A1>::value, _A1>::type
322abs(_A1 __x) {return fabs(__x);}
323
324// acos
325
326using ::acos;
327using ::acosf;
328
329inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) {return acosf(__x);}
330inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) {return acosl(__x);}
331
332template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000333_LIBCPP_INLINE_VISIBILITY
334typename enable_if<is_integral<_A1>::value, double>::type
335acos(_A1 __x) {return acos((double)__x);}
336
337// asin
338
339using ::asin;
340using ::asinf;
341
342inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) {return asinf(__x);}
343inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) {return asinl(__x);}
344
345template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000346_LIBCPP_INLINE_VISIBILITY
347typename enable_if<is_integral<_A1>::value, double>::type
348asin(_A1 __x) {return asin((double)__x);}
349
350// atan
351
352using ::atan;
353using ::atanf;
354
355inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) {return atanf(__x);}
356inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) {return atanl(__x);}
357
358template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000359_LIBCPP_INLINE_VISIBILITY
360typename enable_if<is_integral<_A1>::value, double>::type
361atan(_A1 __x) {return atan((double)__x);}
362
363// atan2
364
365using ::atan2;
366using ::atan2f;
367
368inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) {return atan2f(__y, __x);}
369inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) {return atan2l(__y, __x);}
370
371template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000372_LIBCPP_INLINE_VISIBILITY
373typename enable_if
374<
375 is_arithmetic<_A1>::value &&
376 is_arithmetic<_A2>::value,
377 typename __promote<_A1, _A2>::type
378>::type
379atan2(_A1 __y, _A2 __x)
380{
381 typedef typename __promote<_A1, _A2>::type __result_type;
382 static_assert((!(is_same<_A1, __result_type>::value &&
383 is_same<_A2, __result_type>::value)), "");
384 return atan2((__result_type)__y, (__result_type)__x);
385}
386
387// ceil
388
389using ::ceil;
390using ::ceilf;
391
392inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) {return ceilf(__x);}
393inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) {return ceill(__x);}
394
395template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000396_LIBCPP_INLINE_VISIBILITY
397typename enable_if<is_integral<_A1>::value, double>::type
398ceil(_A1 __x) {return ceil((double)__x);}
399
400// cos
401
402using ::cos;
403using ::cosf;
404
405inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) {return cosf(__x);}
406inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) {return cosl(__x);}
407
408template <class _A1>
409_LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
410typename enable_if<is_integral<_A1>::value, double>::type
411cos(_A1 __x) {return cos((double)__x);}
412
413// cosh
414
415using ::cosh;
416using ::coshf;
417
418inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) {return coshf(__x);}
419inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) {return coshl(__x);}
420
421template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000422_LIBCPP_INLINE_VISIBILITY
423typename enable_if<is_integral<_A1>::value, double>::type
424cosh(_A1 __x) {return cosh((double)__x);}
425
426// exp
427
428using ::exp;
429using ::expf;
430
431inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) {return expf(__x);}
432inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) {return expl(__x);}
433
434template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000435_LIBCPP_INLINE_VISIBILITY
436typename enable_if<is_integral<_A1>::value, double>::type
437exp(_A1 __x) {return exp((double)__x);}
438
439// fabs
440
441using ::fabs;
442using ::fabsf;
443
444inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) {return fabsf(__x);}
445inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) {return fabsl(__x);}
446
447template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000448_LIBCPP_INLINE_VISIBILITY
449typename enable_if<is_integral<_A1>::value, double>::type
450fabs(_A1 __x) {return fabs((double)__x);}
451
452// floor
453
454using ::floor;
455using ::floorf;
456
457inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) {return floorf(__x);}
458inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) {return floorl(__x);}
459
460template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000461_LIBCPP_INLINE_VISIBILITY
462typename enable_if<is_integral<_A1>::value, double>::type
463floor(_A1 __x) {return floor((double)__x);}
464
465// fmod
466
467using ::fmod;
468using ::fmodf;
469
470inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) {return fmodf(__x, __y);}
471inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) {return fmodl(__x, __y);}
472
473template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000474_LIBCPP_INLINE_VISIBILITY
475typename enable_if
476<
477 is_arithmetic<_A1>::value &&
478 is_arithmetic<_A2>::value,
479 typename __promote<_A1, _A2>::type
480>::type
481fmod(_A1 __x, _A2 __y)
482{
483 typedef typename __promote<_A1, _A2>::type __result_type;
484 static_assert((!(is_same<_A1, __result_type>::value &&
485 is_same<_A2, __result_type>::value)), "");
486 return fmod((__result_type)__x, (__result_type)__y);
487}
488
489// frexp
490
491using ::frexp;
492using ::frexpf;
493
494inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) {return frexpf(__x, __e);}
495inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) {return frexpl(__x, __e);}
496
497template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000498_LIBCPP_INLINE_VISIBILITY
499typename enable_if<is_integral<_A1>::value, double>::type
500frexp(_A1 __x, int* __e) {return frexp((double)__x, __e);}
501
502// ldexp
503
504using ::ldexp;
505using ::ldexpf;
506
507inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) {return ldexpf(__x, __e);}
508inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) {return ldexpl(__x, __e);}
509
510template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000511_LIBCPP_INLINE_VISIBILITY
512typename enable_if<is_integral<_A1>::value, double>::type
513ldexp(_A1 __x, int __e) {return ldexp((double)__x, __e);}
514
515// log
516
517using ::log;
518using ::logf;
519
520inline _LIBCPP_INLINE_VISIBILITY float log(float __x) {return logf(__x);}
521inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) {return logl(__x);}
522
523template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000524_LIBCPP_INLINE_VISIBILITY
525typename enable_if<is_integral<_A1>::value, double>::type
526log(_A1 __x) {return log((double)__x);}
527
528// log10
529
530using ::log10;
531using ::log10f;
532
533inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) {return log10f(__x);}
534inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) {return log10l(__x);}
535
536template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000537_LIBCPP_INLINE_VISIBILITY
538typename enable_if<is_integral<_A1>::value, double>::type
539log10(_A1 __x) {return log10((double)__x);}
540
541// modf
542
543using ::modf;
544using ::modff;
545
546inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) {return modff(__x, __y);}
547inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) {return modfl(__x, __y);}
548
549// pow
550
551using ::pow;
552using ::powf;
553
554inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) {return powf(__x, __y);}
555inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) {return powl(__x, __y);}
556
557template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000558_LIBCPP_INLINE_VISIBILITY
559typename enable_if
560<
561 is_arithmetic<_A1>::value &&
562 is_arithmetic<_A2>::value,
563 typename __promote<_A1, _A2>::type
564>::type
565pow(_A1 __x, _A2 __y)
566{
567 typedef typename __promote<_A1, _A2>::type __result_type;
568 static_assert((!(is_same<_A1, __result_type>::value &&
569 is_same<_A2, __result_type>::value)), "");
570 return pow((__result_type)__x, (__result_type)__y);
571}
572
573// sin
574
575using ::sin;
576using ::sinf;
577
578inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) {return sinf(__x);}
579inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) {return sinl(__x);}
580
581template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000582_LIBCPP_INLINE_VISIBILITY
583typename enable_if<is_integral<_A1>::value, double>::type
584sin(_A1 __x) {return sin((double)__x);}
585
586// sinh
587
588using ::sinh;
589using ::sinhf;
590
591inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) {return sinhf(__x);}
592inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) {return sinhl(__x);}
593
594template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000595_LIBCPP_INLINE_VISIBILITY
596typename enable_if<is_integral<_A1>::value, double>::type
597sinh(_A1 __x) {return sinh((double)__x);}
598
599// sqrt
600
601using ::sqrt;
602using ::sqrtf;
603
604inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) {return sqrtf(__x);}
605inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) {return sqrtl(__x);}
606
607template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000608_LIBCPP_INLINE_VISIBILITY
609typename enable_if<is_integral<_A1>::value, double>::type
610sqrt(_A1 __x) {return sqrt((double)__x);}
611
612// tan
613
614using ::tan;
615using ::tanf;
616
617inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) {return tanf(__x);}
618inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) {return tanl(__x);}
619
620template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000621_LIBCPP_INLINE_VISIBILITY
622typename enable_if<is_integral<_A1>::value, double>::type
623tan(_A1 __x) {return tan((double)__x);}
624
625// tanh
626
627using ::tanh;
628using ::tanhf;
629
630inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) {return tanhf(__x);}
631inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) {return tanhl(__x);}
632
633template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000634_LIBCPP_INLINE_VISIBILITY
635typename enable_if<is_integral<_A1>::value, double>::type
636tanh(_A1 __x) {return tanh((double)__x);}
637
638// signbit
639
640#ifndef signbit
641#error Implementation error: signbit not defined
642#else
643
644template <class _A1>
645_LIBCPP_ALWAYS_INLINE
646bool
647__libcpp_signbit(_A1 __x)
648{
649 return signbit(__x);
650}
651
652#undef signbit
653
654template <class _A1>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000655_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000656typename enable_if<is_floating_point<_A1>::value, bool>::type
657signbit(_A1 __x)
658{
659 return __libcpp_signbit(__x);
660}
661
662#endif // signbit
663
664// fpclassify
665
666#ifndef fpclassify
667#error Implementation error: fpclassify not defined
668#else
669
670template <class _A1>
671_LIBCPP_ALWAYS_INLINE
672int
673__libcpp_fpclassify(_A1 __x)
674{
675 return fpclassify(__x);
676}
677
678#undef fpclassify
679
680template <class _A1>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000681_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000682typename enable_if<is_floating_point<_A1>::value, int>::type
683fpclassify(_A1 __x)
684{
685 return __libcpp_fpclassify(__x);
686}
687
688#endif // fpclassify
689
690// isfinite
691
692#ifndef isfinite
693#error Implementation error: isfinite not defined
694#else
695
696template <class _A1>
697_LIBCPP_ALWAYS_INLINE
698bool
699__libcpp_isfinite(_A1 __x)
700{
701 return isfinite(__x);
702}
703
704#undef isfinite
705
706template <class _A1>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000707_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000708typename enable_if<is_floating_point<_A1>::value, bool>::type
709isfinite(_A1 __x)
710{
711 return __libcpp_isfinite(__x);
712}
713
714#endif // isfinite
715
716// isinf
717
718#ifndef isinf
719#error Implementation error: isinf not defined
720#else
721
722template <class _A1>
723_LIBCPP_ALWAYS_INLINE
724bool
725__libcpp_isinf(_A1 __x)
726{
727 return isinf(__x);
728}
729
730#undef isinf
731
732template <class _A1>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000733_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000734typename enable_if<is_floating_point<_A1>::value, bool>::type
735isinf(_A1 __x)
736{
737 return __libcpp_isinf(__x);
738}
739
740#endif // isinf
741
742// isnan
743
744#ifndef isnan
745#error Implementation error: isnan not defined
746#else
747
748template <class _A1>
749_LIBCPP_ALWAYS_INLINE
750bool
751__libcpp_isnan(_A1 __x)
752{
753 return isnan(__x);
754}
755
756#undef isnan
757
758template <class _A1>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000759_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000760typename enable_if<is_floating_point<_A1>::value, bool>::type
761isnan(_A1 __x)
762{
763 return __libcpp_isnan(__x);
764}
765
766#endif // isnan
767
768// isnormal
769
770#ifndef isnormal
771#error Implementation error: isnormal not defined
772#else
773
774template <class _A1>
775_LIBCPP_ALWAYS_INLINE
776bool
777__libcpp_isnormal(_A1 __x)
778{
779 return isnormal(__x);
780}
781
782#undef isnormal
783
784template <class _A1>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000785_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000786typename enable_if<is_floating_point<_A1>::value, bool>::type
787isnormal(_A1 __x)
788{
789 return __libcpp_isnormal(__x);
790}
791
792#endif // isnormal
793
794// isgreater
795
796#ifndef isgreater
797#error Implementation error: isgreater not defined
798#else
799
800template <class _A1, class _A2>
801_LIBCPP_ALWAYS_INLINE
802bool
803__libcpp_isgreater(_A1 __x, _A2 __y)
804{
805 return isgreater(__x, __y);
806}
807
808#undef isgreater
809
810template <class _A1, class _A2>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000811_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000812typename enable_if
813<
814 is_floating_point<_A1>::value &&
815 is_floating_point<_A2>::value,
816 bool
817>::type
818isgreater(_A1 __x, _A2 __y)
819{
820 return __libcpp_isgreater(__x, __y);
821}
822
823#endif // isgreater
824
825// isgreaterequal
826
827#ifndef isgreaterequal
828#error Implementation error: isgreaterequal not defined
829#else
830
831template <class _A1, class _A2>
832_LIBCPP_ALWAYS_INLINE
833bool
834__libcpp_isgreaterequal(_A1 __x, _A2 __y)
835{
836 return isgreaterequal(__x, __y);
837}
838
839#undef isgreaterequal
840
841template <class _A1, class _A2>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000842_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000843typename enable_if
844<
845 is_floating_point<_A1>::value &&
846 is_floating_point<_A2>::value,
847 bool
848>::type
849isgreaterequal(_A1 __x, _A2 __y)
850{
851 return __libcpp_isgreaterequal(__x, __y);
852}
853
854#endif // isgreaterequal
855
856// isless
857
858#ifndef isless
859#error Implementation error: isless not defined
860#else
861
862template <class _A1, class _A2>
863_LIBCPP_ALWAYS_INLINE
864bool
865__libcpp_isless(_A1 __x, _A2 __y)
866{
867 return isless(__x, __y);
868}
869
870#undef isless
871
872template <class _A1, class _A2>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000873_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000874typename enable_if
875<
876 is_floating_point<_A1>::value &&
877 is_floating_point<_A2>::value,
878 bool
879>::type
880isless(_A1 __x, _A2 __y)
881{
882 return __libcpp_isless(__x, __y);
883}
884
885#endif // isless
886
887// islessequal
888
889#ifndef islessequal
890#error Implementation error: islessequal not defined
891#else
892
893template <class _A1, class _A2>
894_LIBCPP_ALWAYS_INLINE
895bool
896__libcpp_islessequal(_A1 __x, _A2 __y)
897{
898 return islessequal(__x, __y);
899}
900
901#undef islessequal
902
903template <class _A1, class _A2>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000904_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000905typename enable_if
906<
907 is_floating_point<_A1>::value &&
908 is_floating_point<_A2>::value,
909 bool
910>::type
911islessequal(_A1 __x, _A2 __y)
912{
913 return __libcpp_islessequal(__x, __y);
914}
915
916#endif // islessequal
917
918// islessgreater
919
920#ifndef islessgreater
921#error Implementation error: islessgreater not defined
922#else
923
924template <class _A1, class _A2>
925_LIBCPP_ALWAYS_INLINE
926bool
927__libcpp_islessgreater(_A1 __x, _A2 __y)
928{
929 return islessgreater(__x, __y);
930}
931
932#undef islessgreater
933
934template <class _A1, class _A2>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000935_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000936typename enable_if
937<
938 is_floating_point<_A1>::value &&
939 is_floating_point<_A2>::value,
940 bool
941>::type
942islessgreater(_A1 __x, _A2 __y)
943{
944 return __libcpp_islessgreater(__x, __y);
945}
946
947#endif // islessgreater
948
949// isunordered
950
951#ifndef isunordered
952#error Implementation error: isunordered not defined
953#else
954
955template <class _A1, class _A2>
956_LIBCPP_ALWAYS_INLINE
957bool
958__libcpp_isunordered(_A1 __x, _A2 __y)
959{
960 return isunordered(__x, __y);
961}
962
963#undef isunordered
964
965template <class _A1, class _A2>
Howard Hinnantc0de2e42010-09-21 16:04:28 +0000966_LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000967typename enable_if
968<
969 is_floating_point<_A1>::value &&
970 is_floating_point<_A2>::value,
971 bool
972>::type
973isunordered(_A1 __x, _A2 __y)
974{
975 return __libcpp_isunordered(__x, __y);
976}
977
978#endif // isunordered
979
980// acosh
981
982using ::acosh;
983using ::acoshf;
984
985inline _LIBCPP_INLINE_VISIBILITY float acosh(float __x) {return acoshf(__x);}
986inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __x) {return acoshl(__x);}
987
988template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000989_LIBCPP_INLINE_VISIBILITY
990typename enable_if<is_integral<_A1>::value, double>::type
991acosh(_A1 __x) {return acosh((double)__x);}
992
993// asinh
994
995using ::asinh;
996using ::asinhf;
997
998inline _LIBCPP_INLINE_VISIBILITY float asinh(float __x) {return asinhf(__x);}
999inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __x) {return asinhl(__x);}
1000
1001template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001002_LIBCPP_INLINE_VISIBILITY
1003typename enable_if<is_integral<_A1>::value, double>::type
1004asinh(_A1 __x) {return asinh((double)__x);}
1005
1006// atanh
1007
1008using ::atanh;
1009using ::atanhf;
1010
1011inline _LIBCPP_INLINE_VISIBILITY float atanh(float __x) {return atanhf(__x);}
1012inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __x) {return atanhl(__x);}
1013
1014template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001015_LIBCPP_INLINE_VISIBILITY
1016typename enable_if<is_integral<_A1>::value, double>::type
1017atanh(_A1 __x) {return atanh((double)__x);}
1018
1019// cbrt
1020
1021using ::cbrt;
1022using ::cbrtf;
1023
1024inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __x) {return cbrtf(__x);}
1025inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __x) {return cbrtl(__x);}
1026
1027template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001028_LIBCPP_INLINE_VISIBILITY
1029typename enable_if<is_integral<_A1>::value, double>::type
1030cbrt(_A1 __x) {return cbrt((double)__x);}
1031
1032// copysign
1033
1034using ::copysign;
1035using ::copysignf;
1036
1037inline _LIBCPP_INLINE_VISIBILITY float copysign(float __x, float __y) {return copysignf(__x, __y);}
1038inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __x, long double __y) {return copysignl(__x, __y);}
1039
1040template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001041_LIBCPP_INLINE_VISIBILITY
1042typename enable_if
1043<
1044 is_arithmetic<_A1>::value &&
1045 is_arithmetic<_A2>::value,
1046 typename __promote<_A1, _A2>::type
1047>::type
1048copysign(_A1 __x, _A2 __y)
1049{
1050 typedef typename __promote<_A1, _A2>::type __result_type;
1051 static_assert((!(is_same<_A1, __result_type>::value &&
1052 is_same<_A2, __result_type>::value)), "");
1053 return copysign((__result_type)__x, (__result_type)__y);
1054}
1055
1056// erf
1057
1058using ::erf;
1059using ::erff;
1060
1061inline _LIBCPP_INLINE_VISIBILITY float erf(float __x) {return erff(__x);}
1062inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __x) {return erfl(__x);}
1063
1064template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001065_LIBCPP_INLINE_VISIBILITY
1066typename enable_if<is_integral<_A1>::value, double>::type
1067erf(_A1 __x) {return erf((double)__x);}
1068
1069// erfc
1070
1071using ::erfc;
1072using ::erfcf;
1073
1074inline _LIBCPP_INLINE_VISIBILITY float erfc(float __x) {return erfcf(__x);}
1075inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __x) {return erfcl(__x);}
1076
1077template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001078_LIBCPP_INLINE_VISIBILITY
1079typename enable_if<is_integral<_A1>::value, double>::type
1080erfc(_A1 __x) {return erfc((double)__x);}
1081
1082// exp2
1083
1084using ::exp2;
1085using ::exp2f;
1086
1087inline _LIBCPP_INLINE_VISIBILITY float exp2(float __x) {return exp2f(__x);}
1088inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __x) {return exp2l(__x);}
1089
1090template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001091_LIBCPP_INLINE_VISIBILITY
1092typename enable_if<is_integral<_A1>::value, double>::type
1093exp2(_A1 __x) {return exp2((double)__x);}
1094
1095// expm1
1096
1097using ::expm1;
1098using ::expm1f;
1099
1100inline _LIBCPP_INLINE_VISIBILITY float expm1(float __x) {return expm1f(__x);}
1101inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __x) {return expm1l(__x);}
1102
1103template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001104_LIBCPP_INLINE_VISIBILITY
1105typename enable_if<is_integral<_A1>::value, double>::type
1106expm1(_A1 __x) {return expm1((double)__x);}
1107
1108// fdim
1109
1110using ::fdim;
1111using ::fdimf;
1112
1113inline _LIBCPP_INLINE_VISIBILITY float fdim(float __x, float __y) {return fdimf(__x, __y);}
1114inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __x, long double __y) {return fdiml(__x, __y);}
1115
1116template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001117_LIBCPP_INLINE_VISIBILITY
1118typename enable_if
1119<
1120 is_arithmetic<_A1>::value &&
1121 is_arithmetic<_A2>::value,
1122 typename __promote<_A1, _A2>::type
1123>::type
1124fdim(_A1 __x, _A2 __y)
1125{
1126 typedef typename __promote<_A1, _A2>::type __result_type;
1127 static_assert((!(is_same<_A1, __result_type>::value &&
1128 is_same<_A2, __result_type>::value)), "");
1129 return fdim((__result_type)__x, (__result_type)__y);
1130}
1131
1132// fma
1133
1134inline _LIBCPP_INLINE_VISIBILITY float fmaf(float __x, float __y, float __z) {return (float)((double)__x*__y + __z);}
1135#define FP_FAST_FMAF
1136
1137//#if (defined(__ppc__) || defined(__ppc64__))
1138//inline _LIBCPP_INLINE_VISIBILITY double fma(register double __x, register double __y, register double __z) {asm {fmadd __x, __x, __y, __z} return __x;}
1139//#define FP_FAST_FMA
1140//#else
1141using ::fma;
1142//#endif
1143
1144inline _LIBCPP_INLINE_VISIBILITY float fma(float __x, float __y, float __z) {return fmaf(__x, __y, __z);}
1145inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __x, long double __y, long double __z) {return fmal(__x, __y, __z);}
1146
1147template <class _A1, class _A2, class _A3>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001148_LIBCPP_INLINE_VISIBILITY
1149typename enable_if
1150<
1151 is_arithmetic<_A1>::value &&
1152 is_arithmetic<_A2>::value &&
1153 is_arithmetic<_A3>::value,
1154 typename __promote<_A1, _A2, _A3>::type
1155>::type
1156fma(_A1 __x, _A2 __y, _A3 __z)
1157{
1158 typedef typename __promote<_A1, _A2, _A3>::type __result_type;
1159 static_assert((!(is_same<_A1, __result_type>::value &&
1160 is_same<_A2, __result_type>::value &&
1161 is_same<_A3, __result_type>::value)), "");
1162 return fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
1163}
1164
1165// fmax
1166
1167using ::fmax;
1168using ::fmaxf;
1169
1170inline _LIBCPP_INLINE_VISIBILITY float fmax(float __x, float __y) {return fmaxf(__x, __y);}
1171inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __x, long double __y) {return fmaxl(__x, __y);}
1172
1173template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001174_LIBCPP_INLINE_VISIBILITY
1175typename enable_if
1176<
1177 is_arithmetic<_A1>::value &&
1178 is_arithmetic<_A2>::value,
1179 typename __promote<_A1, _A2>::type
1180>::type
1181fmax(_A1 __x, _A2 __y)
1182{
1183 typedef typename __promote<_A1, _A2>::type __result_type;
1184 static_assert((!(is_same<_A1, __result_type>::value &&
1185 is_same<_A2, __result_type>::value)), "");
1186 return fmax((__result_type)__x, (__result_type)__y);
1187}
1188
1189// fmin
1190
1191using ::fmin;
1192using ::fminf;
1193
1194inline _LIBCPP_INLINE_VISIBILITY float fmin(float __x, float __y) {return fminf(__x, __y);}
1195inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __x, long double __y) {return fminl(__x, __y);}
1196
1197template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001198_LIBCPP_INLINE_VISIBILITY
1199typename enable_if
1200<
1201 is_arithmetic<_A1>::value &&
1202 is_arithmetic<_A2>::value,
1203 typename __promote<_A1, _A2>::type
1204>::type
1205fmin(_A1 __x, _A2 __y)
1206{
1207 typedef typename __promote<_A1, _A2>::type __result_type;
1208 static_assert((!(is_same<_A1, __result_type>::value &&
1209 is_same<_A2, __result_type>::value)), "");
1210 return fmin((__result_type)__x, (__result_type)__y);
1211}
1212
1213// hypot
1214
1215using ::hypot;
1216using ::hypotf;
1217
1218inline _LIBCPP_INLINE_VISIBILITY float hypot(float __x, float __y) {return hypotf(__x, __y);}
1219inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __x, long double __y) {return hypotl(__x, __y);}
1220
1221template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001222_LIBCPP_INLINE_VISIBILITY
1223typename enable_if
1224<
1225 is_arithmetic<_A1>::value &&
1226 is_arithmetic<_A2>::value,
1227 typename __promote<_A1, _A2>::type
1228>::type
1229hypot(_A1 __x, _A2 __y)
1230{
1231 typedef typename __promote<_A1, _A2>::type __result_type;
1232 static_assert((!(is_same<_A1, __result_type>::value &&
1233 is_same<_A2, __result_type>::value)), "");
1234 return hypot((__result_type)__x, (__result_type)__y);
1235}
1236
1237// ilogb
1238
1239using ::ilogb;
1240using ::ilogbf;
1241
1242inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __x) {return ilogbf(__x);}
1243inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __x) {return ilogbl(__x);}
1244
1245template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001246_LIBCPP_INLINE_VISIBILITY
1247typename enable_if<is_integral<_A1>::value, int>::type
1248ilogb(_A1 __x) {return ilogb((double)__x);}
1249
1250// lgamma
1251
1252using ::lgamma;
1253using ::lgammaf;
1254
1255inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __x) {return lgammaf(__x);}
1256inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __x) {return lgammal(__x);}
1257
1258template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001259_LIBCPP_INLINE_VISIBILITY
1260typename enable_if<is_integral<_A1>::value, double>::type
1261lgamma(_A1 __x) {return lgamma((double)__x);}
1262
1263// llrint
1264
1265using ::llrint;
1266using ::llrintf;
1267
1268inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __x) {return llrintf(__x);}
1269inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __x) {return llrintl(__x);}
1270
1271template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001272_LIBCPP_INLINE_VISIBILITY
1273typename enable_if<is_integral<_A1>::value, long long>::type
1274llrint(_A1 __x) {return llrint((double)__x);}
1275
1276// llround
1277
1278using ::llround;
1279using ::llroundf;
1280
1281inline _LIBCPP_INLINE_VISIBILITY long long llround(float __x) {return llroundf(__x);}
1282inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __x) {return llroundl(__x);}
1283
1284template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001285_LIBCPP_INLINE_VISIBILITY
1286typename enable_if<is_integral<_A1>::value, long long>::type
1287llround(_A1 __x) {return llround((double)__x);}
1288
1289// log1p
1290
1291using ::log1p;
1292using ::log1pf;
1293
1294inline _LIBCPP_INLINE_VISIBILITY float log1p(float __x) {return log1pf(__x);}
1295inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __x) {return log1pl(__x);}
1296
1297template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001298_LIBCPP_INLINE_VISIBILITY
1299typename enable_if<is_integral<_A1>::value, double>::type
1300log1p(_A1 __x) {return log1p((double)__x);}
1301
1302// log2
1303
1304using ::log2;
1305using ::log2f;
1306
1307inline _LIBCPP_INLINE_VISIBILITY float log2(float __x) {return log2f(__x);}
1308inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __x) {return log2l(__x);}
1309
1310template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001311_LIBCPP_INLINE_VISIBILITY
1312typename enable_if<is_integral<_A1>::value, double>::type
1313log2(_A1 __x) {return log2((double)__x);}
1314
1315// logb
1316
1317using ::logb;
1318using ::logbf;
1319
1320inline _LIBCPP_INLINE_VISIBILITY float logb(float __x) {return logbf(__x);}
1321inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __x) {return logbl(__x);}
1322
1323template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001324_LIBCPP_INLINE_VISIBILITY
1325typename enable_if<is_integral<_A1>::value, double>::type
1326logb(_A1 __x) {return logb((double)__x);}
1327
1328// lrint
1329
1330using ::lrint;
1331using ::lrintf;
1332
1333inline _LIBCPP_INLINE_VISIBILITY long lrint(float __x) {return lrintf(__x);}
1334inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __x) {return lrintl(__x);}
1335
1336template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001337_LIBCPP_INLINE_VISIBILITY
1338typename enable_if<is_integral<_A1>::value, long>::type
1339lrint(_A1 __x) {return lrint((double)__x);}
1340
1341// lround
1342
1343using ::lround;
1344using ::lroundf;
1345
1346inline _LIBCPP_INLINE_VISIBILITY long lround(float __x) {return lroundf(__x);}
1347inline _LIBCPP_INLINE_VISIBILITY long lround(long double __x) {return lroundl(__x);}
1348
1349template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001350_LIBCPP_INLINE_VISIBILITY
1351typename enable_if<is_integral<_A1>::value, long>::type
1352lround(_A1 __x) {return lround((double)__x);}
1353
1354// nan
1355
1356using ::nan;
1357using ::nanf;
1358
1359// nearbyint
1360
1361using ::nearbyint;
1362using ::nearbyintf;
1363
1364inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __x) {return nearbyintf(__x);}
1365inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __x) {return nearbyintl(__x);}
1366
1367template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001368_LIBCPP_INLINE_VISIBILITY
1369typename enable_if<is_integral<_A1>::value, double>::type
1370nearbyint(_A1 __x) {return nearbyint((double)__x);}
1371
1372// nextafter
1373
1374using ::nextafter;
1375using ::nextafterf;
1376
1377inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __x, float __y) {return nextafterf(__x, __y);}
1378inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __x, long double __y) {return nextafterl(__x, __y);}
1379
1380template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001381_LIBCPP_INLINE_VISIBILITY
1382typename enable_if
1383<
1384 is_arithmetic<_A1>::value &&
1385 is_arithmetic<_A2>::value,
1386 typename __promote<_A1, _A2>::type
1387>::type
1388nextafter(_A1 __x, _A2 __y)
1389{
1390 typedef typename __promote<_A1, _A2>::type __result_type;
1391 static_assert((!(is_same<_A1, __result_type>::value &&
1392 is_same<_A2, __result_type>::value)), "");
1393 return nextafter((__result_type)__x, (__result_type)__y);
1394}
1395
1396// nexttoward
1397
1398using ::nexttoward;
1399using ::nexttowardf;
1400
1401inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __x, long double __y) {return nexttowardf(__x, __y);}
1402inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __x, long double __y) {return nexttowardl(__x, __y);}
1403
1404template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001405_LIBCPP_INLINE_VISIBILITY
1406typename enable_if<is_integral<_A1>::value, double>::type
1407nexttoward(_A1 __x, long double __y) {return nexttoward((double)__x, __y);}
1408
1409// remainder
1410
1411using ::remainder;
1412using ::remainderf;
1413
1414inline _LIBCPP_INLINE_VISIBILITY float remainder(float __x, float __y) {return remainderf(__x, __y);}
1415inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __x, long double __y) {return remainderl(__x, __y);}
1416
1417template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001418_LIBCPP_INLINE_VISIBILITY
1419typename enable_if
1420<
1421 is_arithmetic<_A1>::value &&
1422 is_arithmetic<_A2>::value,
1423 typename __promote<_A1, _A2>::type
1424>::type
1425remainder(_A1 __x, _A2 __y)
1426{
1427 typedef typename __promote<_A1, _A2>::type __result_type;
1428 static_assert((!(is_same<_A1, __result_type>::value &&
1429 is_same<_A2, __result_type>::value)), "");
1430 return remainder((__result_type)__x, (__result_type)__y);
1431}
1432
1433// remquo
1434
1435using ::remquo;
1436using ::remquof;
1437
1438inline _LIBCPP_INLINE_VISIBILITY float remquo(float __x, float __y, int* __z) {return remquof(__x, __y, __z);}
1439inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __x, long double __y, int* __z) {return remquol(__x, __y, __z);}
1440
1441template <class _A1, class _A2>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001442_LIBCPP_INLINE_VISIBILITY
1443typename enable_if
1444<
1445 is_arithmetic<_A1>::value &&
1446 is_arithmetic<_A2>::value,
1447 typename __promote<_A1, _A2>::type
1448>::type
1449remquo(_A1 __x, _A2 __y, int* __z)
1450{
1451 typedef typename __promote<_A1, _A2>::type __result_type;
1452 static_assert((!(is_same<_A1, __result_type>::value &&
1453 is_same<_A2, __result_type>::value)), "");
1454 return remquo((__result_type)__x, (__result_type)__y, __z);
1455}
1456
1457// rint
1458
1459using ::rint;
1460using ::rintf;
1461
1462inline _LIBCPP_INLINE_VISIBILITY float rint(float __x) {return rintf(__x);}
1463inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __x) {return rintl(__x);}
1464
1465template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001466_LIBCPP_INLINE_VISIBILITY
1467typename enable_if<is_integral<_A1>::value, double>::type
1468rint(_A1 __x) {return rint((double)__x);}
1469
1470// round
1471
1472using ::round;
1473using ::roundf;
1474
1475inline _LIBCPP_INLINE_VISIBILITY float round(float __x) {return roundf(__x);}
1476inline _LIBCPP_INLINE_VISIBILITY long double round(long double __x) {return roundl(__x);}
1477
1478template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001479_LIBCPP_INLINE_VISIBILITY
1480typename enable_if<is_integral<_A1>::value, double>::type
1481round(_A1 __x) {return round((double)__x);}
1482
1483// scalbln
1484
1485using ::scalbln;
1486using ::scalblnf;
1487
1488inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __x, long __y) {return scalblnf(__x, __y);}
1489inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __x, long __y) {return scalblnl(__x, __y);}
1490
1491template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001492_LIBCPP_INLINE_VISIBILITY
1493typename enable_if<is_integral<_A1>::value, double>::type
1494scalbln(_A1 __x, long __y) {return scalbln((double)__x, __y);}
1495
1496// scalbn
1497
1498using ::scalbn;
1499using ::scalbnf;
1500
1501inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __x, int __y) {return scalbnf(__x, __y);}
1502inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __x, int __y) {return scalbnl(__x, __y);}
1503
1504template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001505_LIBCPP_INLINE_VISIBILITY
1506typename enable_if<is_integral<_A1>::value, double>::type
1507scalbn(_A1 __x, int __y) {return scalbn((double)__x, __y);}
1508
1509// tgamma
1510
1511using ::tgamma;
1512using ::tgammaf;
1513
1514inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __x) {return tgammaf(__x);}
1515inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __x) {return tgammal(__x);}
1516
1517template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001518_LIBCPP_INLINE_VISIBILITY
1519typename enable_if<is_integral<_A1>::value, double>::type
1520tgamma(_A1 __x) {return tgamma((double)__x);}
1521
1522// trunc
1523
1524using ::trunc;
1525using ::truncf;
1526
1527inline _LIBCPP_INLINE_VISIBILITY float trunc(float __x) {return truncf(__x);}
1528inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __x) {return truncl(__x);}
1529
1530template <class _A1>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001531_LIBCPP_INLINE_VISIBILITY
1532typename enable_if<is_integral<_A1>::value, double>::type
1533trunc(_A1 __x) {return trunc((double)__x);}
1534
1535using ::acosl;
1536using ::asinl;
1537using ::atanl;
1538using ::atan2l;
1539using ::ceill;
1540using ::cosl;
1541using ::coshl;
1542using ::expl;
1543using ::fabsl;
1544using ::floorl;
1545using ::fmodl;
1546using ::frexpl;
1547using ::ldexpl;
1548using ::logl;
1549using ::log10l;
1550using ::modfl;
1551using ::powl;
1552using ::sinl;
1553using ::sinhl;
1554using ::sqrtl;
1555using ::tanl;
1556using ::tanhl;
1557using ::acoshl;
1558using ::asinhl;
1559using ::atanhl;
1560using ::cbrtl;
1561using ::copysignl;
1562using ::erfl;
1563using ::erfcl;
1564using ::exp2l;
1565using ::expm1l;
1566using ::fdiml;
1567using ::fmal;
1568using ::fmaxl;
1569using ::fminl;
1570using ::hypotl;
1571using ::ilogbl;
1572using ::lgammal;
1573using ::llrintl;
1574using ::llroundl;
1575using ::log1pl;
1576using ::log2l;
1577using ::logbl;
1578using ::lrintl;
1579using ::lroundl;
1580using ::nanl;
1581using ::nearbyintl;
1582using ::nextafterl;
1583using ::nexttowardl;
1584using ::remainderl;
1585using ::remquol;
1586using ::rintl;
1587using ::roundl;
1588using ::scalblnl;
1589using ::scalbnl;
1590using ::tgammal;
1591using ::truncl;
1592
1593_LIBCPP_END_NAMESPACE_STD
1594
Howard Hinnant60a0a8e2010-08-10 20:48:29 +00001595// FIXME: work around for Clang with -std=C++0x on OSX/iOS
1596#if defined(__clang__) && defined(__APPLE__)
1597# pragma pop_macro("__STRICT_ANSI__")
1598#endif
1599
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001600#endif // _LIBCPP_CMATH