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