blob: fb0b6083010b7087368a658be675741f9abed741 [file] [log] [blame]
Richard Smith524956b2015-10-08 20:40:34 +00001// -*- C++ -*-
2//===---------------------------- math.h ----------------------------------===//
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_MATH_H
12#define _LIBCPP_MATH_H
13
14/*
15 math.h 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
38Types:
39
40 float_t // C99
41 double_t // C99
42
43// C90
44
45floating_point abs(floating_point x);
46
47floating_point acos (arithmetic x);
48float acosf(float x);
49long double acosl(long double x);
50
51floating_point asin (arithmetic x);
52float asinf(float x);
53long double asinl(long double x);
54
55floating_point atan (arithmetic x);
56float atanf(float x);
57long double atanl(long double x);
58
59floating_point atan2 (arithmetic y, arithmetic x);
60float atan2f(float y, float x);
61long double atan2l(long double y, long double x);
62
63floating_point ceil (arithmetic x);
64float ceilf(float x);
65long double ceill(long double x);
66
67floating_point cos (arithmetic x);
68float cosf(float x);
69long double cosl(long double x);
70
71floating_point cosh (arithmetic x);
72float coshf(float x);
73long double coshl(long double x);
74
75floating_point exp (arithmetic x);
76float expf(float x);
77long double expl(long double x);
78
79floating_point fabs (arithmetic x);
80float fabsf(float x);
81long double fabsl(long double x);
82
83floating_point floor (arithmetic x);
84float floorf(float x);
85long double floorl(long double x);
86
87floating_point fmod (arithmetic x, arithmetic y);
88float fmodf(float x, float y);
89long double fmodl(long double x, long double y);
90
91floating_point frexp (arithmetic value, int* exp);
92float frexpf(float value, int* exp);
93long double frexpl(long double value, int* exp);
94
95floating_point ldexp (arithmetic value, int exp);
96float ldexpf(float value, int exp);
97long double ldexpl(long double value, int exp);
98
99floating_point log (arithmetic x);
100float logf(float x);
101long double logl(long double x);
102
103floating_point log10 (arithmetic x);
104float log10f(float x);
105long double log10l(long double x);
106
107floating_point modf (floating_point value, floating_point* iptr);
108float modff(float value, float* iptr);
109long double modfl(long double value, long double* iptr);
110
111floating_point pow (arithmetic x, arithmetic y);
112float powf(float x, float y);
113long double powl(long double x, long double y);
114
115floating_point sin (arithmetic x);
116float sinf(float x);
117long double sinl(long double x);
118
119floating_point sinh (arithmetic x);
120float sinhf(float x);
121long double sinhl(long double x);
122
123floating_point sqrt (arithmetic x);
124float sqrtf(float x);
125long double sqrtl(long double x);
126
127floating_point tan (arithmetic x);
128float tanf(float x);
129long double tanl(long double x);
130
131floating_point tanh (arithmetic x);
132float tanhf(float x);
133long double tanhl(long double x);
134
135// C99
136
137bool signbit(arithmetic x);
138
139int fpclassify(arithmetic x);
140
141bool isfinite(arithmetic x);
142bool isinf(arithmetic x);
143bool isnan(arithmetic x);
144bool isnormal(arithmetic x);
145
146bool isgreater(arithmetic x, arithmetic y);
147bool isgreaterequal(arithmetic x, arithmetic y);
148bool isless(arithmetic x, arithmetic y);
149bool islessequal(arithmetic x, arithmetic y);
150bool islessgreater(arithmetic x, arithmetic y);
151bool isunordered(arithmetic x, arithmetic y);
152
153floating_point acosh (arithmetic x);
154float acoshf(float x);
155long double acoshl(long double x);
156
157floating_point asinh (arithmetic x);
158float asinhf(float x);
159long double asinhl(long double x);
160
161floating_point atanh (arithmetic x);
162float atanhf(float x);
163long double atanhl(long double x);
164
165floating_point cbrt (arithmetic x);
166float cbrtf(float x);
167long double cbrtl(long double x);
168
169floating_point copysign (arithmetic x, arithmetic y);
170float copysignf(float x, float y);
171long double copysignl(long double x, long double y);
172
173floating_point erf (arithmetic x);
174float erff(float x);
175long double erfl(long double x);
176
177floating_point erfc (arithmetic x);
178float erfcf(float x);
179long double erfcl(long double x);
180
181floating_point exp2 (arithmetic x);
182float exp2f(float x);
183long double exp2l(long double x);
184
185floating_point expm1 (arithmetic x);
186float expm1f(float x);
187long double expm1l(long double x);
188
189floating_point fdim (arithmetic x, arithmetic y);
190float fdimf(float x, float y);
191long double fdiml(long double x, long double y);
192
193floating_point fma (arithmetic x, arithmetic y, arithmetic z);
194float fmaf(float x, float y, float z);
195long double fmal(long double x, long double y, long double z);
196
197floating_point fmax (arithmetic x, arithmetic y);
198float fmaxf(float x, float y);
199long double fmaxl(long double x, long double y);
200
201floating_point fmin (arithmetic x, arithmetic y);
202float fminf(float x, float y);
203long double fminl(long double x, long double y);
204
205floating_point hypot (arithmetic x, arithmetic y);
206float hypotf(float x, float y);
207long double hypotl(long double x, long double y);
208
209int ilogb (arithmetic x);
210int ilogbf(float x);
211int ilogbl(long double x);
212
213floating_point lgamma (arithmetic x);
214float lgammaf(float x);
215long double lgammal(long double x);
216
217long long llrint (arithmetic x);
218long long llrintf(float x);
219long long llrintl(long double x);
220
221long long llround (arithmetic x);
222long long llroundf(float x);
223long long llroundl(long double x);
224
225floating_point log1p (arithmetic x);
226float log1pf(float x);
227long double log1pl(long double x);
228
229floating_point log2 (arithmetic x);
230float log2f(float x);
231long double log2l(long double x);
232
233floating_point logb (arithmetic x);
234float logbf(float x);
235long double logbl(long double x);
236
237long lrint (arithmetic x);
238long lrintf(float x);
239long lrintl(long double x);
240
241long lround (arithmetic x);
242long lroundf(float x);
243long lroundl(long double x);
244
245double nan (const char* str);
246float nanf(const char* str);
247long double nanl(const char* str);
248
249floating_point nearbyint (arithmetic x);
250float nearbyintf(float x);
251long double nearbyintl(long double x);
252
253floating_point nextafter (arithmetic x, arithmetic y);
254float nextafterf(float x, float y);
255long double nextafterl(long double x, long double y);
256
257floating_point nexttoward (arithmetic x, long double y);
258float nexttowardf(float x, long double y);
259long double nexttowardl(long double x, long double y);
260
261floating_point remainder (arithmetic x, arithmetic y);
262float remainderf(float x, float y);
263long double remainderl(long double x, long double y);
264
265floating_point remquo (arithmetic x, arithmetic y, int* pquo);
266float remquof(float x, float y, int* pquo);
267long double remquol(long double x, long double y, int* pquo);
268
269floating_point rint (arithmetic x);
270float rintf(float x);
271long double rintl(long double x);
272
273floating_point round (arithmetic x);
274float roundf(float x);
275long double roundl(long double x);
276
277floating_point scalbln (arithmetic x, long ex);
278float scalblnf(float x, long ex);
279long double scalblnl(long double x, long ex);
280
281floating_point scalbn (arithmetic x, int ex);
282float scalbnf(float x, int ex);
283long double scalbnl(long double x, int ex);
284
285floating_point tgamma (arithmetic x);
286float tgammaf(float x);
287long double tgammal(long double x);
288
289floating_point trunc (arithmetic x);
290float truncf(float x);
291long double truncl(long double x);
292
293*/
294
295#include <__config>
Richard Smith524956b2015-10-08 20:40:34 +0000296
297#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
298#pragma GCC system_header
299#endif
300
Richard Smith2999ea02015-10-09 00:26:50 +0000301#include_next <math.h>
302
Richard Smith524956b2015-10-08 20:40:34 +0000303#ifdef __cplusplus
304
305// We support including .h headers inside 'extern "C"' contexts, so switch
306// back to C++ linkage before including these C++ headers.
307extern "C++" {
308
309#include <type_traits>
310
Richard Smith524956b2015-10-08 20:40:34 +0000311// signbit
312
313#ifdef signbit
314
315template <class _A1>
316_LIBCPP_ALWAYS_INLINE
317bool
318__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
319{
320 return signbit(__lcpp_x);
321}
322
323#undef signbit
324
325template <class _A1>
326inline _LIBCPP_INLINE_VISIBILITY
327typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
328signbit(_A1 __lcpp_x) _NOEXCEPT
329{
330 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
331}
332
333#endif // signbit
334
335// fpclassify
336
337#ifdef fpclassify
338
339template <class _A1>
340_LIBCPP_ALWAYS_INLINE
341int
342__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT
343{
344 return fpclassify(__lcpp_x);
345}
346
347#undef fpclassify
348
349template <class _A1>
350inline _LIBCPP_INLINE_VISIBILITY
351typename std::enable_if<std::is_arithmetic<_A1>::value, int>::type
352fpclassify(_A1 __lcpp_x) _NOEXCEPT
353{
354 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
355}
356
357#endif // fpclassify
358
359// isfinite
360
361#ifdef isfinite
362
363template <class _A1>
364_LIBCPP_ALWAYS_INLINE
365bool
366__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT
367{
368 return isfinite(__lcpp_x);
369}
370
371#undef isfinite
372
373template <class _A1>
374inline _LIBCPP_INLINE_VISIBILITY
375typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
376isfinite(_A1 __lcpp_x) _NOEXCEPT
377{
378 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
379}
380
381#endif // isfinite
382
383// isinf
384
385#ifdef isinf
386
387template <class _A1>
388_LIBCPP_ALWAYS_INLINE
389bool
390__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
391{
392 return isinf(__lcpp_x);
393}
394
395#undef isinf
396
397template <class _A1>
398inline _LIBCPP_INLINE_VISIBILITY
399typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
400isinf(_A1 __lcpp_x) _NOEXCEPT
401{
402 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
403}
404
405#endif // isinf
406
407// isnan
408
409#ifdef isnan
410
411template <class _A1>
412_LIBCPP_ALWAYS_INLINE
413bool
414__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT
415{
416 return isnan(__lcpp_x);
417}
418
419#undef isnan
420
421template <class _A1>
422inline _LIBCPP_INLINE_VISIBILITY
423typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
424isnan(_A1 __lcpp_x) _NOEXCEPT
425{
426 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);
427}
428
429#endif // isnan
430
431// isnormal
432
433#ifdef isnormal
434
435template <class _A1>
436_LIBCPP_ALWAYS_INLINE
437bool
438__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT
439{
440 return isnormal(__lcpp_x);
441}
442
443#undef isnormal
444
445template <class _A1>
446inline _LIBCPP_INLINE_VISIBILITY
447typename std::enable_if<std::is_arithmetic<_A1>::value, bool>::type
448isnormal(_A1 __lcpp_x) _NOEXCEPT
449{
450 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);
451}
452
453#endif // isnormal
454
455// isgreater
456
457#ifdef isgreater
458
459template <class _A1, class _A2>
460_LIBCPP_ALWAYS_INLINE
461bool
462__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
463{
464 return isgreater(__lcpp_x, __lcpp_y);
465}
466
467#undef isgreater
468
469template <class _A1, class _A2>
470inline _LIBCPP_INLINE_VISIBILITY
471typename std::enable_if
472<
473 std::is_arithmetic<_A1>::value &&
474 std::is_arithmetic<_A2>::value,
475 bool
476>::type
477isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
478{
479 typedef typename std::__promote<_A1, _A2>::type type;
480 return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_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 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
493{
494 return isgreaterequal(__lcpp_x, __lcpp_y);
495}
496
497#undef isgreaterequal
498
499template <class _A1, class _A2>
500inline _LIBCPP_INLINE_VISIBILITY
501typename std::enable_if
502<
503 std::is_arithmetic<_A1>::value &&
504 std::is_arithmetic<_A2>::value,
505 bool
506>::type
507isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
508{
509 typedef typename std::__promote<_A1, _A2>::type type;
510 return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);
511}
512
513#endif // isgreaterequal
514
515// isless
516
517#ifdef isless
518
519template <class _A1, class _A2>
520_LIBCPP_ALWAYS_INLINE
521bool
522__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
523{
524 return isless(__lcpp_x, __lcpp_y);
525}
526
527#undef isless
528
529template <class _A1, class _A2>
530inline _LIBCPP_INLINE_VISIBILITY
531typename std::enable_if
532<
533 std::is_arithmetic<_A1>::value &&
534 std::is_arithmetic<_A2>::value,
535 bool
536>::type
537isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
538{
539 typedef typename std::__promote<_A1, _A2>::type type;
540 return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);
541}
542
543#endif // isless
544
545// islessequal
546
547#ifdef islessequal
548
549template <class _A1, class _A2>
550_LIBCPP_ALWAYS_INLINE
551bool
552__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
553{
554 return islessequal(__lcpp_x, __lcpp_y);
555}
556
557#undef islessequal
558
559template <class _A1, class _A2>
560inline _LIBCPP_INLINE_VISIBILITY
561typename std::enable_if
562<
563 std::is_arithmetic<_A1>::value &&
564 std::is_arithmetic<_A2>::value,
565 bool
566>::type
567islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
568{
569 typedef typename std::__promote<_A1, _A2>::type type;
570 return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);
571}
572
573#endif // islessequal
574
575// islessgreater
576
577#ifdef islessgreater
578
579template <class _A1, class _A2>
580_LIBCPP_ALWAYS_INLINE
581bool
582__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
583{
584 return islessgreater(__lcpp_x, __lcpp_y);
585}
586
587#undef islessgreater
588
589template <class _A1, class _A2>
590inline _LIBCPP_INLINE_VISIBILITY
591typename std::enable_if
592<
593 std::is_arithmetic<_A1>::value &&
594 std::is_arithmetic<_A2>::value,
595 bool
596>::type
597islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
598{
599 typedef typename std::__promote<_A1, _A2>::type type;
600 return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);
601}
602
603#endif // islessgreater
604
605// isunordered
606
607#ifdef isunordered
608
609template <class _A1, class _A2>
610_LIBCPP_ALWAYS_INLINE
611bool
612__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
613{
614 return isunordered(__lcpp_x, __lcpp_y);
615}
616
617#undef isunordered
618
619template <class _A1, class _A2>
620inline _LIBCPP_INLINE_VISIBILITY
621typename std::enable_if
622<
623 std::is_arithmetic<_A1>::value &&
624 std::is_arithmetic<_A2>::value,
625 bool
626>::type
627isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
628{
629 typedef typename std::__promote<_A1, _A2>::type type;
630 return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);
631}
632
633#endif // isunordered
634
Richard Smith524956b2015-10-08 20:40:34 +0000635// abs
636
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000637#if !(defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000638inline _LIBCPP_INLINE_VISIBILITY
639float
640abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
641
642inline _LIBCPP_INLINE_VISIBILITY
643double
644abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);}
645
646inline _LIBCPP_INLINE_VISIBILITY
647long double
648abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000649#endif // !(defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000650
651// acos
652
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000653#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000654inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return acosf(__lcpp_x);}
655inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);}
656#endif
657
658template <class _A1>
659inline _LIBCPP_INLINE_VISIBILITY
660typename std::enable_if<std::is_integral<_A1>::value, double>::type
661acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);}
662
663// asin
664
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000665#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000666inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return asinf(__lcpp_x);}
667inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);}
668#endif
669
670template <class _A1>
671inline _LIBCPP_INLINE_VISIBILITY
672typename std::enable_if<std::is_integral<_A1>::value, double>::type
673asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);}
674
675// atan
676
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000677#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000678inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return atanf(__lcpp_x);}
679inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);}
680#endif
681
682template <class _A1>
683inline _LIBCPP_INLINE_VISIBILITY
684typename std::enable_if<std::is_integral<_A1>::value, double>::type
685atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);}
686
687// atan2
688
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000689#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000690inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);}
691inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);}
692#endif
693
694template <class _A1, class _A2>
695inline _LIBCPP_INLINE_VISIBILITY
696typename std::__lazy_enable_if
697<
698 std::is_arithmetic<_A1>::value &&
699 std::is_arithmetic<_A2>::value,
700 std::__promote<_A1, _A2>
701>::type
702atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
703{
704 typedef typename std::__promote<_A1, _A2>::type __result_type;
705 static_assert((!(std::is_same<_A1, __result_type>::value &&
706 std::is_same<_A2, __result_type>::value)), "");
707 return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
708}
709
710// ceil
711
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000712#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000713inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ceilf(__lcpp_x);}
714inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);}
715#endif
716
717template <class _A1>
718inline _LIBCPP_INLINE_VISIBILITY
719typename std::enable_if<std::is_integral<_A1>::value, double>::type
720ceil(_A1 __lcpp_x) _NOEXCEPT {return ceil((double)__lcpp_x);}
721
722// cos
723
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000724#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000725inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return cosf(__lcpp_x);}
726inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);}
727#endif
728
729template <class _A1>
730inline _LIBCPP_INLINE_VISIBILITY
731typename std::enable_if<std::is_integral<_A1>::value, double>::type
732cos(_A1 __lcpp_x) _NOEXCEPT {return cos((double)__lcpp_x);}
733
734// cosh
735
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000736#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000737inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return coshf(__lcpp_x);}
738inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);}
739#endif
740
741template <class _A1>
742inline _LIBCPP_INLINE_VISIBILITY
743typename std::enable_if<std::is_integral<_A1>::value, double>::type
744cosh(_A1 __lcpp_x) _NOEXCEPT {return cosh((double)__lcpp_x);}
745
746// exp
747
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000748#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000749inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return expf(__lcpp_x);}
750inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);}
751#endif
752
753template <class _A1>
754inline _LIBCPP_INLINE_VISIBILITY
755typename std::enable_if<std::is_integral<_A1>::value, double>::type
756exp(_A1 __lcpp_x) _NOEXCEPT {return exp((double)__lcpp_x);}
757
758// fabs
759
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000760#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000761inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);}
762inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);}
763#endif
764
765template <class _A1>
766inline _LIBCPP_INLINE_VISIBILITY
767typename std::enable_if<std::is_integral<_A1>::value, double>::type
768fabs(_A1 __lcpp_x) _NOEXCEPT {return fabs((double)__lcpp_x);}
769
770// floor
771
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000772#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000773inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return floorf(__lcpp_x);}
774inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);}
775#endif
776
777template <class _A1>
778inline _LIBCPP_INLINE_VISIBILITY
779typename std::enable_if<std::is_integral<_A1>::value, double>::type
780floor(_A1 __lcpp_x) _NOEXCEPT {return floor((double)__lcpp_x);}
781
782// fmod
783
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000784#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000785inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmodf(__lcpp_x, __lcpp_y);}
786inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);}
787#endif
788
789template <class _A1, class _A2>
790inline _LIBCPP_INLINE_VISIBILITY
791typename std::__lazy_enable_if
792<
793 std::is_arithmetic<_A1>::value &&
794 std::is_arithmetic<_A2>::value,
795 std::__promote<_A1, _A2>
796>::type
797fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
798{
799 typedef typename std::__promote<_A1, _A2>::type __result_type;
800 static_assert((!(std::is_same<_A1, __result_type>::value &&
801 std::is_same<_A2, __result_type>::value)), "");
802 return fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
803}
804
805// frexp
806
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000807#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000808inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpf(__lcpp_x, __lcpp_e);}
809inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);}
810#endif
811
812template <class _A1>
813inline _LIBCPP_INLINE_VISIBILITY
814typename std::enable_if<std::is_integral<_A1>::value, double>::type
815frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexp((double)__lcpp_x, __lcpp_e);}
816
817// ldexp
818
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000819#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000820inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpf(__lcpp_x, __lcpp_e);}
821inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);}
822#endif
823
824template <class _A1>
825inline _LIBCPP_INLINE_VISIBILITY
826typename std::enable_if<std::is_integral<_A1>::value, double>::type
827ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexp((double)__lcpp_x, __lcpp_e);}
828
829// log
830
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000831#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000832inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return logf(__lcpp_x);}
833inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);}
834#endif
835
836template <class _A1>
837inline _LIBCPP_INLINE_VISIBILITY
838typename std::enable_if<std::is_integral<_A1>::value, double>::type
839log(_A1 __lcpp_x) _NOEXCEPT {return log((double)__lcpp_x);}
840
841// log10
842
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000843#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000844inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return log10f(__lcpp_x);}
845inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);}
846#endif
847
848template <class _A1>
849inline _LIBCPP_INLINE_VISIBILITY
850typename std::enable_if<std::is_integral<_A1>::value, double>::type
851log10(_A1 __lcpp_x) _NOEXCEPT {return log10((double)__lcpp_x);}
852
853// modf
854
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000855#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000856inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return modff(__lcpp_x, __lcpp_y);}
857inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);}
858#endif
859
860// pow
861
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000862#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000863inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return powf(__lcpp_x, __lcpp_y);}
864inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);}
865#endif
866
867template <class _A1, class _A2>
868inline _LIBCPP_INLINE_VISIBILITY
869typename std::__lazy_enable_if
870<
871 std::is_arithmetic<_A1>::value &&
872 std::is_arithmetic<_A2>::value,
873 std::__promote<_A1, _A2>
874>::type
875pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
876{
877 typedef typename std::__promote<_A1, _A2>::type __result_type;
878 static_assert((!(std::is_same<_A1, __result_type>::value &&
879 std::is_same<_A2, __result_type>::value)), "");
880 return pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
881}
882
883// sin
884
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000885#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000886inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return sinf(__lcpp_x);}
887inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);}
888#endif
889
890template <class _A1>
891inline _LIBCPP_INLINE_VISIBILITY
892typename std::enable_if<std::is_integral<_A1>::value, double>::type
893sin(_A1 __lcpp_x) _NOEXCEPT {return sin((double)__lcpp_x);}
894
895// sinh
896
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000897#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000898inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return sinhf(__lcpp_x);}
899inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);}
900#endif
901
902template <class _A1>
903inline _LIBCPP_INLINE_VISIBILITY
904typename std::enable_if<std::is_integral<_A1>::value, double>::type
905sinh(_A1 __lcpp_x) _NOEXCEPT {return sinh((double)__lcpp_x);}
906
907// sqrt
908
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000909#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000910inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return sqrtf(__lcpp_x);}
911inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);}
912#endif
913
Richard Smith524956b2015-10-08 20:40:34 +0000914template <class _A1>
915inline _LIBCPP_INLINE_VISIBILITY
916typename std::enable_if<std::is_integral<_A1>::value, double>::type
917sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);}
Richard Smith524956b2015-10-08 20:40:34 +0000918
919// tan
920
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000921#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000922inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return tanf(__lcpp_x);}
923inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);}
924#endif
925
926template <class _A1>
927inline _LIBCPP_INLINE_VISIBILITY
928typename std::enable_if<std::is_integral<_A1>::value, double>::type
929tan(_A1 __lcpp_x) _NOEXCEPT {return tan((double)__lcpp_x);}
930
931// tanh
932
Eric Fiselier1053e7e2016-08-15 18:58:57 +0000933#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX) || defined(__sun__))
Richard Smith524956b2015-10-08 20:40:34 +0000934inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return tanhf(__lcpp_x);}
935inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);}
936#endif
937
938template <class _A1>
939inline _LIBCPP_INLINE_VISIBILITY
940typename std::enable_if<std::is_integral<_A1>::value, double>::type
941tanh(_A1 __lcpp_x) _NOEXCEPT {return tanh((double)__lcpp_x);}
942
943// acosh
944
945#ifndef _LIBCPP_MSVCRT
946inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return acoshf(__lcpp_x);}
947inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return acoshl(__lcpp_x);}
948
949template <class _A1>
950inline _LIBCPP_INLINE_VISIBILITY
951typename std::enable_if<std::is_integral<_A1>::value, double>::type
952acosh(_A1 __lcpp_x) _NOEXCEPT {return acosh((double)__lcpp_x);}
953#endif
954
955// asinh
956
957#ifndef _LIBCPP_MSVCRT
958inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return asinhf(__lcpp_x);}
959inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return asinhl(__lcpp_x);}
960
961template <class _A1>
962inline _LIBCPP_INLINE_VISIBILITY
963typename std::enable_if<std::is_integral<_A1>::value, double>::type
964asinh(_A1 __lcpp_x) _NOEXCEPT {return asinh((double)__lcpp_x);}
965#endif
966
967// atanh
968
969#ifndef _LIBCPP_MSVCRT
970inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return atanhf(__lcpp_x);}
971inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return atanhl(__lcpp_x);}
972
973template <class _A1>
974inline _LIBCPP_INLINE_VISIBILITY
975typename std::enable_if<std::is_integral<_A1>::value, double>::type
976atanh(_A1 __lcpp_x) _NOEXCEPT {return atanh((double)__lcpp_x);}
977#endif
978
979// cbrt
980
981#ifndef _LIBCPP_MSVCRT
982inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return cbrtf(__lcpp_x);}
983inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return cbrtl(__lcpp_x);}
984
985template <class _A1>
986inline _LIBCPP_INLINE_VISIBILITY
987typename std::enable_if<std::is_integral<_A1>::value, double>::type
988cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);}
989#endif
990
991// copysign
992
993#if !defined(_VC_CRT_MAJOR_VERSION) || (_VC_CRT_MAJOR_VERSION < 12)
994inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x,
995 float __lcpp_y) _NOEXCEPT {
996 return copysignf(__lcpp_x, __lcpp_y);
997}
998inline _LIBCPP_INLINE_VISIBILITY long double
999copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
1000 return copysignl(__lcpp_x, __lcpp_y);
1001}
1002#endif
1003
1004template <class _A1, class _A2>
1005inline _LIBCPP_INLINE_VISIBILITY
1006typename std::__lazy_enable_if
1007<
1008 std::is_arithmetic<_A1>::value &&
1009 std::is_arithmetic<_A2>::value,
1010 std::__promote<_A1, _A2>
1011>::type
1012copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1013{
1014 typedef typename std::__promote<_A1, _A2>::type __result_type;
1015 static_assert((!(std::is_same<_A1, __result_type>::value &&
1016 std::is_same<_A2, __result_type>::value)), "");
1017 return copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1018}
1019
1020#ifndef _LIBCPP_MSVCRT
1021
1022// erf
1023
1024inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return erff(__lcpp_x);}
1025inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return erfl(__lcpp_x);}
1026
1027template <class _A1>
1028inline _LIBCPP_INLINE_VISIBILITY
1029typename std::enable_if<std::is_integral<_A1>::value, double>::type
1030erf(_A1 __lcpp_x) _NOEXCEPT {return erf((double)__lcpp_x);}
1031
1032// erfc
1033
1034inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return erfcf(__lcpp_x);}
1035inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return erfcl(__lcpp_x);}
1036
1037template <class _A1>
1038inline _LIBCPP_INLINE_VISIBILITY
1039typename std::enable_if<std::is_integral<_A1>::value, double>::type
1040erfc(_A1 __lcpp_x) _NOEXCEPT {return erfc((double)__lcpp_x);}
1041
1042// exp2
1043
1044inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return exp2f(__lcpp_x);}
1045inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return exp2l(__lcpp_x);}
1046
1047template <class _A1>
1048inline _LIBCPP_INLINE_VISIBILITY
1049typename std::enable_if<std::is_integral<_A1>::value, double>::type
1050exp2(_A1 __lcpp_x) _NOEXCEPT {return exp2((double)__lcpp_x);}
1051
1052// expm1
1053
1054inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return expm1f(__lcpp_x);}
1055inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return expm1l(__lcpp_x);}
1056
1057template <class _A1>
1058inline _LIBCPP_INLINE_VISIBILITY
1059typename std::enable_if<std::is_integral<_A1>::value, double>::type
1060expm1(_A1 __lcpp_x) _NOEXCEPT {return expm1((double)__lcpp_x);}
1061
1062// fdim
1063
1064inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fdimf(__lcpp_x, __lcpp_y);}
1065inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fdiml(__lcpp_x, __lcpp_y);}
1066
1067template <class _A1, class _A2>
1068inline _LIBCPP_INLINE_VISIBILITY
1069typename std::__lazy_enable_if
1070<
1071 std::is_arithmetic<_A1>::value &&
1072 std::is_arithmetic<_A2>::value,
1073 std::__promote<_A1, _A2>
1074>::type
1075fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1076{
1077 typedef typename std::__promote<_A1, _A2>::type __result_type;
1078 static_assert((!(std::is_same<_A1, __result_type>::value &&
1079 std::is_same<_A2, __result_type>::value)), "");
1080 return fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1081}
1082
1083// fma
1084
1085inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return fmaf(__lcpp_x, __lcpp_y, __lcpp_z);}
1086inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return fmal(__lcpp_x, __lcpp_y, __lcpp_z);}
1087
1088template <class _A1, class _A2, class _A3>
1089inline _LIBCPP_INLINE_VISIBILITY
1090typename std::__lazy_enable_if
1091<
1092 std::is_arithmetic<_A1>::value &&
1093 std::is_arithmetic<_A2>::value &&
1094 std::is_arithmetic<_A3>::value,
1095 std::__promote<_A1, _A2, _A3>
1096>::type
1097fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
1098{
1099 typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
1100 static_assert((!(std::is_same<_A1, __result_type>::value &&
1101 std::is_same<_A2, __result_type>::value &&
1102 std::is_same<_A3, __result_type>::value)), "");
1103 return fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
1104}
1105
1106// fmax
1107
1108inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmaxf(__lcpp_x, __lcpp_y);}
1109inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmaxl(__lcpp_x, __lcpp_y);}
1110
1111template <class _A1, class _A2>
1112inline _LIBCPP_INLINE_VISIBILITY
1113typename std::__lazy_enable_if
1114<
1115 std::is_arithmetic<_A1>::value &&
1116 std::is_arithmetic<_A2>::value,
1117 std::__promote<_A1, _A2>
1118>::type
1119fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1120{
1121 typedef typename std::__promote<_A1, _A2>::type __result_type;
1122 static_assert((!(std::is_same<_A1, __result_type>::value &&
1123 std::is_same<_A2, __result_type>::value)), "");
1124 return fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1125}
1126
1127// fmin
1128
1129inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fminf(__lcpp_x, __lcpp_y);}
1130inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fminl(__lcpp_x, __lcpp_y);}
1131
1132template <class _A1, class _A2>
1133inline _LIBCPP_INLINE_VISIBILITY
1134typename std::__lazy_enable_if
1135<
1136 std::is_arithmetic<_A1>::value &&
1137 std::is_arithmetic<_A2>::value,
1138 std::__promote<_A1, _A2>
1139>::type
1140fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1141{
1142 typedef typename std::__promote<_A1, _A2>::type __result_type;
1143 static_assert((!(std::is_same<_A1, __result_type>::value &&
1144 std::is_same<_A2, __result_type>::value)), "");
1145 return fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1146}
1147
1148// hypot
1149
1150inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return hypotf(__lcpp_x, __lcpp_y);}
1151inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return hypotl(__lcpp_x, __lcpp_y);}
1152
1153template <class _A1, class _A2>
1154inline _LIBCPP_INLINE_VISIBILITY
1155typename std::__lazy_enable_if
1156<
1157 std::is_arithmetic<_A1>::value &&
1158 std::is_arithmetic<_A2>::value,
1159 std::__promote<_A1, _A2>
1160>::type
1161hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1162{
1163 typedef typename std::__promote<_A1, _A2>::type __result_type;
1164 static_assert((!(std::is_same<_A1, __result_type>::value &&
1165 std::is_same<_A2, __result_type>::value)), "");
1166 return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1167}
1168
1169// ilogb
1170
1171inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ilogbf(__lcpp_x);}
1172inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ilogbl(__lcpp_x);}
1173
1174template <class _A1>
1175inline _LIBCPP_INLINE_VISIBILITY
1176typename std::enable_if<std::is_integral<_A1>::value, int>::type
1177ilogb(_A1 __lcpp_x) _NOEXCEPT {return ilogb((double)__lcpp_x);}
1178
1179// lgamma
1180
1181inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return lgammaf(__lcpp_x);}
1182inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return lgammal(__lcpp_x);}
1183
1184template <class _A1>
1185inline _LIBCPP_INLINE_VISIBILITY
1186typename std::enable_if<std::is_integral<_A1>::value, double>::type
1187lgamma(_A1 __lcpp_x) _NOEXCEPT {return lgamma((double)__lcpp_x);}
1188
1189// llrint
1190
1191inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return llrintf(__lcpp_x);}
1192inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return llrintl(__lcpp_x);}
1193
1194template <class _A1>
1195inline _LIBCPP_INLINE_VISIBILITY
1196typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1197llrint(_A1 __lcpp_x) _NOEXCEPT {return llrint((double)__lcpp_x);}
1198
1199// llround
1200
1201inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return llroundf(__lcpp_x);}
1202inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return llroundl(__lcpp_x);}
1203
1204template <class _A1>
1205inline _LIBCPP_INLINE_VISIBILITY
1206typename std::enable_if<std::is_integral<_A1>::value, long long>::type
1207llround(_A1 __lcpp_x) _NOEXCEPT {return llround((double)__lcpp_x);}
1208
1209// log1p
1210
1211inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return log1pf(__lcpp_x);}
1212inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return log1pl(__lcpp_x);}
1213
1214template <class _A1>
1215inline _LIBCPP_INLINE_VISIBILITY
1216typename std::enable_if<std::is_integral<_A1>::value, double>::type
1217log1p(_A1 __lcpp_x) _NOEXCEPT {return log1p((double)__lcpp_x);}
1218
1219// log2
1220
1221inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return log2f(__lcpp_x);}
1222inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return log2l(__lcpp_x);}
1223
1224template <class _A1>
1225inline _LIBCPP_INLINE_VISIBILITY
1226typename std::enable_if<std::is_integral<_A1>::value, double>::type
1227log2(_A1 __lcpp_x) _NOEXCEPT {return log2((double)__lcpp_x);}
1228
1229// logb
1230
1231inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return logbf(__lcpp_x);}
1232inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return logbl(__lcpp_x);}
1233
1234template <class _A1>
1235inline _LIBCPP_INLINE_VISIBILITY
1236typename std::enable_if<std::is_integral<_A1>::value, double>::type
1237logb(_A1 __lcpp_x) _NOEXCEPT {return logb((double)__lcpp_x);}
1238
1239// lrint
1240
1241inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return lrintf(__lcpp_x);}
1242inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return lrintl(__lcpp_x);}
1243
1244template <class _A1>
1245inline _LIBCPP_INLINE_VISIBILITY
1246typename std::enable_if<std::is_integral<_A1>::value, long>::type
1247lrint(_A1 __lcpp_x) _NOEXCEPT {return lrint((double)__lcpp_x);}
1248
1249// lround
1250
1251inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return lroundf(__lcpp_x);}
1252inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return lroundl(__lcpp_x);}
1253
1254template <class _A1>
1255inline _LIBCPP_INLINE_VISIBILITY
1256typename std::enable_if<std::is_integral<_A1>::value, long>::type
1257lround(_A1 __lcpp_x) _NOEXCEPT {return lround((double)__lcpp_x);}
1258
1259// nan
1260
1261// nearbyint
1262
1263inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return nearbyintf(__lcpp_x);}
1264inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return nearbyintl(__lcpp_x);}
1265
1266template <class _A1>
1267inline _LIBCPP_INLINE_VISIBILITY
1268typename std::enable_if<std::is_integral<_A1>::value, double>::type
1269nearbyint(_A1 __lcpp_x) _NOEXCEPT {return nearbyint((double)__lcpp_x);}
1270
1271// nextafter
1272
1273inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return nextafterf(__lcpp_x, __lcpp_y);}
1274inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nextafterl(__lcpp_x, __lcpp_y);}
1275
1276template <class _A1, class _A2>
1277inline _LIBCPP_INLINE_VISIBILITY
1278typename std::__lazy_enable_if
1279<
1280 std::is_arithmetic<_A1>::value &&
1281 std::is_arithmetic<_A2>::value,
1282 std::__promote<_A1, _A2>
1283>::type
1284nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1285{
1286 typedef typename std::__promote<_A1, _A2>::type __result_type;
1287 static_assert((!(std::is_same<_A1, __result_type>::value &&
1288 std::is_same<_A2, __result_type>::value)), "");
1289 return nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1290}
1291
1292// nexttoward
1293
1294inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardf(__lcpp_x, __lcpp_y);}
1295inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardl(__lcpp_x, __lcpp_y);}
1296
1297template <class _A1>
1298inline _LIBCPP_INLINE_VISIBILITY
1299typename std::enable_if<std::is_integral<_A1>::value, double>::type
1300nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttoward((double)__lcpp_x, __lcpp_y);}
1301
1302// remainder
1303
1304inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return remainderf(__lcpp_x, __lcpp_y);}
1305inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return remainderl(__lcpp_x, __lcpp_y);}
1306
1307template <class _A1, class _A2>
1308inline _LIBCPP_INLINE_VISIBILITY
1309typename std::__lazy_enable_if
1310<
1311 std::is_arithmetic<_A1>::value &&
1312 std::is_arithmetic<_A2>::value,
1313 std::__promote<_A1, _A2>
1314>::type
1315remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
1316{
1317 typedef typename std::__promote<_A1, _A2>::type __result_type;
1318 static_assert((!(std::is_same<_A1, __result_type>::value &&
1319 std::is_same<_A2, __result_type>::value)), "");
1320 return remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
1321}
1322
1323// remquo
1324
1325inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquof(__lcpp_x, __lcpp_y, __lcpp_z);}
1326inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquol(__lcpp_x, __lcpp_y, __lcpp_z);}
1327
1328template <class _A1, class _A2>
1329inline _LIBCPP_INLINE_VISIBILITY
1330typename std::__lazy_enable_if
1331<
1332 std::is_arithmetic<_A1>::value &&
1333 std::is_arithmetic<_A2>::value,
1334 std::__promote<_A1, _A2>
1335>::type
1336remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
1337{
1338 typedef typename std::__promote<_A1, _A2>::type __result_type;
1339 static_assert((!(std::is_same<_A1, __result_type>::value &&
1340 std::is_same<_A2, __result_type>::value)), "");
1341 return remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
1342}
1343
1344// rint
1345
1346inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return rintf(__lcpp_x);}
1347inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return rintl(__lcpp_x);}
1348
1349template <class _A1>
1350inline _LIBCPP_INLINE_VISIBILITY
1351typename std::enable_if<std::is_integral<_A1>::value, double>::type
1352rint(_A1 __lcpp_x) _NOEXCEPT {return rint((double)__lcpp_x);}
1353
1354// round
1355
1356inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return roundf(__lcpp_x);}
1357inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return roundl(__lcpp_x);}
1358
1359template <class _A1>
1360inline _LIBCPP_INLINE_VISIBILITY
1361typename std::enable_if<std::is_integral<_A1>::value, double>::type
1362round(_A1 __lcpp_x) _NOEXCEPT {return round((double)__lcpp_x);}
1363
1364// scalbln
1365
1366inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnf(__lcpp_x, __lcpp_y);}
1367inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnl(__lcpp_x, __lcpp_y);}
1368
1369template <class _A1>
1370inline _LIBCPP_INLINE_VISIBILITY
1371typename std::enable_if<std::is_integral<_A1>::value, double>::type
1372scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalbln((double)__lcpp_x, __lcpp_y);}
1373
1374// scalbn
1375
1376inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnf(__lcpp_x, __lcpp_y);}
1377inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnl(__lcpp_x, __lcpp_y);}
1378
1379template <class _A1>
1380inline _LIBCPP_INLINE_VISIBILITY
1381typename std::enable_if<std::is_integral<_A1>::value, double>::type
1382scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbn((double)__lcpp_x, __lcpp_y);}
1383
1384// tgamma
1385
1386inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return tgammaf(__lcpp_x);}
1387inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return tgammal(__lcpp_x);}
1388
1389template <class _A1>
1390inline _LIBCPP_INLINE_VISIBILITY
1391typename std::enable_if<std::is_integral<_A1>::value, double>::type
1392tgamma(_A1 __lcpp_x) _NOEXCEPT {return tgamma((double)__lcpp_x);}
1393
1394// trunc
1395
1396inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return truncf(__lcpp_x);}
1397inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return truncl(__lcpp_x);}
1398
1399template <class _A1>
1400inline _LIBCPP_INLINE_VISIBILITY
1401typename std::enable_if<std::is_integral<_A1>::value, double>::type
1402trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);}
1403
1404#endif // !_LIBCPP_MSVCRT
Richard Smith524956b2015-10-08 20:40:34 +00001405
1406} // extern "C++"
1407
1408#endif // __cplusplus
1409
1410#endif // _LIBCPP_MATH_H