blob: f8bc0dfc66a7f846e5cf3b7bf17141ce386e1798 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- cmath -----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_CMATH
12#define _LIBCPP_CMATH
13
14/*
15 cmath synopsis
16
17Macros:
18
19 HUGE_VAL
20 HUGE_VALF // C99
21 HUGE_VALL // C99
22 INFINITY // C99
23 NAN // C99
24 FP_INFINITE // C99
25 FP_NAN // C99
26 FP_NORMAL // C99
27 FP_SUBNORMAL // C99
28 FP_ZERO // C99
29 FP_FAST_FMA // C99
30 FP_FAST_FMAF // C99
31 FP_FAST_FMAL // C99
32 FP_ILOGB0 // C99
33 FP_ILOGBNAN // C99
34 MATH_ERRNO // C99
35 MATH_ERREXCEPT // C99
36 math_errhandling // C99
37
38namespace std
39{
40
41Types:
42
43 float_t // C99
44 double_t // C99
45
46// C90
47
48floating_point abs(floating_point x);
49
50floating_point acos (arithmetic x);
51float acosf(float x);
52long double acosl(long double x);
53
54floating_point asin (arithmetic x);
55float asinf(float x);
56long double asinl(long double x);
57
58floating_point atan (arithmetic x);
59float atanf(float x);
60long double atanl(long double x);
61
62floating_point atan2 (arithmetic y, arithmetic x);
63float atan2f(float y, float x);
64long double atan2l(long double y, long double x);
65
66floating_point ceil (arithmetic x);
67float ceilf(float x);
68long double ceill(long double x);
69
70floating_point cos (arithmetic x);
71float cosf(float x);
72long double cosl(long double x);
73
74floating_point cosh (arithmetic x);
75float coshf(float x);
76long double coshl(long double x);
77
78floating_point exp (arithmetic x);
79float expf(float x);
80long double expl(long double x);
81
82floating_point fabs (arithmetic x);
83float fabsf(float x);
84long double fabsl(long double x);
85
86floating_point floor (arithmetic x);
87float floorf(float x);
88long double floorl(long double x);
89
90floating_point fmod (arithmetic x, arithmetic y);
91float fmodf(float x, float y);
92long double fmodl(long double x, long double y);
93
94floating_point frexp (arithmetic value, int* exp);
95float frexpf(float value, int* exp);
96long double frexpl(long double value, int* exp);
97
98floating_point ldexp (arithmetic value, int exp);
99float ldexpf(float value, int exp);
100long double ldexpl(long double value, int exp);
101
102floating_point log (arithmetic x);
103float logf(float x);
104long double logl(long double x);
105
106floating_point log10 (arithmetic x);
107float log10f(float x);
108long double log10l(long double x);
109
110floating_point modf (floating_point value, floating_point* iptr);
111float modff(float value, float* iptr);
112long double modfl(long double value, long double* iptr);
113
114floating_point pow (arithmetic x, arithmetic y);
115float powf(float x, float y);
116long double powl(long double x, long double y);
117
118floating_point sin (arithmetic x);
119float sinf(float x);
120long double sinl(long double x);
121
122floating_point sinh (arithmetic x);
123float sinhf(float x);
124long double sinhl(long double x);
125
126floating_point sqrt (arithmetic x);
127float sqrtf(float x);
128long double sqrtl(long double x);
129
130floating_point tan (arithmetic x);
131float tanf(float x);
132long double tanl(long double x);
133
134floating_point tanh (arithmetic x);
135float tanhf(float x);
136long double tanhl(long double x);
137
138// C99
139
140bool signbit(floating_point x);
141
142int fpclassify(floating_point x);
143
Howard Hinnant324bb032010-08-22 00:02:43 +0000144bool isfinite(floating_point x);
145bool isinf(floating_point x);
146bool isnan(floating_point x);
147bool isnormal(floating_point x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000148
Howard Hinnant324bb032010-08-22 00:02:43 +0000149bool isgreater(floating_point x, floating_point y);
150bool isgreaterequal(floating_point x, floating_point y);
151bool isless(floating_point x, floating_point y);
152bool islessequal(floating_point x, floating_point y);
153bool islessgreater(floating_point x, floating_point y);
154bool isunordered(floating_point x, floating_point y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000155
156floating_point acosh (arithmetic x);
157float acoshf(float x);
158long double acoshl(long double x);
159
160floating_point asinh (arithmetic x);
161float asinhf(float x);
162long double asinhl(long double x);
163
164floating_point atanh (arithmetic x);
165float atanhf(float x);
166long double atanhl(long double x);
167
168floating_point cbrt (arithmetic x);
169float cbrtf(float x);
170long double cbrtl(long double x);
171
172floating_point copysign (arithmetic x, arithmetic y);
173float copysignf(float x, float y);
174long double copysignl(long double x, long double y);
175
176floating_point erf (arithmetic x);
177float erff(float x);
178long double erfl(long double x);
179
180floating_point erfc (arithmetic x);
181float erfcf(float x);
182long double erfcl(long double x);
183
184floating_point exp2 (arithmetic x);
185float exp2f(float x);
186long double exp2l(long double x);
187
188floating_point expm1 (arithmetic x);
189float expm1f(float x);
190long double expm1l(long double x);
191
192floating_point fdim (arithmetic x, arithmetic y);
193float fdimf(float x, float y);
194long double fdiml(long double x, long double y);
195
196floating_point fma (arithmetic x, arithmetic y, arithmetic z);
197float fmaf(float x, float y, float z);
198long double fmal(long double x, long double y, long double z);
199
200floating_point fmax (arithmetic x, arithmetic y);
201float fmaxf(float x, float y);
202long double fmaxl(long double x, long double y);
203
204floating_point fmin (arithmetic x, arithmetic y);
205float fminf(float x, float y);
206long double fminl(long double x, long double y);
207
208floating_point hypot (arithmetic x, arithmetic y);
209float hypotf(float x, float y);
210long double hypotl(long double x, long double y);
211
212int ilogb (arithmetic x);
213int ilogbf(float x);
214int ilogbl(long double x);
215
216floating_point lgamma (arithmetic x);
217float lgammaf(float x);
218long double lgammal(long double x);
219
220long long llrint (arithmetic x);
221long long llrintf(float x);
222long long llrintl(long double x);
223
224long long llround (arithmetic x);
225long long llroundf(float x);
226long long llroundl(long double x);
227
228floating_point log1p (arithmetic x);
229float log1pf(float x);
230long double log1pl(long double x);
231
232floating_point log2 (arithmetic x);
233float log2f(float x);
234long double log2l(long double x);
235
236floating_point logb (arithmetic x);
237float logbf(float x);
238long double logbl(long double x);
239
240long lrint (arithmetic x);
241long lrintf(float x);
242long lrintl(long double x);
243
244long lround (arithmetic x);
245long lroundf(float x);
246long lroundl(long double x);
247
248double nan (const char* str);
249float nanf(const char* str);
250long double nanl(const char* str);
251
252floating_point nearbyint (arithmetic x);
253float nearbyintf(float x);
254long double nearbyintl(long double x);
255
256floating_point nextafter (arithmetic x, arithmetic y);
257float nextafterf(float x, float y);
258long double nextafterl(long double x, long double y);
259
260floating_point nexttoward (arithmetic x, long double y);
261float nexttowardf(float x, long double y);
262long double nexttowardl(long double x, long double y);
263
264floating_point remainder (arithmetic x, arithmetic y);
265float remainderf(float x, float y);
266long double remainderl(long double x, long double y);
267
268floating_point remquo (arithmetic x, arithmetic y, int* pquo);
269float remquof(float x, float y, int* pquo);
270long double remquol(long double x, long double y, int* pquo);
271
272floating_point rint (arithmetic x);
273float rintf(float x);
274long double rintl(long double x);
275
276floating_point round (arithmetic x);
277float roundf(float x);
278long double roundl(long double x);
279
280floating_point scalbln (arithmetic x, long ex);
281float scalblnf(float x, long ex);
282long double scalblnl(long double x, long ex);
283
284floating_point scalbn (arithmetic x, int ex);
285float scalbnf(float x, int ex);
286long double scalbnl(long double x, int ex);
287
288floating_point tgamma (arithmetic x);
289float tgammaf(float x);
290long double tgammal(long double x);
291
292floating_point trunc (arithmetic x);
293float truncf(float x);
294long double truncl(long double x);
295
296} // std
297
298*/
299
300#include <__config>
301#include <math.h>
302#include <type_traits>
303
304#pragma GCC system_header
305
Howard Hinnant0a111112011-05-13 21:52:40 +0000306// signbit
307
308#ifdef signbit
309
310template <class _A1>
311_LIBCPP_ALWAYS_INLINE
312bool
313__libcpp_signbit(_A1 __x)
314{
315 return signbit(__x);
316}
317
318#undef signbit
319
320template <class _A1>
321inline _LIBCPP_INLINE_VISIBILITY
322typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
323signbit(_A1 __x)
324{
325 return __libcpp_signbit(__x);
326}
327
328#endif // signbit
329
330// fpclassify
331
332#ifdef fpclassify
333
334template <class _A1>
335_LIBCPP_ALWAYS_INLINE
336int
337__libcpp_fpclassify(_A1 __x)
338{
339 return fpclassify(__x);
340}
341
342#undef fpclassify
343
344template <class _A1>
345inline _LIBCPP_INLINE_VISIBILITY
346typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
347fpclassify(_A1 __x)
348{
349 return __libcpp_fpclassify(__x);
350}
351
352#endif // fpclassify
353
354// isfinite
355
356#ifdef isfinite
357
358template <class _A1>
359_LIBCPP_ALWAYS_INLINE
360bool
361__libcpp_isfinite(_A1 __x)
362{
363 return isfinite(__x);
364}
365
366#undef isfinite
367
368template <class _A1>
369inline _LIBCPP_INLINE_VISIBILITY
370typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
371isfinite(_A1 __x)
372{
373 return __libcpp_isfinite(__x);
374}
375
376#endif // isfinite
377
378// isinf
379
380#ifdef isinf
381
382template <class _A1>
383_LIBCPP_ALWAYS_INLINE
384bool
385__libcpp_isinf(_A1 __x)
386{
387 return isinf(__x);
388}
389
390#undef isinf
391
392template <class _A1>
393inline _LIBCPP_INLINE_VISIBILITY
394typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
395isinf(_A1 __x)
396{
397 return __libcpp_isinf(__x);
398}
399
400#endif // isinf
401
402// isnan
403
404#ifdef isnan
405
406template <class _A1>
407_LIBCPP_ALWAYS_INLINE
408bool
409__libcpp_isnan(_A1 __x)
410{
411 return isnan(__x);
412}
413
414#undef isnan
415
416template <class _A1>
417inline _LIBCPP_INLINE_VISIBILITY
418typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
419isnan(_A1 __x)
420{
421 return __libcpp_isnan(__x);
422}
423
424#endif // isnan
425
426// isnormal
427
428#ifdef isnormal
429
430template <class _A1>
431_LIBCPP_ALWAYS_INLINE
432bool
433__libcpp_isnormal(_A1 __x)
434{
435 return isnormal(__x);
436}
437
438#undef isnormal
439
440template <class _A1>
441inline _LIBCPP_INLINE_VISIBILITY
442typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
443isnormal(_A1 __x)
444{
445 return __libcpp_isnormal(__x);
446}
447
448#endif // isnormal
449
450// isgreater
451
452#ifdef isgreater
453
454template <class _A1, class _A2>
455_LIBCPP_ALWAYS_INLINE
456bool
457__libcpp_isgreater(_A1 __x, _A2 __y)
458{
459 return isgreater(__x, __y);
460}
461
462#undef isgreater
463
464template <class _A1, class _A2>
465inline _LIBCPP_INLINE_VISIBILITY
466typename std::enable_if
467<
468 std::is_floating_point<_A1>::value &&
469 std::is_floating_point<_A2>::value,
470 bool
471>::type
472isgreater(_A1 __x, _A2 __y)
473{
474 return __libcpp_isgreater(__x, __y);
475}
476
477#endif // isgreater
478
479// isgreaterequal
480
481#ifdef isgreaterequal
482
483template <class _A1, class _A2>
484_LIBCPP_ALWAYS_INLINE
485bool
486__libcpp_isgreaterequal(_A1 __x, _A2 __y)
487{
488 return isgreaterequal(__x, __y);
489}
490
491#undef isgreaterequal
492
493template <class _A1, class _A2>
494inline _LIBCPP_INLINE_VISIBILITY
495typename std::enable_if
496<
497 std::is_floating_point<_A1>::value &&
498 std::is_floating_point<_A2>::value,
499 bool
500>::type
501isgreaterequal(_A1 __x, _A2 __y)
502{
503 return __libcpp_isgreaterequal(__x, __y);
504}
505
506#endif // isgreaterequal
507
508// isless
509
510#ifdef isless
511
512template <class _A1, class _A2>
513_LIBCPP_ALWAYS_INLINE
514bool
515__libcpp_isless(_A1 __x, _A2 __y)
516{
517 return isless(__x, __y);
518}
519
520#undef isless
521
522template <class _A1, class _A2>
523inline _LIBCPP_INLINE_VISIBILITY
524typename std::enable_if
525<
526 std::is_floating_point<_A1>::value &&
527 std::is_floating_point<_A2>::value,
528 bool
529>::type
530isless(_A1 __x, _A2 __y)
531{
532 return __libcpp_isless(__x, __y);
533}
534
535#endif // isless
536
537// islessequal
538
539#ifdef islessequal
540
541template <class _A1, class _A2>
542_LIBCPP_ALWAYS_INLINE
543bool
544__libcpp_islessequal(_A1 __x, _A2 __y)
545{
546 return islessequal(__x, __y);
547}
548
549#undef islessequal
550
551template <class _A1, class _A2>
552inline _LIBCPP_INLINE_VISIBILITY
553typename std::enable_if
554<
555 std::is_floating_point<_A1>::value &&
556 std::is_floating_point<_A2>::value,
557 bool
558>::type
559islessequal(_A1 __x, _A2 __y)
560{
561 return __libcpp_islessequal(__x, __y);
562}
563
564#endif // islessequal
565
566// islessgreater
567
568#ifdef islessgreater
569
570template <class _A1, class _A2>
571_LIBCPP_ALWAYS_INLINE
572bool
573__libcpp_islessgreater(_A1 __x, _A2 __y)
574{
575 return islessgreater(__x, __y);
576}
577
578#undef islessgreater
579
580template <class _A1, class _A2>
581inline _LIBCPP_INLINE_VISIBILITY
582typename std::enable_if
583<
584 std::is_floating_point<_A1>::value &&
585 std::is_floating_point<_A2>::value,
586 bool
587>::type
588islessgreater(_A1 __x, _A2 __y)
589{
590 return __libcpp_islessgreater(__x, __y);
591}
592
593#endif // islessgreater
594
595// isunordered
596
597#ifdef isunordered
598
599template <class _A1, class _A2>
600_LIBCPP_ALWAYS_INLINE
601bool
602__libcpp_isunordered(_A1 __x, _A2 __y)
603{
604 return isunordered(__x, __y);
605}
606
607#undef isunordered
608
609template <class _A1, class _A2>
610inline _LIBCPP_INLINE_VISIBILITY
611typename std::enable_if
612<
613 std::is_floating_point<_A1>::value &&
614 std::is_floating_point<_A2>::value,
615 bool
616>::type
617isunordered(_A1 __x, _A2 __y)
618{
619 return __libcpp_isunordered(__x, __y);
620}
621
622#endif // isunordered
623
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000624_LIBCPP_BEGIN_NAMESPACE_STD
625
Howard Hinnant0a111112011-05-13 21:52:40 +0000626using ::signbit;
627using ::fpclassify;
628using ::isfinite;
629using ::isinf;
630using ::isnan;
631using ::isnormal;
632using ::isgreater;
633using ::isgreaterequal;
634using ::isless;
635using ::islessequal;
636using ::islessgreater;
637using ::isunordered;
638using ::isunordered;
639
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000640using ::float_t;
641using ::double_t;
642
643// abs
644
645template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000646inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000647typename enable_if<is_floating_point<_A1>::value, _A1>::type
648abs(_A1 __x) {return fabs(__x);}
649
650// acos
651
652using ::acos;
653using ::acosf;
654
655inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) {return acosf(__x);}
656inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) {return acosl(__x);}
657
658template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000659inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000660typename enable_if<is_integral<_A1>::value, double>::type
661acos(_A1 __x) {return acos((double)__x);}
662
663// asin
664
665using ::asin;
666using ::asinf;
667
668inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) {return asinf(__x);}
669inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) {return asinl(__x);}
670
671template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000672inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000673typename enable_if<is_integral<_A1>::value, double>::type
674asin(_A1 __x) {return asin((double)__x);}
675
676// atan
677
678using ::atan;
679using ::atanf;
680
681inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) {return atanf(__x);}
682inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) {return atanl(__x);}
683
684template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000685inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000686typename enable_if<is_integral<_A1>::value, double>::type
687atan(_A1 __x) {return atan((double)__x);}
688
689// atan2
690
691using ::atan2;
692using ::atan2f;
693
694inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) {return atan2f(__y, __x);}
695inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) {return atan2l(__y, __x);}
696
697template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000698inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000699typename enable_if
700<
701 is_arithmetic<_A1>::value &&
702 is_arithmetic<_A2>::value,
703 typename __promote<_A1, _A2>::type
704>::type
705atan2(_A1 __y, _A2 __x)
706{
707 typedef typename __promote<_A1, _A2>::type __result_type;
708 static_assert((!(is_same<_A1, __result_type>::value &&
709 is_same<_A2, __result_type>::value)), "");
710 return atan2((__result_type)__y, (__result_type)__x);
711}
712
713// ceil
714
715using ::ceil;
716using ::ceilf;
717
718inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) {return ceilf(__x);}
719inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) {return ceill(__x);}
720
721template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000722inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000723typename enable_if<is_integral<_A1>::value, double>::type
724ceil(_A1 __x) {return ceil((double)__x);}
725
726// cos
727
728using ::cos;
729using ::cosf;
730
731inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) {return cosf(__x);}
732inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) {return cosl(__x);}
733
734template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000735inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000736typename enable_if<is_integral<_A1>::value, double>::type
737cos(_A1 __x) {return cos((double)__x);}
738
739// cosh
740
741using ::cosh;
742using ::coshf;
743
744inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) {return coshf(__x);}
745inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) {return coshl(__x);}
746
747template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000748inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000749typename enable_if<is_integral<_A1>::value, double>::type
750cosh(_A1 __x) {return cosh((double)__x);}
751
752// exp
753
754using ::exp;
755using ::expf;
756
757inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) {return expf(__x);}
758inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) {return expl(__x);}
759
760template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000761inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000762typename enable_if<is_integral<_A1>::value, double>::type
763exp(_A1 __x) {return exp((double)__x);}
764
765// fabs
766
767using ::fabs;
768using ::fabsf;
769
770inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) {return fabsf(__x);}
771inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) {return fabsl(__x);}
772
773template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000774inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000775typename enable_if<is_integral<_A1>::value, double>::type
776fabs(_A1 __x) {return fabs((double)__x);}
777
778// floor
779
780using ::floor;
781using ::floorf;
782
783inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) {return floorf(__x);}
784inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) {return floorl(__x);}
785
786template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000787inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000788typename enable_if<is_integral<_A1>::value, double>::type
789floor(_A1 __x) {return floor((double)__x);}
790
791// fmod
792
793using ::fmod;
794using ::fmodf;
795
796inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) {return fmodf(__x, __y);}
797inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) {return fmodl(__x, __y);}
798
799template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000800inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000801typename enable_if
802<
803 is_arithmetic<_A1>::value &&
804 is_arithmetic<_A2>::value,
805 typename __promote<_A1, _A2>::type
806>::type
807fmod(_A1 __x, _A2 __y)
808{
809 typedef typename __promote<_A1, _A2>::type __result_type;
810 static_assert((!(is_same<_A1, __result_type>::value &&
811 is_same<_A2, __result_type>::value)), "");
812 return fmod((__result_type)__x, (__result_type)__y);
813}
814
815// frexp
816
817using ::frexp;
818using ::frexpf;
819
820inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) {return frexpf(__x, __e);}
821inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) {return frexpl(__x, __e);}
822
823template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000824inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000825typename enable_if<is_integral<_A1>::value, double>::type
826frexp(_A1 __x, int* __e) {return frexp((double)__x, __e);}
827
828// ldexp
829
830using ::ldexp;
831using ::ldexpf;
832
833inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) {return ldexpf(__x, __e);}
834inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) {return ldexpl(__x, __e);}
835
836template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000837inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000838typename enable_if<is_integral<_A1>::value, double>::type
839ldexp(_A1 __x, int __e) {return ldexp((double)__x, __e);}
840
841// log
842
843using ::log;
844using ::logf;
845
846inline _LIBCPP_INLINE_VISIBILITY float log(float __x) {return logf(__x);}
847inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) {return logl(__x);}
848
849template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000850inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000851typename enable_if<is_integral<_A1>::value, double>::type
852log(_A1 __x) {return log((double)__x);}
853
854// log10
855
856using ::log10;
857using ::log10f;
858
859inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) {return log10f(__x);}
860inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) {return log10l(__x);}
861
862template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000863inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000864typename enable_if<is_integral<_A1>::value, double>::type
865log10(_A1 __x) {return log10((double)__x);}
866
867// modf
868
869using ::modf;
870using ::modff;
871
872inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) {return modff(__x, __y);}
873inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) {return modfl(__x, __y);}
874
875// pow
876
877using ::pow;
878using ::powf;
879
880inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) {return powf(__x, __y);}
881inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) {return powl(__x, __y);}
882
883template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000884inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000885typename enable_if
886<
887 is_arithmetic<_A1>::value &&
888 is_arithmetic<_A2>::value,
889 typename __promote<_A1, _A2>::type
890>::type
891pow(_A1 __x, _A2 __y)
892{
893 typedef typename __promote<_A1, _A2>::type __result_type;
894 static_assert((!(is_same<_A1, __result_type>::value &&
895 is_same<_A2, __result_type>::value)), "");
896 return pow((__result_type)__x, (__result_type)__y);
897}
898
899// sin
900
901using ::sin;
902using ::sinf;
903
904inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) {return sinf(__x);}
905inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) {return sinl(__x);}
906
907template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000908inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000909typename enable_if<is_integral<_A1>::value, double>::type
910sin(_A1 __x) {return sin((double)__x);}
911
912// sinh
913
914using ::sinh;
915using ::sinhf;
916
917inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) {return sinhf(__x);}
918inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) {return sinhl(__x);}
919
920template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000921inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000922typename enable_if<is_integral<_A1>::value, double>::type
923sinh(_A1 __x) {return sinh((double)__x);}
924
925// sqrt
926
927using ::sqrt;
928using ::sqrtf;
929
930inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) {return sqrtf(__x);}
931inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) {return sqrtl(__x);}
932
933template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000934inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000935typename enable_if<is_integral<_A1>::value, double>::type
936sqrt(_A1 __x) {return sqrt((double)__x);}
937
938// tan
939
940using ::tan;
941using ::tanf;
942
943inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) {return tanf(__x);}
944inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) {return tanl(__x);}
945
946template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000947inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000948typename enable_if<is_integral<_A1>::value, double>::type
949tan(_A1 __x) {return tan((double)__x);}
950
951// tanh
952
953using ::tanh;
954using ::tanhf;
955
956inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) {return tanhf(__x);}
957inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) {return tanhl(__x);}
958
959template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000960inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000961typename enable_if<is_integral<_A1>::value, double>::type
962tanh(_A1 __x) {return tanh((double)__x);}
963
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000964// acosh
965
966using ::acosh;
967using ::acoshf;
968
969inline _LIBCPP_INLINE_VISIBILITY float acosh(float __x) {return acoshf(__x);}
970inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __x) {return acoshl(__x);}
971
972template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000973inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000974typename enable_if<is_integral<_A1>::value, double>::type
975acosh(_A1 __x) {return acosh((double)__x);}
976
977// asinh
978
979using ::asinh;
980using ::asinhf;
981
982inline _LIBCPP_INLINE_VISIBILITY float asinh(float __x) {return asinhf(__x);}
983inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __x) {return asinhl(__x);}
984
985template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000986inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000987typename enable_if<is_integral<_A1>::value, double>::type
988asinh(_A1 __x) {return asinh((double)__x);}
989
990// atanh
991
992using ::atanh;
993using ::atanhf;
994
995inline _LIBCPP_INLINE_VISIBILITY float atanh(float __x) {return atanhf(__x);}
996inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __x) {return atanhl(__x);}
997
998template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000999inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001000typename enable_if<is_integral<_A1>::value, double>::type
1001atanh(_A1 __x) {return atanh((double)__x);}
1002
1003// cbrt
1004
1005using ::cbrt;
1006using ::cbrtf;
1007
1008inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __x) {return cbrtf(__x);}
1009inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __x) {return cbrtl(__x);}
1010
1011template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001012inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001013typename enable_if<is_integral<_A1>::value, double>::type
1014cbrt(_A1 __x) {return cbrt((double)__x);}
1015
1016// copysign
1017
1018using ::copysign;
1019using ::copysignf;
1020
1021inline _LIBCPP_INLINE_VISIBILITY float copysign(float __x, float __y) {return copysignf(__x, __y);}
1022inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __x, long double __y) {return copysignl(__x, __y);}
1023
1024template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001025inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001026typename enable_if
1027<
1028 is_arithmetic<_A1>::value &&
1029 is_arithmetic<_A2>::value,
1030 typename __promote<_A1, _A2>::type
1031>::type
1032copysign(_A1 __x, _A2 __y)
1033{
1034 typedef typename __promote<_A1, _A2>::type __result_type;
1035 static_assert((!(is_same<_A1, __result_type>::value &&
1036 is_same<_A2, __result_type>::value)), "");
1037 return copysign((__result_type)__x, (__result_type)__y);
1038}
1039
1040// erf
1041
1042using ::erf;
1043using ::erff;
1044
1045inline _LIBCPP_INLINE_VISIBILITY float erf(float __x) {return erff(__x);}
1046inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __x) {return erfl(__x);}
1047
1048template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001049inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001050typename enable_if<is_integral<_A1>::value, double>::type
1051erf(_A1 __x) {return erf((double)__x);}
1052
1053// erfc
1054
1055using ::erfc;
1056using ::erfcf;
1057
1058inline _LIBCPP_INLINE_VISIBILITY float erfc(float __x) {return erfcf(__x);}
1059inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __x) {return erfcl(__x);}
1060
1061template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001062inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001063typename enable_if<is_integral<_A1>::value, double>::type
1064erfc(_A1 __x) {return erfc((double)__x);}
1065
1066// exp2
1067
1068using ::exp2;
1069using ::exp2f;
1070
1071inline _LIBCPP_INLINE_VISIBILITY float exp2(float __x) {return exp2f(__x);}
1072inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __x) {return exp2l(__x);}
1073
1074template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001075inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001076typename enable_if<is_integral<_A1>::value, double>::type
1077exp2(_A1 __x) {return exp2((double)__x);}
1078
1079// expm1
1080
1081using ::expm1;
1082using ::expm1f;
1083
1084inline _LIBCPP_INLINE_VISIBILITY float expm1(float __x) {return expm1f(__x);}
1085inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __x) {return expm1l(__x);}
1086
1087template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001088inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001089typename enable_if<is_integral<_A1>::value, double>::type
1090expm1(_A1 __x) {return expm1((double)__x);}
1091
1092// fdim
1093
1094using ::fdim;
1095using ::fdimf;
1096
1097inline _LIBCPP_INLINE_VISIBILITY float fdim(float __x, float __y) {return fdimf(__x, __y);}
1098inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __x, long double __y) {return fdiml(__x, __y);}
1099
1100template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001101inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001102typename enable_if
1103<
1104 is_arithmetic<_A1>::value &&
1105 is_arithmetic<_A2>::value,
1106 typename __promote<_A1, _A2>::type
1107>::type
1108fdim(_A1 __x, _A2 __y)
1109{
1110 typedef typename __promote<_A1, _A2>::type __result_type;
1111 static_assert((!(is_same<_A1, __result_type>::value &&
1112 is_same<_A2, __result_type>::value)), "");
1113 return fdim((__result_type)__x, (__result_type)__y);
1114}
1115
1116// fma
1117
1118inline _LIBCPP_INLINE_VISIBILITY float fmaf(float __x, float __y, float __z) {return (float)((double)__x*__y + __z);}
1119#define FP_FAST_FMAF
1120
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001121using ::fma;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001122
1123inline _LIBCPP_INLINE_VISIBILITY float fma(float __x, float __y, float __z) {return fmaf(__x, __y, __z);}
1124inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __x, long double __y, long double __z) {return fmal(__x, __y, __z);}
1125
1126template <class _A1, class _A2, class _A3>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001127inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001128typename enable_if
1129<
1130 is_arithmetic<_A1>::value &&
1131 is_arithmetic<_A2>::value &&
1132 is_arithmetic<_A3>::value,
1133 typename __promote<_A1, _A2, _A3>::type
1134>::type
1135fma(_A1 __x, _A2 __y, _A3 __z)
1136{
1137 typedef typename __promote<_A1, _A2, _A3>::type __result_type;
1138 static_assert((!(is_same<_A1, __result_type>::value &&
1139 is_same<_A2, __result_type>::value &&
1140 is_same<_A3, __result_type>::value)), "");
1141 return fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
1142}
1143
1144// fmax
1145
1146using ::fmax;
1147using ::fmaxf;
1148
1149inline _LIBCPP_INLINE_VISIBILITY float fmax(float __x, float __y) {return fmaxf(__x, __y);}
1150inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __x, long double __y) {return fmaxl(__x, __y);}
1151
1152template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001153inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001154typename enable_if
1155<
1156 is_arithmetic<_A1>::value &&
1157 is_arithmetic<_A2>::value,
1158 typename __promote<_A1, _A2>::type
1159>::type
1160fmax(_A1 __x, _A2 __y)
1161{
1162 typedef typename __promote<_A1, _A2>::type __result_type;
1163 static_assert((!(is_same<_A1, __result_type>::value &&
1164 is_same<_A2, __result_type>::value)), "");
1165 return fmax((__result_type)__x, (__result_type)__y);
1166}
1167
1168// fmin
1169
1170using ::fmin;
1171using ::fminf;
1172
1173inline _LIBCPP_INLINE_VISIBILITY float fmin(float __x, float __y) {return fminf(__x, __y);}
1174inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __x, long double __y) {return fminl(__x, __y);}
1175
1176template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001177inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001178typename enable_if
1179<
1180 is_arithmetic<_A1>::value &&
1181 is_arithmetic<_A2>::value,
1182 typename __promote<_A1, _A2>::type
1183>::type
1184fmin(_A1 __x, _A2 __y)
1185{
1186 typedef typename __promote<_A1, _A2>::type __result_type;
1187 static_assert((!(is_same<_A1, __result_type>::value &&
1188 is_same<_A2, __result_type>::value)), "");
1189 return fmin((__result_type)__x, (__result_type)__y);
1190}
1191
1192// hypot
1193
1194using ::hypot;
1195using ::hypotf;
1196
1197inline _LIBCPP_INLINE_VISIBILITY float hypot(float __x, float __y) {return hypotf(__x, __y);}
1198inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __x, long double __y) {return hypotl(__x, __y);}
1199
1200template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001201inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001202typename enable_if
1203<
1204 is_arithmetic<_A1>::value &&
1205 is_arithmetic<_A2>::value,
1206 typename __promote<_A1, _A2>::type
1207>::type
1208hypot(_A1 __x, _A2 __y)
1209{
1210 typedef typename __promote<_A1, _A2>::type __result_type;
1211 static_assert((!(is_same<_A1, __result_type>::value &&
1212 is_same<_A2, __result_type>::value)), "");
1213 return hypot((__result_type)__x, (__result_type)__y);
1214}
1215
1216// ilogb
1217
1218using ::ilogb;
1219using ::ilogbf;
1220
1221inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __x) {return ilogbf(__x);}
1222inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __x) {return ilogbl(__x);}
1223
1224template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001225inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001226typename enable_if<is_integral<_A1>::value, int>::type
1227ilogb(_A1 __x) {return ilogb((double)__x);}
1228
1229// lgamma
1230
1231using ::lgamma;
1232using ::lgammaf;
1233
1234inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __x) {return lgammaf(__x);}
1235inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __x) {return lgammal(__x);}
1236
1237template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001238inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001239typename enable_if<is_integral<_A1>::value, double>::type
1240lgamma(_A1 __x) {return lgamma((double)__x);}
1241
1242// llrint
1243
1244using ::llrint;
1245using ::llrintf;
1246
1247inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __x) {return llrintf(__x);}
1248inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __x) {return llrintl(__x);}
1249
1250template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001251inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001252typename enable_if<is_integral<_A1>::value, long long>::type
1253llrint(_A1 __x) {return llrint((double)__x);}
1254
1255// llround
1256
1257using ::llround;
1258using ::llroundf;
1259
1260inline _LIBCPP_INLINE_VISIBILITY long long llround(float __x) {return llroundf(__x);}
1261inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __x) {return llroundl(__x);}
1262
1263template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001264inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001265typename enable_if<is_integral<_A1>::value, long long>::type
1266llround(_A1 __x) {return llround((double)__x);}
1267
1268// log1p
1269
1270using ::log1p;
1271using ::log1pf;
1272
1273inline _LIBCPP_INLINE_VISIBILITY float log1p(float __x) {return log1pf(__x);}
1274inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __x) {return log1pl(__x);}
1275
1276template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001277inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001278typename enable_if<is_integral<_A1>::value, double>::type
1279log1p(_A1 __x) {return log1p((double)__x);}
1280
1281// log2
1282
1283using ::log2;
1284using ::log2f;
1285
1286inline _LIBCPP_INLINE_VISIBILITY float log2(float __x) {return log2f(__x);}
1287inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __x) {return log2l(__x);}
1288
1289template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001290inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001291typename enable_if<is_integral<_A1>::value, double>::type
1292log2(_A1 __x) {return log2((double)__x);}
1293
1294// logb
1295
1296using ::logb;
1297using ::logbf;
1298
1299inline _LIBCPP_INLINE_VISIBILITY float logb(float __x) {return logbf(__x);}
1300inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __x) {return logbl(__x);}
1301
1302template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001303inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001304typename enable_if<is_integral<_A1>::value, double>::type
1305logb(_A1 __x) {return logb((double)__x);}
1306
1307// lrint
1308
1309using ::lrint;
1310using ::lrintf;
1311
1312inline _LIBCPP_INLINE_VISIBILITY long lrint(float __x) {return lrintf(__x);}
1313inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __x) {return lrintl(__x);}
1314
1315template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001316inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001317typename enable_if<is_integral<_A1>::value, long>::type
1318lrint(_A1 __x) {return lrint((double)__x);}
1319
1320// lround
1321
1322using ::lround;
1323using ::lroundf;
1324
1325inline _LIBCPP_INLINE_VISIBILITY long lround(float __x) {return lroundf(__x);}
1326inline _LIBCPP_INLINE_VISIBILITY long lround(long double __x) {return lroundl(__x);}
1327
1328template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001329inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001330typename enable_if<is_integral<_A1>::value, long>::type
1331lround(_A1 __x) {return lround((double)__x);}
1332
1333// nan
1334
1335using ::nan;
1336using ::nanf;
1337
1338// nearbyint
1339
1340using ::nearbyint;
1341using ::nearbyintf;
1342
1343inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __x) {return nearbyintf(__x);}
1344inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __x) {return nearbyintl(__x);}
1345
1346template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001347inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001348typename enable_if<is_integral<_A1>::value, double>::type
1349nearbyint(_A1 __x) {return nearbyint((double)__x);}
1350
1351// nextafter
1352
1353using ::nextafter;
1354using ::nextafterf;
1355
1356inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __x, float __y) {return nextafterf(__x, __y);}
1357inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __x, long double __y) {return nextafterl(__x, __y);}
1358
1359template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001360inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001361typename enable_if
1362<
1363 is_arithmetic<_A1>::value &&
1364 is_arithmetic<_A2>::value,
1365 typename __promote<_A1, _A2>::type
1366>::type
1367nextafter(_A1 __x, _A2 __y)
1368{
1369 typedef typename __promote<_A1, _A2>::type __result_type;
1370 static_assert((!(is_same<_A1, __result_type>::value &&
1371 is_same<_A2, __result_type>::value)), "");
1372 return nextafter((__result_type)__x, (__result_type)__y);
1373}
1374
1375// nexttoward
1376
1377using ::nexttoward;
1378using ::nexttowardf;
1379
1380inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __x, long double __y) {return nexttowardf(__x, __y);}
1381inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __x, long double __y) {return nexttowardl(__x, __y);}
1382
1383template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001384inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001385typename enable_if<is_integral<_A1>::value, double>::type
1386nexttoward(_A1 __x, long double __y) {return nexttoward((double)__x, __y);}
1387
1388// remainder
1389
1390using ::remainder;
1391using ::remainderf;
1392
1393inline _LIBCPP_INLINE_VISIBILITY float remainder(float __x, float __y) {return remainderf(__x, __y);}
1394inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __x, long double __y) {return remainderl(__x, __y);}
1395
1396template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001397inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001398typename enable_if
1399<
1400 is_arithmetic<_A1>::value &&
1401 is_arithmetic<_A2>::value,
1402 typename __promote<_A1, _A2>::type
1403>::type
1404remainder(_A1 __x, _A2 __y)
1405{
1406 typedef typename __promote<_A1, _A2>::type __result_type;
1407 static_assert((!(is_same<_A1, __result_type>::value &&
1408 is_same<_A2, __result_type>::value)), "");
1409 return remainder((__result_type)__x, (__result_type)__y);
1410}
1411
1412// remquo
1413
1414using ::remquo;
1415using ::remquof;
1416
1417inline _LIBCPP_INLINE_VISIBILITY float remquo(float __x, float __y, int* __z) {return remquof(__x, __y, __z);}
1418inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __x, long double __y, int* __z) {return remquol(__x, __y, __z);}
1419
1420template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001421inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001422typename enable_if
1423<
1424 is_arithmetic<_A1>::value &&
1425 is_arithmetic<_A2>::value,
1426 typename __promote<_A1, _A2>::type
1427>::type
1428remquo(_A1 __x, _A2 __y, int* __z)
1429{
1430 typedef typename __promote<_A1, _A2>::type __result_type;
1431 static_assert((!(is_same<_A1, __result_type>::value &&
1432 is_same<_A2, __result_type>::value)), "");
1433 return remquo((__result_type)__x, (__result_type)__y, __z);
1434}
1435
1436// rint
1437
1438using ::rint;
1439using ::rintf;
1440
1441inline _LIBCPP_INLINE_VISIBILITY float rint(float __x) {return rintf(__x);}
1442inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __x) {return rintl(__x);}
1443
1444template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001445inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001446typename enable_if<is_integral<_A1>::value, double>::type
1447rint(_A1 __x) {return rint((double)__x);}
1448
1449// round
1450
1451using ::round;
1452using ::roundf;
1453
1454inline _LIBCPP_INLINE_VISIBILITY float round(float __x) {return roundf(__x);}
1455inline _LIBCPP_INLINE_VISIBILITY long double round(long double __x) {return roundl(__x);}
1456
1457template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001458inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001459typename enable_if<is_integral<_A1>::value, double>::type
1460round(_A1 __x) {return round((double)__x);}
1461
1462// scalbln
1463
1464using ::scalbln;
1465using ::scalblnf;
1466
1467inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __x, long __y) {return scalblnf(__x, __y);}
1468inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __x, long __y) {return scalblnl(__x, __y);}
1469
1470template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001471inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001472typename enable_if<is_integral<_A1>::value, double>::type
1473scalbln(_A1 __x, long __y) {return scalbln((double)__x, __y);}
1474
1475// scalbn
1476
1477using ::scalbn;
1478using ::scalbnf;
1479
1480inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __x, int __y) {return scalbnf(__x, __y);}
1481inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __x, int __y) {return scalbnl(__x, __y);}
1482
1483template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001484inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001485typename enable_if<is_integral<_A1>::value, double>::type
1486scalbn(_A1 __x, int __y) {return scalbn((double)__x, __y);}
1487
1488// tgamma
1489
1490using ::tgamma;
1491using ::tgammaf;
1492
1493inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __x) {return tgammaf(__x);}
1494inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __x) {return tgammal(__x);}
1495
1496template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001497inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001498typename enable_if<is_integral<_A1>::value, double>::type
1499tgamma(_A1 __x) {return tgamma((double)__x);}
1500
1501// trunc
1502
1503using ::trunc;
1504using ::truncf;
1505
1506inline _LIBCPP_INLINE_VISIBILITY float trunc(float __x) {return truncf(__x);}
1507inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __x) {return truncl(__x);}
1508
1509template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001510inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001511typename enable_if<is_integral<_A1>::value, double>::type
1512trunc(_A1 __x) {return trunc((double)__x);}
1513
1514using ::acosl;
1515using ::asinl;
1516using ::atanl;
1517using ::atan2l;
1518using ::ceill;
1519using ::cosl;
1520using ::coshl;
1521using ::expl;
1522using ::fabsl;
1523using ::floorl;
1524using ::fmodl;
1525using ::frexpl;
1526using ::ldexpl;
1527using ::logl;
1528using ::log10l;
1529using ::modfl;
1530using ::powl;
1531using ::sinl;
1532using ::sinhl;
1533using ::sqrtl;
1534using ::tanl;
1535using ::tanhl;
1536using ::acoshl;
1537using ::asinhl;
1538using ::atanhl;
1539using ::cbrtl;
1540using ::copysignl;
1541using ::erfl;
1542using ::erfcl;
1543using ::exp2l;
1544using ::expm1l;
1545using ::fdiml;
1546using ::fmal;
1547using ::fmaxl;
1548using ::fminl;
1549using ::hypotl;
1550using ::ilogbl;
1551using ::lgammal;
1552using ::llrintl;
1553using ::llroundl;
1554using ::log1pl;
1555using ::log2l;
1556using ::logbl;
1557using ::lrintl;
1558using ::lroundl;
1559using ::nanl;
1560using ::nearbyintl;
1561using ::nextafterl;
1562using ::nexttowardl;
1563using ::remainderl;
1564using ::remquol;
1565using ::rintl;
1566using ::roundl;
1567using ::scalblnl;
1568using ::scalbnl;
1569using ::tgammal;
1570using ::truncl;
1571
1572_LIBCPP_END_NAMESPACE_STD
1573
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001574#endif // _LIBCPP_CMATH