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