blob: bc3151ba3e03a7e8f39213509293511efba71fef [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- cmath -----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_CMATH
12#define _LIBCPP_CMATH
13
14/*
15 cmath synopsis
16
17Macros:
18
19 HUGE_VAL
20 HUGE_VALF // C99
21 HUGE_VALL // C99
22 INFINITY // C99
23 NAN // C99
24 FP_INFINITE // C99
25 FP_NAN // C99
26 FP_NORMAL // C99
27 FP_SUBNORMAL // C99
28 FP_ZERO // C99
29 FP_FAST_FMA // C99
30 FP_FAST_FMAF // C99
31 FP_FAST_FMAL // C99
32 FP_ILOGB0 // C99
33 FP_ILOGBNAN // C99
34 MATH_ERRNO // C99
35 MATH_ERREXCEPT // C99
36 math_errhandling // C99
37
38namespace std
39{
40
41Types:
42
43 float_t // C99
44 double_t // C99
45
46// C90
47
48floating_point abs(floating_point x);
49
50floating_point acos (arithmetic x);
51float acosf(float x);
52long double acosl(long double x);
53
54floating_point asin (arithmetic x);
55float asinf(float x);
56long double asinl(long double x);
57
58floating_point atan (arithmetic x);
59float atanf(float x);
60long double atanl(long double x);
61
62floating_point atan2 (arithmetic y, arithmetic x);
63float atan2f(float y, float x);
64long double atan2l(long double y, long double x);
65
66floating_point ceil (arithmetic x);
67float ceilf(float x);
68long double ceill(long double x);
69
70floating_point cos (arithmetic x);
71float cosf(float x);
72long double cosl(long double x);
73
74floating_point cosh (arithmetic x);
75float coshf(float x);
76long double coshl(long double x);
77
78floating_point exp (arithmetic x);
79float expf(float x);
80long double expl(long double x);
81
82floating_point fabs (arithmetic x);
83float fabsf(float x);
84long double fabsl(long double x);
85
86floating_point floor (arithmetic x);
87float floorf(float x);
88long double floorl(long double x);
89
90floating_point fmod (arithmetic x, arithmetic y);
91float fmodf(float x, float y);
92long double fmodl(long double x, long double y);
93
94floating_point frexp (arithmetic value, int* exp);
95float frexpf(float value, int* exp);
96long double frexpl(long double value, int* exp);
97
98floating_point ldexp (arithmetic value, int exp);
99float ldexpf(float value, int exp);
100long double ldexpl(long double value, int exp);
101
102floating_point log (arithmetic x);
103float logf(float x);
104long double logl(long double x);
105
106floating_point log10 (arithmetic x);
107float log10f(float x);
108long double log10l(long double x);
109
110floating_point modf (floating_point value, floating_point* iptr);
111float modff(float value, float* iptr);
112long double modfl(long double value, long double* iptr);
113
114floating_point pow (arithmetic x, arithmetic y);
115float powf(float x, float y);
116long double powl(long double x, long double y);
117
118floating_point sin (arithmetic x);
119float sinf(float x);
120long double sinl(long double x);
121
122floating_point sinh (arithmetic x);
123float sinhf(float x);
124long double sinhl(long double x);
125
126floating_point sqrt (arithmetic x);
127float sqrtf(float x);
128long double sqrtl(long double x);
129
130floating_point tan (arithmetic x);
131float tanf(float x);
132long double tanl(long double x);
133
134floating_point tanh (arithmetic x);
135float tanhf(float x);
136long double tanhl(long double x);
137
138// C99
139
140bool signbit(floating_point x);
141
142int fpclassify(floating_point x);
143
Howard Hinnant324bb032010-08-22 00:02:43 +0000144bool isfinite(floating_point x);
145bool isinf(floating_point x);
146bool isnan(floating_point x);
147bool isnormal(floating_point x);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000148
Howard Hinnant324bb032010-08-22 00:02:43 +0000149bool isgreater(floating_point x, floating_point y);
150bool isgreaterequal(floating_point x, floating_point y);
151bool isless(floating_point x, floating_point y);
152bool islessequal(floating_point x, floating_point y);
153bool islessgreater(floating_point x, floating_point y);
154bool isunordered(floating_point x, floating_point y);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000155
156floating_point acosh (arithmetic x);
157float acoshf(float x);
158long double acoshl(long double x);
159
160floating_point asinh (arithmetic x);
161float asinhf(float x);
162long double asinhl(long double x);
163
164floating_point atanh (arithmetic x);
165float atanhf(float x);
166long double atanhl(long double x);
167
168floating_point cbrt (arithmetic x);
169float cbrtf(float x);
170long double cbrtl(long double x);
171
172floating_point copysign (arithmetic x, arithmetic y);
173float copysignf(float x, float y);
174long double copysignl(long double x, long double y);
175
176floating_point erf (arithmetic x);
177float erff(float x);
178long double erfl(long double x);
179
180floating_point erfc (arithmetic x);
181float erfcf(float x);
182long double erfcl(long double x);
183
184floating_point exp2 (arithmetic x);
185float exp2f(float x);
186long double exp2l(long double x);
187
188floating_point expm1 (arithmetic x);
189float expm1f(float x);
190long double expm1l(long double x);
191
192floating_point fdim (arithmetic x, arithmetic y);
193float fdimf(float x, float y);
194long double fdiml(long double x, long double y);
195
196floating_point fma (arithmetic x, arithmetic y, arithmetic z);
197float fmaf(float x, float y, float z);
198long double fmal(long double x, long double y, long double z);
199
200floating_point fmax (arithmetic x, arithmetic y);
201float fmaxf(float x, float y);
202long double fmaxl(long double x, long double y);
203
204floating_point fmin (arithmetic x, arithmetic y);
205float fminf(float x, float y);
206long double fminl(long double x, long double y);
207
208floating_point hypot (arithmetic x, arithmetic y);
209float hypotf(float x, float y);
210long double hypotl(long double x, long double y);
211
212int ilogb (arithmetic x);
213int ilogbf(float x);
214int ilogbl(long double x);
215
216floating_point lgamma (arithmetic x);
217float lgammaf(float x);
218long double lgammal(long double x);
219
220long long llrint (arithmetic x);
221long long llrintf(float x);
222long long llrintl(long double x);
223
224long long llround (arithmetic x);
225long long llroundf(float x);
226long long llroundl(long double x);
227
228floating_point log1p (arithmetic x);
229float log1pf(float x);
230long double log1pl(long double x);
231
232floating_point log2 (arithmetic x);
233float log2f(float x);
234long double log2l(long double x);
235
236floating_point logb (arithmetic x);
237float logbf(float x);
238long double logbl(long double x);
239
240long lrint (arithmetic x);
241long lrintf(float x);
242long lrintl(long double x);
243
244long lround (arithmetic x);
245long lroundf(float x);
246long lroundl(long double x);
247
248double nan (const char* str);
249float nanf(const char* str);
250long double nanl(const char* str);
251
252floating_point nearbyint (arithmetic x);
253float nearbyintf(float x);
254long double nearbyintl(long double x);
255
256floating_point nextafter (arithmetic x, arithmetic y);
257float nextafterf(float x, float y);
258long double nextafterl(long double x, long double y);
259
260floating_point nexttoward (arithmetic x, long double y);
261float nexttowardf(float x, long double y);
262long double nexttowardl(long double x, long double y);
263
264floating_point remainder (arithmetic x, arithmetic y);
265float remainderf(float x, float y);
266long double remainderl(long double x, long double y);
267
268floating_point remquo (arithmetic x, arithmetic y, int* pquo);
269float remquof(float x, float y, int* pquo);
270long double remquol(long double x, long double y, int* pquo);
271
272floating_point rint (arithmetic x);
273float rintf(float x);
274long double rintl(long double x);
275
276floating_point round (arithmetic x);
277float roundf(float x);
278long double roundl(long double x);
279
280floating_point scalbln (arithmetic x, long ex);
281float scalblnf(float x, long ex);
282long double scalblnl(long double x, long ex);
283
284floating_point scalbn (arithmetic x, int ex);
285float scalbnf(float x, int ex);
286long double scalbnl(long double x, int ex);
287
288floating_point tgamma (arithmetic x);
289float tgammaf(float x);
290long double tgammal(long double x);
291
292floating_point trunc (arithmetic x);
293float truncf(float x);
294long double truncl(long double x);
295
296} // std
297
298*/
299
300#include <__config>
301#include <math.h>
302#include <type_traits>
303
Howard Hinnant08e17472011-10-17 20:05:10 +0000304#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000305#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +0000306#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000307
Howard Hinnant0a111112011-05-13 21:52:40 +0000308// signbit
309
310#ifdef signbit
311
312template <class _A1>
313_LIBCPP_ALWAYS_INLINE
314bool
315__libcpp_signbit(_A1 __x)
316{
317 return signbit(__x);
318}
319
320#undef signbit
321
322template <class _A1>
323inline _LIBCPP_INLINE_VISIBILITY
324typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
325signbit(_A1 __x)
326{
327 return __libcpp_signbit(__x);
328}
329
330#endif // signbit
331
332// fpclassify
333
334#ifdef fpclassify
335
336template <class _A1>
337_LIBCPP_ALWAYS_INLINE
338int
339__libcpp_fpclassify(_A1 __x)
340{
341 return fpclassify(__x);
342}
343
344#undef fpclassify
345
346template <class _A1>
347inline _LIBCPP_INLINE_VISIBILITY
348typename std::enable_if<std::is_floating_point<_A1>::value, int>::type
349fpclassify(_A1 __x)
350{
351 return __libcpp_fpclassify(__x);
352}
353
354#endif // fpclassify
355
356// isfinite
357
358#ifdef isfinite
359
360template <class _A1>
361_LIBCPP_ALWAYS_INLINE
362bool
363__libcpp_isfinite(_A1 __x)
364{
365 return isfinite(__x);
366}
367
368#undef isfinite
369
370template <class _A1>
371inline _LIBCPP_INLINE_VISIBILITY
372typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
373isfinite(_A1 __x)
374{
375 return __libcpp_isfinite(__x);
376}
377
378#endif // isfinite
379
380// isinf
381
382#ifdef isinf
383
384template <class _A1>
385_LIBCPP_ALWAYS_INLINE
386bool
387__libcpp_isinf(_A1 __x)
388{
389 return isinf(__x);
390}
391
392#undef isinf
393
394template <class _A1>
395inline _LIBCPP_INLINE_VISIBILITY
396typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
397isinf(_A1 __x)
398{
399 return __libcpp_isinf(__x);
400}
401
402#endif // isinf
403
404// isnan
405
406#ifdef isnan
407
408template <class _A1>
409_LIBCPP_ALWAYS_INLINE
410bool
411__libcpp_isnan(_A1 __x)
412{
413 return isnan(__x);
414}
415
416#undef isnan
417
418template <class _A1>
419inline _LIBCPP_INLINE_VISIBILITY
420typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
421isnan(_A1 __x)
422{
423 return __libcpp_isnan(__x);
424}
425
426#endif // isnan
427
428// isnormal
429
430#ifdef isnormal
431
432template <class _A1>
433_LIBCPP_ALWAYS_INLINE
434bool
435__libcpp_isnormal(_A1 __x)
436{
437 return isnormal(__x);
438}
439
440#undef isnormal
441
442template <class _A1>
443inline _LIBCPP_INLINE_VISIBILITY
444typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type
445isnormal(_A1 __x)
446{
447 return __libcpp_isnormal(__x);
448}
449
450#endif // isnormal
451
452// isgreater
453
454#ifdef isgreater
455
456template <class _A1, class _A2>
457_LIBCPP_ALWAYS_INLINE
458bool
459__libcpp_isgreater(_A1 __x, _A2 __y)
460{
461 return isgreater(__x, __y);
462}
463
464#undef isgreater
465
466template <class _A1, class _A2>
467inline _LIBCPP_INLINE_VISIBILITY
468typename std::enable_if
469<
470 std::is_floating_point<_A1>::value &&
471 std::is_floating_point<_A2>::value,
472 bool
473>::type
474isgreater(_A1 __x, _A2 __y)
475{
476 return __libcpp_isgreater(__x, __y);
477}
478
479#endif // isgreater
480
481// isgreaterequal
482
483#ifdef isgreaterequal
484
485template <class _A1, class _A2>
486_LIBCPP_ALWAYS_INLINE
487bool
488__libcpp_isgreaterequal(_A1 __x, _A2 __y)
489{
490 return isgreaterequal(__x, __y);
491}
492
493#undef isgreaterequal
494
495template <class _A1, class _A2>
496inline _LIBCPP_INLINE_VISIBILITY
497typename std::enable_if
498<
499 std::is_floating_point<_A1>::value &&
500 std::is_floating_point<_A2>::value,
501 bool
502>::type
503isgreaterequal(_A1 __x, _A2 __y)
504{
505 return __libcpp_isgreaterequal(__x, __y);
506}
507
508#endif // isgreaterequal
509
510// isless
511
512#ifdef isless
513
514template <class _A1, class _A2>
515_LIBCPP_ALWAYS_INLINE
516bool
517__libcpp_isless(_A1 __x, _A2 __y)
518{
519 return isless(__x, __y);
520}
521
522#undef isless
523
524template <class _A1, class _A2>
525inline _LIBCPP_INLINE_VISIBILITY
526typename std::enable_if
527<
528 std::is_floating_point<_A1>::value &&
529 std::is_floating_point<_A2>::value,
530 bool
531>::type
532isless(_A1 __x, _A2 __y)
533{
534 return __libcpp_isless(__x, __y);
535}
536
537#endif // isless
538
539// islessequal
540
541#ifdef islessequal
542
543template <class _A1, class _A2>
544_LIBCPP_ALWAYS_INLINE
545bool
546__libcpp_islessequal(_A1 __x, _A2 __y)
547{
548 return islessequal(__x, __y);
549}
550
551#undef islessequal
552
553template <class _A1, class _A2>
554inline _LIBCPP_INLINE_VISIBILITY
555typename std::enable_if
556<
557 std::is_floating_point<_A1>::value &&
558 std::is_floating_point<_A2>::value,
559 bool
560>::type
561islessequal(_A1 __x, _A2 __y)
562{
563 return __libcpp_islessequal(__x, __y);
564}
565
566#endif // islessequal
567
568// islessgreater
569
570#ifdef islessgreater
571
572template <class _A1, class _A2>
573_LIBCPP_ALWAYS_INLINE
574bool
575__libcpp_islessgreater(_A1 __x, _A2 __y)
576{
577 return islessgreater(__x, __y);
578}
579
580#undef islessgreater
581
582template <class _A1, class _A2>
583inline _LIBCPP_INLINE_VISIBILITY
584typename std::enable_if
585<
586 std::is_floating_point<_A1>::value &&
587 std::is_floating_point<_A2>::value,
588 bool
589>::type
590islessgreater(_A1 __x, _A2 __y)
591{
592 return __libcpp_islessgreater(__x, __y);
593}
594
595#endif // islessgreater
596
597// isunordered
598
599#ifdef isunordered
600
601template <class _A1, class _A2>
602_LIBCPP_ALWAYS_INLINE
603bool
604__libcpp_isunordered(_A1 __x, _A2 __y)
605{
606 return isunordered(__x, __y);
607}
608
609#undef isunordered
610
611template <class _A1, class _A2>
612inline _LIBCPP_INLINE_VISIBILITY
613typename std::enable_if
614<
615 std::is_floating_point<_A1>::value &&
616 std::is_floating_point<_A2>::value,
617 bool
618>::type
619isunordered(_A1 __x, _A2 __y)
620{
621 return __libcpp_isunordered(__x, __y);
622}
623
624#endif // isunordered
625
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000626_LIBCPP_BEGIN_NAMESPACE_STD
627
Howard Hinnant0a111112011-05-13 21:52:40 +0000628using ::signbit;
629using ::fpclassify;
630using ::isfinite;
631using ::isinf;
632using ::isnan;
633using ::isnormal;
634using ::isgreater;
635using ::isgreaterequal;
636using ::isless;
637using ::islessequal;
638using ::islessgreater;
639using ::isunordered;
640using ::isunordered;
641
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000642using ::float_t;
643using ::double_t;
644
645// abs
646
647template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000648inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000649typename enable_if<is_floating_point<_A1>::value, _A1>::type
650abs(_A1 __x) {return fabs(__x);}
651
652// acos
653
654using ::acos;
655using ::acosf;
656
657inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) {return acosf(__x);}
658inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) {return acosl(__x);}
659
660template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000661inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000662typename enable_if<is_integral<_A1>::value, double>::type
663acos(_A1 __x) {return acos((double)__x);}
664
665// asin
666
667using ::asin;
668using ::asinf;
669
670inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) {return asinf(__x);}
671inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) {return asinl(__x);}
672
673template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000674inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000675typename enable_if<is_integral<_A1>::value, double>::type
676asin(_A1 __x) {return asin((double)__x);}
677
678// atan
679
680using ::atan;
681using ::atanf;
682
683inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) {return atanf(__x);}
684inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) {return atanl(__x);}
685
686template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000687inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000688typename enable_if<is_integral<_A1>::value, double>::type
689atan(_A1 __x) {return atan((double)__x);}
690
691// atan2
692
693using ::atan2;
694using ::atan2f;
695
696inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) {return atan2f(__y, __x);}
697inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) {return atan2l(__y, __x);}
698
699template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000700inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000701typename enable_if
702<
703 is_arithmetic<_A1>::value &&
704 is_arithmetic<_A2>::value,
705 typename __promote<_A1, _A2>::type
706>::type
707atan2(_A1 __y, _A2 __x)
708{
709 typedef typename __promote<_A1, _A2>::type __result_type;
710 static_assert((!(is_same<_A1, __result_type>::value &&
711 is_same<_A2, __result_type>::value)), "");
712 return atan2((__result_type)__y, (__result_type)__x);
713}
714
715// ceil
716
717using ::ceil;
718using ::ceilf;
719
720inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) {return ceilf(__x);}
721inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) {return ceill(__x);}
722
723template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000724inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000725typename enable_if<is_integral<_A1>::value, double>::type
726ceil(_A1 __x) {return ceil((double)__x);}
727
728// cos
729
730using ::cos;
731using ::cosf;
732
733inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) {return cosf(__x);}
734inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) {return cosl(__x);}
735
736template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000737inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000738typename enable_if<is_integral<_A1>::value, double>::type
739cos(_A1 __x) {return cos((double)__x);}
740
741// cosh
742
743using ::cosh;
744using ::coshf;
745
746inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) {return coshf(__x);}
747inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) {return coshl(__x);}
748
749template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000750inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000751typename enable_if<is_integral<_A1>::value, double>::type
752cosh(_A1 __x) {return cosh((double)__x);}
753
754// exp
755
756using ::exp;
757using ::expf;
758
759inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) {return expf(__x);}
760inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) {return expl(__x);}
761
762template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000763inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000764typename enable_if<is_integral<_A1>::value, double>::type
765exp(_A1 __x) {return exp((double)__x);}
766
767// fabs
768
769using ::fabs;
770using ::fabsf;
771
772inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) {return fabsf(__x);}
773inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) {return fabsl(__x);}
774
775template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000776inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000777typename enable_if<is_integral<_A1>::value, double>::type
778fabs(_A1 __x) {return fabs((double)__x);}
779
780// floor
781
782using ::floor;
783using ::floorf;
784
785inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) {return floorf(__x);}
786inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) {return floorl(__x);}
787
788template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000789inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000790typename enable_if<is_integral<_A1>::value, double>::type
791floor(_A1 __x) {return floor((double)__x);}
792
793// fmod
794
795using ::fmod;
796using ::fmodf;
797
798inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) {return fmodf(__x, __y);}
799inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) {return fmodl(__x, __y);}
800
801template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000802inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000803typename enable_if
804<
805 is_arithmetic<_A1>::value &&
806 is_arithmetic<_A2>::value,
807 typename __promote<_A1, _A2>::type
808>::type
809fmod(_A1 __x, _A2 __y)
810{
811 typedef typename __promote<_A1, _A2>::type __result_type;
812 static_assert((!(is_same<_A1, __result_type>::value &&
813 is_same<_A2, __result_type>::value)), "");
814 return fmod((__result_type)__x, (__result_type)__y);
815}
816
817// frexp
818
819using ::frexp;
820using ::frexpf;
821
822inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) {return frexpf(__x, __e);}
823inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) {return frexpl(__x, __e);}
824
825template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000826inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000827typename enable_if<is_integral<_A1>::value, double>::type
828frexp(_A1 __x, int* __e) {return frexp((double)__x, __e);}
829
830// ldexp
831
832using ::ldexp;
833using ::ldexpf;
834
835inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) {return ldexpf(__x, __e);}
836inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) {return ldexpl(__x, __e);}
837
838template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000839inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000840typename enable_if<is_integral<_A1>::value, double>::type
841ldexp(_A1 __x, int __e) {return ldexp((double)__x, __e);}
842
843// log
844
845using ::log;
846using ::logf;
847
848inline _LIBCPP_INLINE_VISIBILITY float log(float __x) {return logf(__x);}
849inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) {return logl(__x);}
850
851template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000852inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000853typename enable_if<is_integral<_A1>::value, double>::type
854log(_A1 __x) {return log((double)__x);}
855
856// log10
857
858using ::log10;
859using ::log10f;
860
861inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) {return log10f(__x);}
862inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) {return log10l(__x);}
863
864template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000865inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000866typename enable_if<is_integral<_A1>::value, double>::type
867log10(_A1 __x) {return log10((double)__x);}
868
869// modf
870
871using ::modf;
872using ::modff;
873
874inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) {return modff(__x, __y);}
875inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) {return modfl(__x, __y);}
876
877// pow
878
879using ::pow;
880using ::powf;
881
882inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) {return powf(__x, __y);}
883inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) {return powl(__x, __y);}
884
885template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000886inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000887typename enable_if
888<
889 is_arithmetic<_A1>::value &&
890 is_arithmetic<_A2>::value,
891 typename __promote<_A1, _A2>::type
892>::type
893pow(_A1 __x, _A2 __y)
894{
895 typedef typename __promote<_A1, _A2>::type __result_type;
896 static_assert((!(is_same<_A1, __result_type>::value &&
897 is_same<_A2, __result_type>::value)), "");
898 return pow((__result_type)__x, (__result_type)__y);
899}
900
901// sin
902
903using ::sin;
904using ::sinf;
905
906inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) {return sinf(__x);}
907inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) {return sinl(__x);}
908
909template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000910inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000911typename enable_if<is_integral<_A1>::value, double>::type
912sin(_A1 __x) {return sin((double)__x);}
913
914// sinh
915
916using ::sinh;
917using ::sinhf;
918
919inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) {return sinhf(__x);}
920inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) {return sinhl(__x);}
921
922template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000923inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000924typename enable_if<is_integral<_A1>::value, double>::type
925sinh(_A1 __x) {return sinh((double)__x);}
926
927// sqrt
928
929using ::sqrt;
930using ::sqrtf;
931
932inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) {return sqrtf(__x);}
933inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) {return sqrtl(__x);}
934
935template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000936inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000937typename enable_if<is_integral<_A1>::value, double>::type
938sqrt(_A1 __x) {return sqrt((double)__x);}
939
940// tan
941
942using ::tan;
943using ::tanf;
944
945inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) {return tanf(__x);}
946inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) {return tanl(__x);}
947
948template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000949inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000950typename enable_if<is_integral<_A1>::value, double>::type
951tan(_A1 __x) {return tan((double)__x);}
952
953// tanh
954
955using ::tanh;
956using ::tanhf;
957
958inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) {return tanhf(__x);}
959inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) {return tanhl(__x);}
960
961template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000962inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000963typename enable_if<is_integral<_A1>::value, double>::type
964tanh(_A1 __x) {return tanh((double)__x);}
965
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000966// acosh
967
968using ::acosh;
969using ::acoshf;
970
971inline _LIBCPP_INLINE_VISIBILITY float acosh(float __x) {return acoshf(__x);}
972inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __x) {return acoshl(__x);}
973
974template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000975inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000976typename enable_if<is_integral<_A1>::value, double>::type
977acosh(_A1 __x) {return acosh((double)__x);}
978
979// asinh
980
981using ::asinh;
982using ::asinhf;
983
984inline _LIBCPP_INLINE_VISIBILITY float asinh(float __x) {return asinhf(__x);}
985inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __x) {return asinhl(__x);}
986
987template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +0000988inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000989typename enable_if<is_integral<_A1>::value, double>::type
990asinh(_A1 __x) {return asinh((double)__x);}
991
992// atanh
993
994using ::atanh;
995using ::atanhf;
996
997inline _LIBCPP_INLINE_VISIBILITY float atanh(float __x) {return atanhf(__x);}
998inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __x) {return atanhl(__x);}
999
1000template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001001inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001002typename enable_if<is_integral<_A1>::value, double>::type
1003atanh(_A1 __x) {return atanh((double)__x);}
1004
1005// cbrt
1006
1007using ::cbrt;
1008using ::cbrtf;
1009
1010inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __x) {return cbrtf(__x);}
1011inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __x) {return cbrtl(__x);}
1012
1013template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001014inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001015typename enable_if<is_integral<_A1>::value, double>::type
1016cbrt(_A1 __x) {return cbrt((double)__x);}
1017
1018// copysign
1019
1020using ::copysign;
1021using ::copysignf;
1022
1023inline _LIBCPP_INLINE_VISIBILITY float copysign(float __x, float __y) {return copysignf(__x, __y);}
1024inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __x, long double __y) {return copysignl(__x, __y);}
1025
1026template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001027inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001028typename enable_if
1029<
1030 is_arithmetic<_A1>::value &&
1031 is_arithmetic<_A2>::value,
1032 typename __promote<_A1, _A2>::type
1033>::type
1034copysign(_A1 __x, _A2 __y)
1035{
1036 typedef typename __promote<_A1, _A2>::type __result_type;
1037 static_assert((!(is_same<_A1, __result_type>::value &&
1038 is_same<_A2, __result_type>::value)), "");
1039 return copysign((__result_type)__x, (__result_type)__y);
1040}
1041
1042// erf
1043
1044using ::erf;
1045using ::erff;
1046
1047inline _LIBCPP_INLINE_VISIBILITY float erf(float __x) {return erff(__x);}
1048inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __x) {return erfl(__x);}
1049
1050template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001051inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001052typename enable_if<is_integral<_A1>::value, double>::type
1053erf(_A1 __x) {return erf((double)__x);}
1054
1055// erfc
1056
1057using ::erfc;
1058using ::erfcf;
1059
1060inline _LIBCPP_INLINE_VISIBILITY float erfc(float __x) {return erfcf(__x);}
1061inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __x) {return erfcl(__x);}
1062
1063template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001064inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001065typename enable_if<is_integral<_A1>::value, double>::type
1066erfc(_A1 __x) {return erfc((double)__x);}
1067
1068// exp2
1069
1070using ::exp2;
1071using ::exp2f;
1072
1073inline _LIBCPP_INLINE_VISIBILITY float exp2(float __x) {return exp2f(__x);}
1074inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __x) {return exp2l(__x);}
1075
1076template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001077inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001078typename enable_if<is_integral<_A1>::value, double>::type
1079exp2(_A1 __x) {return exp2((double)__x);}
1080
1081// expm1
1082
1083using ::expm1;
1084using ::expm1f;
1085
1086inline _LIBCPP_INLINE_VISIBILITY float expm1(float __x) {return expm1f(__x);}
1087inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __x) {return expm1l(__x);}
1088
1089template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001090inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001091typename enable_if<is_integral<_A1>::value, double>::type
1092expm1(_A1 __x) {return expm1((double)__x);}
1093
1094// fdim
1095
1096using ::fdim;
1097using ::fdimf;
1098
1099inline _LIBCPP_INLINE_VISIBILITY float fdim(float __x, float __y) {return fdimf(__x, __y);}
1100inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __x, long double __y) {return fdiml(__x, __y);}
1101
1102template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001103inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001104typename enable_if
1105<
1106 is_arithmetic<_A1>::value &&
1107 is_arithmetic<_A2>::value,
1108 typename __promote<_A1, _A2>::type
1109>::type
1110fdim(_A1 __x, _A2 __y)
1111{
1112 typedef typename __promote<_A1, _A2>::type __result_type;
1113 static_assert((!(is_same<_A1, __result_type>::value &&
1114 is_same<_A2, __result_type>::value)), "");
1115 return fdim((__result_type)__x, (__result_type)__y);
1116}
1117
1118// fma
1119
1120inline _LIBCPP_INLINE_VISIBILITY float fmaf(float __x, float __y, float __z) {return (float)((double)__x*__y + __z);}
1121#define FP_FAST_FMAF
1122
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001123using ::fma;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001124
1125inline _LIBCPP_INLINE_VISIBILITY float fma(float __x, float __y, float __z) {return fmaf(__x, __y, __z);}
1126inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __x, long double __y, long double __z) {return fmal(__x, __y, __z);}
1127
1128template <class _A1, class _A2, class _A3>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001129inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001130typename enable_if
1131<
1132 is_arithmetic<_A1>::value &&
1133 is_arithmetic<_A2>::value &&
1134 is_arithmetic<_A3>::value,
1135 typename __promote<_A1, _A2, _A3>::type
1136>::type
1137fma(_A1 __x, _A2 __y, _A3 __z)
1138{
1139 typedef typename __promote<_A1, _A2, _A3>::type __result_type;
1140 static_assert((!(is_same<_A1, __result_type>::value &&
1141 is_same<_A2, __result_type>::value &&
1142 is_same<_A3, __result_type>::value)), "");
1143 return fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
1144}
1145
1146// fmax
1147
1148using ::fmax;
1149using ::fmaxf;
1150
1151inline _LIBCPP_INLINE_VISIBILITY float fmax(float __x, float __y) {return fmaxf(__x, __y);}
1152inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __x, long double __y) {return fmaxl(__x, __y);}
1153
1154template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001155inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001156typename enable_if
1157<
1158 is_arithmetic<_A1>::value &&
1159 is_arithmetic<_A2>::value,
1160 typename __promote<_A1, _A2>::type
1161>::type
1162fmax(_A1 __x, _A2 __y)
1163{
1164 typedef typename __promote<_A1, _A2>::type __result_type;
1165 static_assert((!(is_same<_A1, __result_type>::value &&
1166 is_same<_A2, __result_type>::value)), "");
1167 return fmax((__result_type)__x, (__result_type)__y);
1168}
1169
1170// fmin
1171
1172using ::fmin;
1173using ::fminf;
1174
1175inline _LIBCPP_INLINE_VISIBILITY float fmin(float __x, float __y) {return fminf(__x, __y);}
1176inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __x, long double __y) {return fminl(__x, __y);}
1177
1178template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001179inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001180typename enable_if
1181<
1182 is_arithmetic<_A1>::value &&
1183 is_arithmetic<_A2>::value,
1184 typename __promote<_A1, _A2>::type
1185>::type
1186fmin(_A1 __x, _A2 __y)
1187{
1188 typedef typename __promote<_A1, _A2>::type __result_type;
1189 static_assert((!(is_same<_A1, __result_type>::value &&
1190 is_same<_A2, __result_type>::value)), "");
1191 return fmin((__result_type)__x, (__result_type)__y);
1192}
1193
1194// hypot
1195
1196using ::hypot;
1197using ::hypotf;
1198
1199inline _LIBCPP_INLINE_VISIBILITY float hypot(float __x, float __y) {return hypotf(__x, __y);}
1200inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __x, long double __y) {return hypotl(__x, __y);}
1201
1202template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001203inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001204typename enable_if
1205<
1206 is_arithmetic<_A1>::value &&
1207 is_arithmetic<_A2>::value,
1208 typename __promote<_A1, _A2>::type
1209>::type
1210hypot(_A1 __x, _A2 __y)
1211{
1212 typedef typename __promote<_A1, _A2>::type __result_type;
1213 static_assert((!(is_same<_A1, __result_type>::value &&
1214 is_same<_A2, __result_type>::value)), "");
1215 return hypot((__result_type)__x, (__result_type)__y);
1216}
1217
1218// ilogb
1219
1220using ::ilogb;
1221using ::ilogbf;
1222
1223inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __x) {return ilogbf(__x);}
1224inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __x) {return ilogbl(__x);}
1225
1226template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001227inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001228typename enable_if<is_integral<_A1>::value, int>::type
1229ilogb(_A1 __x) {return ilogb((double)__x);}
1230
1231// lgamma
1232
1233using ::lgamma;
1234using ::lgammaf;
1235
1236inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __x) {return lgammaf(__x);}
1237inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __x) {return lgammal(__x);}
1238
1239template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001240inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001241typename enable_if<is_integral<_A1>::value, double>::type
1242lgamma(_A1 __x) {return lgamma((double)__x);}
1243
1244// llrint
1245
1246using ::llrint;
1247using ::llrintf;
1248
1249inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __x) {return llrintf(__x);}
1250inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __x) {return llrintl(__x);}
1251
1252template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001253inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001254typename enable_if<is_integral<_A1>::value, long long>::type
1255llrint(_A1 __x) {return llrint((double)__x);}
1256
1257// llround
1258
1259using ::llround;
1260using ::llroundf;
1261
1262inline _LIBCPP_INLINE_VISIBILITY long long llround(float __x) {return llroundf(__x);}
1263inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __x) {return llroundl(__x);}
1264
1265template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001266inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001267typename enable_if<is_integral<_A1>::value, long long>::type
1268llround(_A1 __x) {return llround((double)__x);}
1269
1270// log1p
1271
1272using ::log1p;
1273using ::log1pf;
1274
1275inline _LIBCPP_INLINE_VISIBILITY float log1p(float __x) {return log1pf(__x);}
1276inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __x) {return log1pl(__x);}
1277
1278template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001279inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001280typename enable_if<is_integral<_A1>::value, double>::type
1281log1p(_A1 __x) {return log1p((double)__x);}
1282
1283// log2
1284
1285using ::log2;
1286using ::log2f;
1287
1288inline _LIBCPP_INLINE_VISIBILITY float log2(float __x) {return log2f(__x);}
1289inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __x) {return log2l(__x);}
1290
1291template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001292inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001293typename enable_if<is_integral<_A1>::value, double>::type
1294log2(_A1 __x) {return log2((double)__x);}
1295
1296// logb
1297
1298using ::logb;
1299using ::logbf;
1300
1301inline _LIBCPP_INLINE_VISIBILITY float logb(float __x) {return logbf(__x);}
1302inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __x) {return logbl(__x);}
1303
1304template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001305inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001306typename enable_if<is_integral<_A1>::value, double>::type
1307logb(_A1 __x) {return logb((double)__x);}
1308
1309// lrint
1310
1311using ::lrint;
1312using ::lrintf;
1313
1314inline _LIBCPP_INLINE_VISIBILITY long lrint(float __x) {return lrintf(__x);}
1315inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __x) {return lrintl(__x);}
1316
1317template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001318inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001319typename enable_if<is_integral<_A1>::value, long>::type
1320lrint(_A1 __x) {return lrint((double)__x);}
1321
1322// lround
1323
1324using ::lround;
1325using ::lroundf;
1326
1327inline _LIBCPP_INLINE_VISIBILITY long lround(float __x) {return lroundf(__x);}
1328inline _LIBCPP_INLINE_VISIBILITY long lround(long double __x) {return lroundl(__x);}
1329
1330template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001331inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001332typename enable_if<is_integral<_A1>::value, long>::type
1333lround(_A1 __x) {return lround((double)__x);}
1334
1335// nan
1336
1337using ::nan;
1338using ::nanf;
1339
1340// nearbyint
1341
1342using ::nearbyint;
1343using ::nearbyintf;
1344
1345inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __x) {return nearbyintf(__x);}
1346inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __x) {return nearbyintl(__x);}
1347
1348template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001349inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001350typename enable_if<is_integral<_A1>::value, double>::type
1351nearbyint(_A1 __x) {return nearbyint((double)__x);}
1352
1353// nextafter
1354
1355using ::nextafter;
1356using ::nextafterf;
1357
1358inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __x, float __y) {return nextafterf(__x, __y);}
1359inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __x, long double __y) {return nextafterl(__x, __y);}
1360
1361template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001362inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001363typename enable_if
1364<
1365 is_arithmetic<_A1>::value &&
1366 is_arithmetic<_A2>::value,
1367 typename __promote<_A1, _A2>::type
1368>::type
1369nextafter(_A1 __x, _A2 __y)
1370{
1371 typedef typename __promote<_A1, _A2>::type __result_type;
1372 static_assert((!(is_same<_A1, __result_type>::value &&
1373 is_same<_A2, __result_type>::value)), "");
1374 return nextafter((__result_type)__x, (__result_type)__y);
1375}
1376
1377// nexttoward
1378
1379using ::nexttoward;
1380using ::nexttowardf;
1381
1382inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __x, long double __y) {return nexttowardf(__x, __y);}
1383inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __x, long double __y) {return nexttowardl(__x, __y);}
1384
1385template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001386inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001387typename enable_if<is_integral<_A1>::value, double>::type
1388nexttoward(_A1 __x, long double __y) {return nexttoward((double)__x, __y);}
1389
1390// remainder
1391
1392using ::remainder;
1393using ::remainderf;
1394
1395inline _LIBCPP_INLINE_VISIBILITY float remainder(float __x, float __y) {return remainderf(__x, __y);}
1396inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __x, long double __y) {return remainderl(__x, __y);}
1397
1398template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001399inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001400typename enable_if
1401<
1402 is_arithmetic<_A1>::value &&
1403 is_arithmetic<_A2>::value,
1404 typename __promote<_A1, _A2>::type
1405>::type
1406remainder(_A1 __x, _A2 __y)
1407{
1408 typedef typename __promote<_A1, _A2>::type __result_type;
1409 static_assert((!(is_same<_A1, __result_type>::value &&
1410 is_same<_A2, __result_type>::value)), "");
1411 return remainder((__result_type)__x, (__result_type)__y);
1412}
1413
1414// remquo
1415
1416using ::remquo;
1417using ::remquof;
1418
1419inline _LIBCPP_INLINE_VISIBILITY float remquo(float __x, float __y, int* __z) {return remquof(__x, __y, __z);}
1420inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __x, long double __y, int* __z) {return remquol(__x, __y, __z);}
1421
1422template <class _A1, class _A2>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001423inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001424typename enable_if
1425<
1426 is_arithmetic<_A1>::value &&
1427 is_arithmetic<_A2>::value,
1428 typename __promote<_A1, _A2>::type
1429>::type
1430remquo(_A1 __x, _A2 __y, int* __z)
1431{
1432 typedef typename __promote<_A1, _A2>::type __result_type;
1433 static_assert((!(is_same<_A1, __result_type>::value &&
1434 is_same<_A2, __result_type>::value)), "");
1435 return remquo((__result_type)__x, (__result_type)__y, __z);
1436}
1437
1438// rint
1439
1440using ::rint;
1441using ::rintf;
1442
1443inline _LIBCPP_INLINE_VISIBILITY float rint(float __x) {return rintf(__x);}
1444inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __x) {return rintl(__x);}
1445
1446template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001447inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001448typename enable_if<is_integral<_A1>::value, double>::type
1449rint(_A1 __x) {return rint((double)__x);}
1450
1451// round
1452
1453using ::round;
1454using ::roundf;
1455
1456inline _LIBCPP_INLINE_VISIBILITY float round(float __x) {return roundf(__x);}
1457inline _LIBCPP_INLINE_VISIBILITY long double round(long double __x) {return roundl(__x);}
1458
1459template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001460inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001461typename enable_if<is_integral<_A1>::value, double>::type
1462round(_A1 __x) {return round((double)__x);}
1463
1464// scalbln
1465
1466using ::scalbln;
1467using ::scalblnf;
1468
1469inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __x, long __y) {return scalblnf(__x, __y);}
1470inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __x, long __y) {return scalblnl(__x, __y);}
1471
1472template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001473inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001474typename enable_if<is_integral<_A1>::value, double>::type
1475scalbln(_A1 __x, long __y) {return scalbln((double)__x, __y);}
1476
1477// scalbn
1478
1479using ::scalbn;
1480using ::scalbnf;
1481
1482inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __x, int __y) {return scalbnf(__x, __y);}
1483inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __x, int __y) {return scalbnl(__x, __y);}
1484
1485template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001486inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001487typename enable_if<is_integral<_A1>::value, double>::type
1488scalbn(_A1 __x, int __y) {return scalbn((double)__x, __y);}
1489
1490// tgamma
1491
1492using ::tgamma;
1493using ::tgammaf;
1494
1495inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __x) {return tgammaf(__x);}
1496inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __x) {return tgammal(__x);}
1497
1498template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001499inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001500typename enable_if<is_integral<_A1>::value, double>::type
1501tgamma(_A1 __x) {return tgamma((double)__x);}
1502
1503// trunc
1504
1505using ::trunc;
1506using ::truncf;
1507
1508inline _LIBCPP_INLINE_VISIBILITY float trunc(float __x) {return truncf(__x);}
1509inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __x) {return truncl(__x);}
1510
1511template <class _A1>
Howard Hinnant422a53f2010-09-21 21:28:23 +00001512inline _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001513typename enable_if<is_integral<_A1>::value, double>::type
1514trunc(_A1 __x) {return trunc((double)__x);}
1515
1516using ::acosl;
1517using ::asinl;
1518using ::atanl;
1519using ::atan2l;
1520using ::ceill;
1521using ::cosl;
1522using ::coshl;
1523using ::expl;
1524using ::fabsl;
1525using ::floorl;
1526using ::fmodl;
1527using ::frexpl;
1528using ::ldexpl;
1529using ::logl;
1530using ::log10l;
1531using ::modfl;
1532using ::powl;
1533using ::sinl;
1534using ::sinhl;
1535using ::sqrtl;
1536using ::tanl;
1537using ::tanhl;
1538using ::acoshl;
1539using ::asinhl;
1540using ::atanhl;
1541using ::cbrtl;
1542using ::copysignl;
1543using ::erfl;
1544using ::erfcl;
1545using ::exp2l;
1546using ::expm1l;
1547using ::fdiml;
1548using ::fmal;
1549using ::fmaxl;
1550using ::fminl;
1551using ::hypotl;
1552using ::ilogbl;
1553using ::lgammal;
1554using ::llrintl;
1555using ::llroundl;
1556using ::log1pl;
1557using ::log2l;
1558using ::logbl;
1559using ::lrintl;
1560using ::lroundl;
1561using ::nanl;
1562using ::nearbyintl;
1563using ::nextafterl;
1564using ::nexttowardl;
1565using ::remainderl;
1566using ::remquol;
1567using ::rintl;
1568using ::roundl;
1569using ::scalblnl;
1570using ::scalbnl;
1571using ::tgammal;
1572using ::truncl;
1573
1574_LIBCPP_END_NAMESPACE_STD
1575
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001576#endif // _LIBCPP_CMATH