blob: 4d92841e988f59bbaac6e77f608b926da343a4bb [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
300#include <__config>
301#include <math.h>
302#include <type_traits>
303
304#pragma GCC system_header
305
306_LIBCPP_BEGIN_NAMESPACE_STD
307
308using ::float_t;
309using ::double_t;
310
311// abs
312
313template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000314inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000315typename enable_if<is_floating_point<_A1>::value, _A1>::type
316abs(_A1 __x) {return fabs(__x);}
317
318// acos
319
320using ::acos;
321using ::acosf;
322
323inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) {return acosf(__x);}
324inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) {return acosl(__x);}
325
326template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000327inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000328typename enable_if<is_integral<_A1>::value, double>::type
329acos(_A1 __x) {return acos((double)__x);}
330
331// asin
332
333using ::asin;
334using ::asinf;
335
336inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) {return asinf(__x);}
337inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) {return asinl(__x);}
338
339template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000340inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000341typename enable_if<is_integral<_A1>::value, double>::type
342asin(_A1 __x) {return asin((double)__x);}
343
344// atan
345
346using ::atan;
347using ::atanf;
348
349inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) {return atanf(__x);}
350inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) {return atanl(__x);}
351
352template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000353inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000354typename enable_if<is_integral<_A1>::value, double>::type
355atan(_A1 __x) {return atan((double)__x);}
356
357// atan2
358
359using ::atan2;
360using ::atan2f;
361
362inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) {return atan2f(__y, __x);}
363inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) {return atan2l(__y, __x);}
364
365template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000366inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000367typename enable_if
368<
369 is_arithmetic<_A1>::value &&
370 is_arithmetic<_A2>::value,
371 typename __promote<_A1, _A2>::type
372>::type
373atan2(_A1 __y, _A2 __x)
374{
375 typedef typename __promote<_A1, _A2>::type __result_type;
376 static_assert((!(is_same<_A1, __result_type>::value &&
377 is_same<_A2, __result_type>::value)), "");
378 return atan2((__result_type)__y, (__result_type)__x);
379}
380
381// ceil
382
383using ::ceil;
384using ::ceilf;
385
386inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) {return ceilf(__x);}
387inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) {return ceill(__x);}
388
389template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000390inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000391typename enable_if<is_integral<_A1>::value, double>::type
392ceil(_A1 __x) {return ceil((double)__x);}
393
394// cos
395
396using ::cos;
397using ::cosf;
398
399inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) {return cosf(__x);}
400inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) {return cosl(__x);}
401
402template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000403inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000404typename enable_if<is_integral<_A1>::value, double>::type
405cos(_A1 __x) {return cos((double)__x);}
406
407// cosh
408
409using ::cosh;
410using ::coshf;
411
412inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) {return coshf(__x);}
413inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) {return coshl(__x);}
414
415template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000416inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000417typename enable_if<is_integral<_A1>::value, double>::type
418cosh(_A1 __x) {return cosh((double)__x);}
419
420// exp
421
422using ::exp;
423using ::expf;
424
425inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) {return expf(__x);}
426inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) {return expl(__x);}
427
428template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000429inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000430typename enable_if<is_integral<_A1>::value, double>::type
431exp(_A1 __x) {return exp((double)__x);}
432
433// fabs
434
435using ::fabs;
436using ::fabsf;
437
438inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) {return fabsf(__x);}
439inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) {return fabsl(__x);}
440
441template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000442inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000443typename enable_if<is_integral<_A1>::value, double>::type
444fabs(_A1 __x) {return fabs((double)__x);}
445
446// floor
447
448using ::floor;
449using ::floorf;
450
451inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) {return floorf(__x);}
452inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) {return floorl(__x);}
453
454template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000455inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000456typename enable_if<is_integral<_A1>::value, double>::type
457floor(_A1 __x) {return floor((double)__x);}
458
459// fmod
460
461using ::fmod;
462using ::fmodf;
463
464inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) {return fmodf(__x, __y);}
465inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) {return fmodl(__x, __y);}
466
467template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000468inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000469typename enable_if
470<
471 is_arithmetic<_A1>::value &&
472 is_arithmetic<_A2>::value,
473 typename __promote<_A1, _A2>::type
474>::type
475fmod(_A1 __x, _A2 __y)
476{
477 typedef typename __promote<_A1, _A2>::type __result_type;
478 static_assert((!(is_same<_A1, __result_type>::value &&
479 is_same<_A2, __result_type>::value)), "");
480 return fmod((__result_type)__x, (__result_type)__y);
481}
482
483// frexp
484
485using ::frexp;
486using ::frexpf;
487
488inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) {return frexpf(__x, __e);}
489inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) {return frexpl(__x, __e);}
490
491template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000492inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000493typename enable_if<is_integral<_A1>::value, double>::type
494frexp(_A1 __x, int* __e) {return frexp((double)__x, __e);}
495
496// ldexp
497
498using ::ldexp;
499using ::ldexpf;
500
501inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) {return ldexpf(__x, __e);}
502inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) {return ldexpl(__x, __e);}
503
504template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000505inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000506typename enable_if<is_integral<_A1>::value, double>::type
507ldexp(_A1 __x, int __e) {return ldexp((double)__x, __e);}
508
509// log
510
511using ::log;
512using ::logf;
513
514inline _LIBCPP_INLINE_VISIBILITY float log(float __x) {return logf(__x);}
515inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) {return logl(__x);}
516
517template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000518inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000519typename enable_if<is_integral<_A1>::value, double>::type
520log(_A1 __x) {return log((double)__x);}
521
522// log10
523
524using ::log10;
525using ::log10f;
526
527inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) {return log10f(__x);}
528inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) {return log10l(__x);}
529
530template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000531inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000532typename enable_if<is_integral<_A1>::value, double>::type
533log10(_A1 __x) {return log10((double)__x);}
534
535// modf
536
537using ::modf;
538using ::modff;
539
540inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) {return modff(__x, __y);}
541inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) {return modfl(__x, __y);}
542
543// pow
544
545using ::pow;
546using ::powf;
547
548inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) {return powf(__x, __y);}
549inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) {return powl(__x, __y);}
550
551template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000552inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000553typename enable_if
554<
555 is_arithmetic<_A1>::value &&
556 is_arithmetic<_A2>::value,
557 typename __promote<_A1, _A2>::type
558>::type
559pow(_A1 __x, _A2 __y)
560{
561 typedef typename __promote<_A1, _A2>::type __result_type;
562 static_assert((!(is_same<_A1, __result_type>::value &&
563 is_same<_A2, __result_type>::value)), "");
564 return pow((__result_type)__x, (__result_type)__y);
565}
566
567// sin
568
569using ::sin;
570using ::sinf;
571
572inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) {return sinf(__x);}
573inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) {return sinl(__x);}
574
575template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000576inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000577typename enable_if<is_integral<_A1>::value, double>::type
578sin(_A1 __x) {return sin((double)__x);}
579
580// sinh
581
582using ::sinh;
583using ::sinhf;
584
585inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) {return sinhf(__x);}
586inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) {return sinhl(__x);}
587
588template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000589inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000590typename enable_if<is_integral<_A1>::value, double>::type
591sinh(_A1 __x) {return sinh((double)__x);}
592
593// sqrt
594
595using ::sqrt;
596using ::sqrtf;
597
598inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) {return sqrtf(__x);}
599inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) {return sqrtl(__x);}
600
601template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000602inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000603typename enable_if<is_integral<_A1>::value, double>::type
604sqrt(_A1 __x) {return sqrt((double)__x);}
605
606// tan
607
608using ::tan;
609using ::tanf;
610
611inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) {return tanf(__x);}
612inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) {return tanl(__x);}
613
614template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000615inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000616typename enable_if<is_integral<_A1>::value, double>::type
617tan(_A1 __x) {return tan((double)__x);}
618
619// tanh
620
621using ::tanh;
622using ::tanhf;
623
624inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) {return tanhf(__x);}
625inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) {return tanhl(__x);}
626
627template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000628inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000629typename enable_if<is_integral<_A1>::value, double>::type
630tanh(_A1 __x) {return tanh((double)__x);}
631
632// signbit
633
634#ifndef signbit
635#error Implementation error: signbit not defined
636#else
637
638template <class _A1>
639_LIBCPP_ALWAYS_INLINE
640bool
641__libcpp_signbit(_A1 __x)
642{
643 return signbit(__x);
644}
645
646#undef signbit
647
648template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000649inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000650typename enable_if<is_floating_point<_A1>::value, bool>::type
651signbit(_A1 __x)
652{
653 return __libcpp_signbit(__x);
654}
655
656#endif // signbit
657
658// fpclassify
659
660#ifndef fpclassify
661#error Implementation error: fpclassify not defined
662#else
663
664template <class _A1>
665_LIBCPP_ALWAYS_INLINE
666int
667__libcpp_fpclassify(_A1 __x)
668{
669 return fpclassify(__x);
670}
671
672#undef fpclassify
673
674template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000675inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000676typename enable_if<is_floating_point<_A1>::value, int>::type
677fpclassify(_A1 __x)
678{
679 return __libcpp_fpclassify(__x);
680}
681
682#endif // fpclassify
683
684// isfinite
685
686#ifndef isfinite
687#error Implementation error: isfinite not defined
688#else
689
690template <class _A1>
691_LIBCPP_ALWAYS_INLINE
692bool
693__libcpp_isfinite(_A1 __x)
694{
695 return isfinite(__x);
696}
697
698#undef isfinite
699
700template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000701inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000702typename enable_if<is_floating_point<_A1>::value, bool>::type
703isfinite(_A1 __x)
704{
705 return __libcpp_isfinite(__x);
706}
707
708#endif // isfinite
709
710// isinf
711
712#ifndef isinf
713#error Implementation error: isinf not defined
714#else
715
716template <class _A1>
717_LIBCPP_ALWAYS_INLINE
718bool
719__libcpp_isinf(_A1 __x)
720{
721 return isinf(__x);
722}
723
724#undef isinf
725
726template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000727inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000728typename enable_if<is_floating_point<_A1>::value, bool>::type
729isinf(_A1 __x)
730{
731 return __libcpp_isinf(__x);
732}
733
734#endif // isinf
735
736// isnan
737
738#ifndef isnan
739#error Implementation error: isnan not defined
740#else
741
742template <class _A1>
743_LIBCPP_ALWAYS_INLINE
744bool
745__libcpp_isnan(_A1 __x)
746{
747 return isnan(__x);
748}
749
750#undef isnan
751
752template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000753inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000754typename enable_if<is_floating_point<_A1>::value, bool>::type
755isnan(_A1 __x)
756{
757 return __libcpp_isnan(__x);
758}
759
760#endif // isnan
761
762// isnormal
763
764#ifndef isnormal
765#error Implementation error: isnormal not defined
766#else
767
768template <class _A1>
769_LIBCPP_ALWAYS_INLINE
770bool
771__libcpp_isnormal(_A1 __x)
772{
773 return isnormal(__x);
774}
775
776#undef isnormal
777
778template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000779inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000780typename enable_if<is_floating_point<_A1>::value, bool>::type
781isnormal(_A1 __x)
782{
783 return __libcpp_isnormal(__x);
784}
785
786#endif // isnormal
787
788// isgreater
789
790#ifndef isgreater
791#error Implementation error: isgreater not defined
792#else
793
794template <class _A1, class _A2>
795_LIBCPP_ALWAYS_INLINE
796bool
797__libcpp_isgreater(_A1 __x, _A2 __y)
798{
799 return isgreater(__x, __y);
800}
801
802#undef isgreater
803
804template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000805inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000806typename enable_if
807<
808 is_floating_point<_A1>::value &&
809 is_floating_point<_A2>::value,
810 bool
811>::type
812isgreater(_A1 __x, _A2 __y)
813{
814 return __libcpp_isgreater(__x, __y);
815}
816
817#endif // isgreater
818
819// isgreaterequal
820
821#ifndef isgreaterequal
822#error Implementation error: isgreaterequal not defined
823#else
824
825template <class _A1, class _A2>
826_LIBCPP_ALWAYS_INLINE
827bool
828__libcpp_isgreaterequal(_A1 __x, _A2 __y)
829{
830 return isgreaterequal(__x, __y);
831}
832
833#undef isgreaterequal
834
835template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000836inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000837typename enable_if
838<
839 is_floating_point<_A1>::value &&
840 is_floating_point<_A2>::value,
841 bool
842>::type
843isgreaterequal(_A1 __x, _A2 __y)
844{
845 return __libcpp_isgreaterequal(__x, __y);
846}
847
848#endif // isgreaterequal
849
850// isless
851
852#ifndef isless
853#error Implementation error: isless not defined
854#else
855
856template <class _A1, class _A2>
857_LIBCPP_ALWAYS_INLINE
858bool
859__libcpp_isless(_A1 __x, _A2 __y)
860{
861 return isless(__x, __y);
862}
863
864#undef isless
865
866template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000867inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000868typename enable_if
869<
870 is_floating_point<_A1>::value &&
871 is_floating_point<_A2>::value,
872 bool
873>::type
874isless(_A1 __x, _A2 __y)
875{
876 return __libcpp_isless(__x, __y);
877}
878
879#endif // isless
880
881// islessequal
882
883#ifndef islessequal
884#error Implementation error: islessequal not defined
885#else
886
887template <class _A1, class _A2>
888_LIBCPP_ALWAYS_INLINE
889bool
890__libcpp_islessequal(_A1 __x, _A2 __y)
891{
892 return islessequal(__x, __y);
893}
894
895#undef islessequal
896
897template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000898inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000899typename enable_if
900<
901 is_floating_point<_A1>::value &&
902 is_floating_point<_A2>::value,
903 bool
904>::type
905islessequal(_A1 __x, _A2 __y)
906{
907 return __libcpp_islessequal(__x, __y);
908}
909
910#endif // islessequal
911
912// islessgreater
913
914#ifndef islessgreater
915#error Implementation error: islessgreater not defined
916#else
917
918template <class _A1, class _A2>
919_LIBCPP_ALWAYS_INLINE
920bool
921__libcpp_islessgreater(_A1 __x, _A2 __y)
922{
923 return islessgreater(__x, __y);
924}
925
926#undef islessgreater
927
928template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000929inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000930typename enable_if
931<
932 is_floating_point<_A1>::value &&
933 is_floating_point<_A2>::value,
934 bool
935>::type
936islessgreater(_A1 __x, _A2 __y)
937{
938 return __libcpp_islessgreater(__x, __y);
939}
940
941#endif // islessgreater
942
943// isunordered
944
945#ifndef isunordered
946#error Implementation error: isunordered not defined
947#else
948
949template <class _A1, class _A2>
950_LIBCPP_ALWAYS_INLINE
951bool
952__libcpp_isunordered(_A1 __x, _A2 __y)
953{
954 return isunordered(__x, __y);
955}
956
957#undef isunordered
958
959template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000960inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000961typename enable_if
962<
963 is_floating_point<_A1>::value &&
964 is_floating_point<_A2>::value,
965 bool
966>::type
967isunordered(_A1 __x, _A2 __y)
968{
969 return __libcpp_isunordered(__x, __y);
970}
971
972#endif // isunordered
973
974// acosh
975
976using ::acosh;
977using ::acoshf;
978
979inline _LIBCPP_INLINE_VISIBILITY float acosh(float __x) {return acoshf(__x);}
980inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __x) {return acoshl(__x);}
981
982template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000983inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000984typename enable_if<is_integral<_A1>::value, double>::type
985acosh(_A1 __x) {return acosh((double)__x);}
986
987// asinh
988
989using ::asinh;
990using ::asinhf;
991
992inline _LIBCPP_INLINE_VISIBILITY float asinh(float __x) {return asinhf(__x);}
993inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __x) {return asinhl(__x);}
994
995template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000996inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000997typename enable_if<is_integral<_A1>::value, double>::type
998asinh(_A1 __x) {return asinh((double)__x);}
999
1000// atanh
1001
1002using ::atanh;
1003using ::atanhf;
1004
1005inline _LIBCPP_INLINE_VISIBILITY float atanh(float __x) {return atanhf(__x);}
1006inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __x) {return atanhl(__x);}
1007
1008template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001009inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001010typename enable_if<is_integral<_A1>::value, double>::type
1011atanh(_A1 __x) {return atanh((double)__x);}
1012
1013// cbrt
1014
1015using ::cbrt;
1016using ::cbrtf;
1017
1018inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __x) {return cbrtf(__x);}
1019inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __x) {return cbrtl(__x);}
1020
1021template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001022inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001023typename enable_if<is_integral<_A1>::value, double>::type
1024cbrt(_A1 __x) {return cbrt((double)__x);}
1025
1026// copysign
1027
1028using ::copysign;
1029using ::copysignf;
1030
1031inline _LIBCPP_INLINE_VISIBILITY float copysign(float __x, float __y) {return copysignf(__x, __y);}
1032inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __x, long double __y) {return copysignl(__x, __y);}
1033
1034template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001035inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001036typename enable_if
1037<
1038 is_arithmetic<_A1>::value &&
1039 is_arithmetic<_A2>::value,
1040 typename __promote<_A1, _A2>::type
1041>::type
1042copysign(_A1 __x, _A2 __y)
1043{
1044 typedef typename __promote<_A1, _A2>::type __result_type;
1045 static_assert((!(is_same<_A1, __result_type>::value &&
1046 is_same<_A2, __result_type>::value)), "");
1047 return copysign((__result_type)__x, (__result_type)__y);
1048}
1049
1050// erf
1051
1052using ::erf;
1053using ::erff;
1054
1055inline _LIBCPP_INLINE_VISIBILITY float erf(float __x) {return erff(__x);}
1056inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __x) {return erfl(__x);}
1057
1058template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001059inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001060typename enable_if<is_integral<_A1>::value, double>::type
1061erf(_A1 __x) {return erf((double)__x);}
1062
1063// erfc
1064
1065using ::erfc;
1066using ::erfcf;
1067
1068inline _LIBCPP_INLINE_VISIBILITY float erfc(float __x) {return erfcf(__x);}
1069inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __x) {return erfcl(__x);}
1070
1071template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001072inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001073typename enable_if<is_integral<_A1>::value, double>::type
1074erfc(_A1 __x) {return erfc((double)__x);}
1075
1076// exp2
1077
1078using ::exp2;
1079using ::exp2f;
1080
1081inline _LIBCPP_INLINE_VISIBILITY float exp2(float __x) {return exp2f(__x);}
1082inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __x) {return exp2l(__x);}
1083
1084template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001085inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001086typename enable_if<is_integral<_A1>::value, double>::type
1087exp2(_A1 __x) {return exp2((double)__x);}
1088
1089// expm1
1090
1091using ::expm1;
1092using ::expm1f;
1093
1094inline _LIBCPP_INLINE_VISIBILITY float expm1(float __x) {return expm1f(__x);}
1095inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __x) {return expm1l(__x);}
1096
1097template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001098inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001099typename enable_if<is_integral<_A1>::value, double>::type
1100expm1(_A1 __x) {return expm1((double)__x);}
1101
1102// fdim
1103
1104using ::fdim;
1105using ::fdimf;
1106
1107inline _LIBCPP_INLINE_VISIBILITY float fdim(float __x, float __y) {return fdimf(__x, __y);}
1108inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __x, long double __y) {return fdiml(__x, __y);}
1109
1110template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001111inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001112typename enable_if
1113<
1114 is_arithmetic<_A1>::value &&
1115 is_arithmetic<_A2>::value,
1116 typename __promote<_A1, _A2>::type
1117>::type
1118fdim(_A1 __x, _A2 __y)
1119{
1120 typedef typename __promote<_A1, _A2>::type __result_type;
1121 static_assert((!(is_same<_A1, __result_type>::value &&
1122 is_same<_A2, __result_type>::value)), "");
1123 return fdim((__result_type)__x, (__result_type)__y);
1124}
1125
1126// fma
1127
1128inline _LIBCPP_INLINE_VISIBILITY float fmaf(float __x, float __y, float __z) {return (float)((double)__x*__y + __z);}
1129#define FP_FAST_FMAF
1130
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001131using ::fma;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001132
1133inline _LIBCPP_INLINE_VISIBILITY float fma(float __x, float __y, float __z) {return fmaf(__x, __y, __z);}
1134inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __x, long double __y, long double __z) {return fmal(__x, __y, __z);}
1135
1136template <class _A1, class _A2, class _A3>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001137inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001138typename enable_if
1139<
1140 is_arithmetic<_A1>::value &&
1141 is_arithmetic<_A2>::value &&
1142 is_arithmetic<_A3>::value,
1143 typename __promote<_A1, _A2, _A3>::type
1144>::type
1145fma(_A1 __x, _A2 __y, _A3 __z)
1146{
1147 typedef typename __promote<_A1, _A2, _A3>::type __result_type;
1148 static_assert((!(is_same<_A1, __result_type>::value &&
1149 is_same<_A2, __result_type>::value &&
1150 is_same<_A3, __result_type>::value)), "");
1151 return fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
1152}
1153
1154// fmax
1155
1156using ::fmax;
1157using ::fmaxf;
1158
1159inline _LIBCPP_INLINE_VISIBILITY float fmax(float __x, float __y) {return fmaxf(__x, __y);}
1160inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __x, long double __y) {return fmaxl(__x, __y);}
1161
1162template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001163inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001164typename enable_if
1165<
1166 is_arithmetic<_A1>::value &&
1167 is_arithmetic<_A2>::value,
1168 typename __promote<_A1, _A2>::type
1169>::type
1170fmax(_A1 __x, _A2 __y)
1171{
1172 typedef typename __promote<_A1, _A2>::type __result_type;
1173 static_assert((!(is_same<_A1, __result_type>::value &&
1174 is_same<_A2, __result_type>::value)), "");
1175 return fmax((__result_type)__x, (__result_type)__y);
1176}
1177
1178// fmin
1179
1180using ::fmin;
1181using ::fminf;
1182
1183inline _LIBCPP_INLINE_VISIBILITY float fmin(float __x, float __y) {return fminf(__x, __y);}
1184inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __x, long double __y) {return fminl(__x, __y);}
1185
1186template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001187inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001188typename enable_if
1189<
1190 is_arithmetic<_A1>::value &&
1191 is_arithmetic<_A2>::value,
1192 typename __promote<_A1, _A2>::type
1193>::type
1194fmin(_A1 __x, _A2 __y)
1195{
1196 typedef typename __promote<_A1, _A2>::type __result_type;
1197 static_assert((!(is_same<_A1, __result_type>::value &&
1198 is_same<_A2, __result_type>::value)), "");
1199 return fmin((__result_type)__x, (__result_type)__y);
1200}
1201
1202// hypot
1203
1204using ::hypot;
1205using ::hypotf;
1206
1207inline _LIBCPP_INLINE_VISIBILITY float hypot(float __x, float __y) {return hypotf(__x, __y);}
1208inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __x, long double __y) {return hypotl(__x, __y);}
1209
1210template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001211inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001212typename enable_if
1213<
1214 is_arithmetic<_A1>::value &&
1215 is_arithmetic<_A2>::value,
1216 typename __promote<_A1, _A2>::type
1217>::type
1218hypot(_A1 __x, _A2 __y)
1219{
1220 typedef typename __promote<_A1, _A2>::type __result_type;
1221 static_assert((!(is_same<_A1, __result_type>::value &&
1222 is_same<_A2, __result_type>::value)), "");
1223 return hypot((__result_type)__x, (__result_type)__y);
1224}
1225
1226// ilogb
1227
1228using ::ilogb;
1229using ::ilogbf;
1230
1231inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __x) {return ilogbf(__x);}
1232inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __x) {return ilogbl(__x);}
1233
1234template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001235inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001236typename enable_if<is_integral<_A1>::value, int>::type
1237ilogb(_A1 __x) {return ilogb((double)__x);}
1238
1239// lgamma
1240
1241using ::lgamma;
1242using ::lgammaf;
1243
1244inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __x) {return lgammaf(__x);}
1245inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __x) {return lgammal(__x);}
1246
1247template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001248inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001249typename enable_if<is_integral<_A1>::value, double>::type
1250lgamma(_A1 __x) {return lgamma((double)__x);}
1251
1252// llrint
1253
1254using ::llrint;
1255using ::llrintf;
1256
1257inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __x) {return llrintf(__x);}
1258inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __x) {return llrintl(__x);}
1259
1260template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001261inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001262typename enable_if<is_integral<_A1>::value, long long>::type
1263llrint(_A1 __x) {return llrint((double)__x);}
1264
1265// llround
1266
1267using ::llround;
1268using ::llroundf;
1269
1270inline _LIBCPP_INLINE_VISIBILITY long long llround(float __x) {return llroundf(__x);}
1271inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __x) {return llroundl(__x);}
1272
1273template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001274inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001275typename enable_if<is_integral<_A1>::value, long long>::type
1276llround(_A1 __x) {return llround((double)__x);}
1277
1278// log1p
1279
1280using ::log1p;
1281using ::log1pf;
1282
1283inline _LIBCPP_INLINE_VISIBILITY float log1p(float __x) {return log1pf(__x);}
1284inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __x) {return log1pl(__x);}
1285
1286template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001287inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001288typename enable_if<is_integral<_A1>::value, double>::type
1289log1p(_A1 __x) {return log1p((double)__x);}
1290
1291// log2
1292
1293using ::log2;
1294using ::log2f;
1295
1296inline _LIBCPP_INLINE_VISIBILITY float log2(float __x) {return log2f(__x);}
1297inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __x) {return log2l(__x);}
1298
1299template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001300inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001301typename enable_if<is_integral<_A1>::value, double>::type
1302log2(_A1 __x) {return log2((double)__x);}
1303
1304// logb
1305
1306using ::logb;
1307using ::logbf;
1308
1309inline _LIBCPP_INLINE_VISIBILITY float logb(float __x) {return logbf(__x);}
1310inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __x) {return logbl(__x);}
1311
1312template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001313inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001314typename enable_if<is_integral<_A1>::value, double>::type
1315logb(_A1 __x) {return logb((double)__x);}
1316
1317// lrint
1318
1319using ::lrint;
1320using ::lrintf;
1321
1322inline _LIBCPP_INLINE_VISIBILITY long lrint(float __x) {return lrintf(__x);}
1323inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __x) {return lrintl(__x);}
1324
1325template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001326inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001327typename enable_if<is_integral<_A1>::value, long>::type
1328lrint(_A1 __x) {return lrint((double)__x);}
1329
1330// lround
1331
1332using ::lround;
1333using ::lroundf;
1334
1335inline _LIBCPP_INLINE_VISIBILITY long lround(float __x) {return lroundf(__x);}
1336inline _LIBCPP_INLINE_VISIBILITY long lround(long double __x) {return lroundl(__x);}
1337
1338template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001339inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001340typename enable_if<is_integral<_A1>::value, long>::type
1341lround(_A1 __x) {return lround((double)__x);}
1342
1343// nan
1344
1345using ::nan;
1346using ::nanf;
1347
1348// nearbyint
1349
1350using ::nearbyint;
1351using ::nearbyintf;
1352
1353inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __x) {return nearbyintf(__x);}
1354inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __x) {return nearbyintl(__x);}
1355
1356template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001357inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001358typename enable_if<is_integral<_A1>::value, double>::type
1359nearbyint(_A1 __x) {return nearbyint((double)__x);}
1360
1361// nextafter
1362
1363using ::nextafter;
1364using ::nextafterf;
1365
1366inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __x, float __y) {return nextafterf(__x, __y);}
1367inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __x, long double __y) {return nextafterl(__x, __y);}
1368
1369template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001370inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001371typename enable_if
1372<
1373 is_arithmetic<_A1>::value &&
1374 is_arithmetic<_A2>::value,
1375 typename __promote<_A1, _A2>::type
1376>::type
1377nextafter(_A1 __x, _A2 __y)
1378{
1379 typedef typename __promote<_A1, _A2>::type __result_type;
1380 static_assert((!(is_same<_A1, __result_type>::value &&
1381 is_same<_A2, __result_type>::value)), "");
1382 return nextafter((__result_type)__x, (__result_type)__y);
1383}
1384
1385// nexttoward
1386
1387using ::nexttoward;
1388using ::nexttowardf;
1389
1390inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __x, long double __y) {return nexttowardf(__x, __y);}
1391inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __x, long double __y) {return nexttowardl(__x, __y);}
1392
1393template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001394inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001395typename enable_if<is_integral<_A1>::value, double>::type
1396nexttoward(_A1 __x, long double __y) {return nexttoward((double)__x, __y);}
1397
1398// remainder
1399
1400using ::remainder;
1401using ::remainderf;
1402
1403inline _LIBCPP_INLINE_VISIBILITY float remainder(float __x, float __y) {return remainderf(__x, __y);}
1404inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __x, long double __y) {return remainderl(__x, __y);}
1405
1406template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001407inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001408typename enable_if
1409<
1410 is_arithmetic<_A1>::value &&
1411 is_arithmetic<_A2>::value,
1412 typename __promote<_A1, _A2>::type
1413>::type
1414remainder(_A1 __x, _A2 __y)
1415{
1416 typedef typename __promote<_A1, _A2>::type __result_type;
1417 static_assert((!(is_same<_A1, __result_type>::value &&
1418 is_same<_A2, __result_type>::value)), "");
1419 return remainder((__result_type)__x, (__result_type)__y);
1420}
1421
1422// remquo
1423
1424using ::remquo;
1425using ::remquof;
1426
1427inline _LIBCPP_INLINE_VISIBILITY float remquo(float __x, float __y, int* __z) {return remquof(__x, __y, __z);}
1428inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __x, long double __y, int* __z) {return remquol(__x, __y, __z);}
1429
1430template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001431inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001432typename enable_if
1433<
1434 is_arithmetic<_A1>::value &&
1435 is_arithmetic<_A2>::value,
1436 typename __promote<_A1, _A2>::type
1437>::type
1438remquo(_A1 __x, _A2 __y, int* __z)
1439{
1440 typedef typename __promote<_A1, _A2>::type __result_type;
1441 static_assert((!(is_same<_A1, __result_type>::value &&
1442 is_same<_A2, __result_type>::value)), "");
1443 return remquo((__result_type)__x, (__result_type)__y, __z);
1444}
1445
1446// rint
1447
1448using ::rint;
1449using ::rintf;
1450
1451inline _LIBCPP_INLINE_VISIBILITY float rint(float __x) {return rintf(__x);}
1452inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __x) {return rintl(__x);}
1453
1454template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001455inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001456typename enable_if<is_integral<_A1>::value, double>::type
1457rint(_A1 __x) {return rint((double)__x);}
1458
1459// round
1460
1461using ::round;
1462using ::roundf;
1463
1464inline _LIBCPP_INLINE_VISIBILITY float round(float __x) {return roundf(__x);}
1465inline _LIBCPP_INLINE_VISIBILITY long double round(long double __x) {return roundl(__x);}
1466
1467template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001468inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001469typename enable_if<is_integral<_A1>::value, double>::type
1470round(_A1 __x) {return round((double)__x);}
1471
1472// scalbln
1473
1474using ::scalbln;
1475using ::scalblnf;
1476
1477inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __x, long __y) {return scalblnf(__x, __y);}
1478inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __x, long __y) {return scalblnl(__x, __y);}
1479
1480template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001481inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001482typename enable_if<is_integral<_A1>::value, double>::type
1483scalbln(_A1 __x, long __y) {return scalbln((double)__x, __y);}
1484
1485// scalbn
1486
1487using ::scalbn;
1488using ::scalbnf;
1489
1490inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __x, int __y) {return scalbnf(__x, __y);}
1491inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __x, int __y) {return scalbnl(__x, __y);}
1492
1493template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001494inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001495typename enable_if<is_integral<_A1>::value, double>::type
1496scalbn(_A1 __x, int __y) {return scalbn((double)__x, __y);}
1497
1498// tgamma
1499
1500using ::tgamma;
1501using ::tgammaf;
1502
1503inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __x) {return tgammaf(__x);}
1504inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __x) {return tgammal(__x);}
1505
1506template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001507inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001508typename enable_if<is_integral<_A1>::value, double>::type
1509tgamma(_A1 __x) {return tgamma((double)__x);}
1510
1511// trunc
1512
1513using ::trunc;
1514using ::truncf;
1515
1516inline _LIBCPP_INLINE_VISIBILITY float trunc(float __x) {return truncf(__x);}
1517inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __x) {return truncl(__x);}
1518
1519template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001520inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001521typename enable_if<is_integral<_A1>::value, double>::type
1522trunc(_A1 __x) {return trunc((double)__x);}
1523
1524using ::acosl;
1525using ::asinl;
1526using ::atanl;
1527using ::atan2l;
1528using ::ceill;
1529using ::cosl;
1530using ::coshl;
1531using ::expl;
1532using ::fabsl;
1533using ::floorl;
1534using ::fmodl;
1535using ::frexpl;
1536using ::ldexpl;
1537using ::logl;
1538using ::log10l;
1539using ::modfl;
1540using ::powl;
1541using ::sinl;
1542using ::sinhl;
1543using ::sqrtl;
1544using ::tanl;
1545using ::tanhl;
1546using ::acoshl;
1547using ::asinhl;
1548using ::atanhl;
1549using ::cbrtl;
1550using ::copysignl;
1551using ::erfl;
1552using ::erfcl;
1553using ::exp2l;
1554using ::expm1l;
1555using ::fdiml;
1556using ::fmal;
1557using ::fmaxl;
1558using ::fminl;
1559using ::hypotl;
1560using ::ilogbl;
1561using ::lgammal;
1562using ::llrintl;
1563using ::llroundl;
1564using ::log1pl;
1565using ::log2l;
1566using ::logbl;
1567using ::lrintl;
1568using ::lroundl;
1569using ::nanl;
1570using ::nearbyintl;
1571using ::nextafterl;
1572using ::nexttowardl;
1573using ::remainderl;
1574using ::remquol;
1575using ::rintl;
1576using ::roundl;
1577using ::scalblnl;
1578using ::scalbnl;
1579using ::tgammal;
1580using ::truncl;
1581
1582_LIBCPP_END_NAMESPACE_STD
1583
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001584#endif // _LIBCPP_CMATH