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