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