codekingpro/portable-devtools
114k
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX_MATH_H11#define _LIBCUDACXX_MATH_H12 13/*14 math.h synopsis15 16Macros:17 18 HUGE_VAL19 HUGE_VALF // C9920 HUGE_VALL // C9921 INFINITY // C9922 NAN // C9923 FP_INFINITE // C9924 FP_NAN // C9925 FP_NORMAL // C9926 FP_SUBNORMAL // C9927 FP_ZERO // C9928 FP_FAST_FMA // C9929 FP_FAST_FMAF // C9930 FP_FAST_FMAL // C9931 FP_ILOGB0 // C9932 FP_ILOGBNAN // C9933 MATH_ERRNO // C9934 MATH_ERREXCEPT // C9935 math_errhandling // C9936 37Types:38 39 float_t // C9940 double_t // C9941 42// C9043 44floating_point abs(floating_point x);45 46floating_point acos (arithmetic x);47float acosf(float x);48long double acosl(long double x);49 50floating_point asin (arithmetic x);51float asinf(float x);52long double asinl(long double x);53 54floating_point atan (arithmetic x);55float atanf(float x);56long double atanl(long double x);57 58floating_point atan2 (arithmetic y, arithmetic x);59float atan2f(float y, float x);60long double atan2l(long double y, long double x);61 62floating_point ceil (arithmetic x);63float ceilf(float x);64long double ceill(long double x);65 66floating_point cos (arithmetic x);67float cosf(float x);68long double cosl(long double x);69 70floating_point cosh (arithmetic x);71float coshf(float x);72long double coshl(long double x);73 74floating_point exp (arithmetic x);75float expf(float x);76long double expl(long double x);77 78floating_point fabs (arithmetic x);79float fabsf(float x);80long double fabsl(long double x);81 82floating_point floor (arithmetic x);83float floorf(float x);84long double floorl(long double x);85 86floating_point fmod (arithmetic x, arithmetic y);87float fmodf(float x, float y);88long double fmodl(long double x, long double y);89 90floating_point frexp (arithmetic value, int* exp);91float frexpf(float value, int* exp);92long double frexpl(long double value, int* exp);93 94floating_point ldexp (arithmetic value, int exp);95float ldexpf(float value, int exp);96long double ldexpl(long double value, int exp);97 98floating_point log (arithmetic x);99float logf(float x);100long double logl(long double x);101 102floating_point log10 (arithmetic x);103float log10f(float x);104long double log10l(long double x);105 106floating_point modf (floating_point value, floating_point* iptr);107float modff(float value, float* iptr);108long double modfl(long double value, long double* iptr);109 110floating_point pow (arithmetic x, arithmetic y);111float powf(float x, float y);112long double powl(long double x, long double y);113 114floating_point sin (arithmetic x);115float sinf(float x);116long double sinl(long double x);117 118floating_point sinh (arithmetic x);119float sinhf(float x);120long double sinhl(long double x);121 122floating_point sqrt (arithmetic x);123float sqrtf(float x);124long double sqrtl(long double x);125 126floating_point tan (arithmetic x);127float tanf(float x);128long double tanl(long double x);129 130floating_point tanh (arithmetic x);131float tanhf(float x);132long double tanhl(long double x);133 134// C99135 136bool signbit(arithmetic x);137 138int fpclassify(arithmetic x);139 140bool isfinite(arithmetic x);141bool isinf(arithmetic x);142bool isnan(arithmetic x);143bool isnormal(arithmetic x);144 145bool isgreater(arithmetic x, arithmetic y);146bool isgreaterequal(arithmetic x, arithmetic y);147bool isless(arithmetic x, arithmetic y);148bool islessequal(arithmetic x, arithmetic y);149bool islessgreater(arithmetic x, arithmetic y);150bool isunordered(arithmetic x, arithmetic y);151 152floating_point acosh (arithmetic x);153float acoshf(float x);154long double acoshl(long double x);155 156floating_point asinh (arithmetic x);157float asinhf(float x);158long double asinhl(long double x);159 160floating_point atanh (arithmetic x);161float atanhf(float x);162long double atanhl(long double x);163 164floating_point cbrt (arithmetic x);165float cbrtf(float x);166long double cbrtl(long double x);167 168floating_point copysign (arithmetic x, arithmetic y);169float copysignf(float x, float y);170long double copysignl(long double x, long double y);171 172floating_point erf (arithmetic x);173float erff(float x);174long double erfl(long double x);175 176floating_point erfc (arithmetic x);177float erfcf(float x);178long double erfcl(long double x);179 180floating_point exp2 (arithmetic x);181float exp2f(float x);182long double exp2l(long double x);183 184floating_point expm1 (arithmetic x);185float expm1f(float x);186long double expm1l(long double x);187 188floating_point fdim (arithmetic x, arithmetic y);189float fdimf(float x, float y);190long double fdiml(long double x, long double y);191 192floating_point fma (arithmetic x, arithmetic y, arithmetic z);193float fmaf(float x, float y, float z);194long double fmal(long double x, long double y, long double z);195 196floating_point fmax (arithmetic x, arithmetic y);197float fmaxf(float x, float y);198long double fmaxl(long double x, long double y);199 200floating_point fmin (arithmetic x, arithmetic y);201float fminf(float x, float y);202long double fminl(long double x, long double y);203 204floating_point hypot (arithmetic x, arithmetic y);205float hypotf(float x, float y);206long double hypotl(long double x, long double y);207 208int ilogb (arithmetic x);209int ilogbf(float x);210int ilogbl(long double x);211 212floating_point lgamma (arithmetic x);213float lgammaf(float x);214long double lgammal(long double x);215 216long long llrint (arithmetic x);217long long llrintf(float x);218long long llrintl(long double x);219 220long long llround (arithmetic x);221long long llroundf(float x);222long long llroundl(long double x);223 224floating_point log1p (arithmetic x);225float log1pf(float x);226long double log1pl(long double x);227 228floating_point log2 (arithmetic x);229float log2f(float x);230long double log2l(long double x);231 232floating_point logb (arithmetic x);233float logbf(float x);234long double logbl(long double x);235 236long lrint (arithmetic x);237long lrintf(float x);238long lrintl(long double x);239 240long lround (arithmetic x);241long lroundf(float x);242long lroundl(long double x);243 244double nan (const char* str);245float nanf(const char* str);246long double nanl(const char* str);247 248floating_point nearbyint (arithmetic x);249float nearbyintf(float x);250long double nearbyintl(long double x);251 252floating_point nextafter (arithmetic x, arithmetic y);253float nextafterf(float x, float y);254long double nextafterl(long double x, long double y);255 256floating_point nexttoward (arithmetic x, long double y);257float nexttowardf(float x, long double y);258long double nexttowardl(long double x, long double y);259 260floating_point remainder (arithmetic x, arithmetic y);261float remainderf(float x, float y);262long double remainderl(long double x, long double y);263 264floating_point remquo (arithmetic x, arithmetic y, int* pquo);265float remquof(float x, float y, int* pquo);266long double remquol(long double x, long double y, int* pquo);267 268floating_point rint (arithmetic x);269float rintf(float x);270long double rintl(long double x);271 272floating_point round (arithmetic x);273float roundf(float x);274long double roundl(long double x);275 276floating_point scalbln (arithmetic x, long ex);277float scalblnf(float x, long ex);278long double scalblnl(long double x, long ex);279 280floating_point scalbn (arithmetic x, int ex);281float scalbnf(float x, int ex);282long double scalbnl(long double x, int ex);283 284floating_point tgamma (arithmetic x);285float tgammaf(float x);286long double tgammal(long double x);287 288floating_point trunc (arithmetic x);289float truncf(float x);290long double truncl(long double x);291 292*/293 294#include <__config>295 296#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)297# pragma GCC system_header298#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)299# pragma clang system_header300#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)301# pragma system_header302#endif // no system header303 304#define _LIBCUDACXX_STDLIB_INCLUDE_NEXT305#include <stdlib.h>306 307#include_next <math.h>308 309#ifdef __cplusplus310 311// We support including .h headers inside 'extern "C"' contexts, so switch312// back to C++ linkage before including these C++ headers.313extern "C++" {314 315#include <type_traits>316#include <limits>317 318// signbit319 320#ifdef signbit321 322template <class _A1>323_LIBCUDACXX_INLINE_VISIBILITY324bool325__libcpp_signbit(_A1 __lcpp_x) noexcept326{327 return signbit(__lcpp_x);328}329 330#undef signbit331 332template <class _A1>333inline _LIBCUDACXX_INLINE_VISIBILITY334typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type335signbit(_A1 __lcpp_x) noexcept336{337 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);338}339 340template <class _A1>341inline _LIBCUDACXX_INLINE_VISIBILITY342typename std::enable_if<343 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type344signbit(_A1 __lcpp_x) noexcept345{ return __lcpp_x < 0; }346 347template <class _A1>348inline _LIBCUDACXX_INLINE_VISIBILITY349typename std::enable_if<350 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type351signbit(_A1) noexcept352{ return false; }353 354#elif defined(_LIBCUDACXX_MSVCRT)355 356template <typename _A1>357inline _LIBCUDACXX_INLINE_VISIBILITY358typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type359signbit(_A1 __lcpp_x) noexcept360{361 return ::signbit(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));362}363 364template <class _A1>365inline _LIBCUDACXX_INLINE_VISIBILITY366typename std::enable_if<367 std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type368signbit(_A1 __lcpp_x) noexcept369{ return __lcpp_x < 0; }370 371template <class _A1>372inline _LIBCUDACXX_INLINE_VISIBILITY373typename std::enable_if<374 std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type375signbit(_A1) noexcept376{ return false; }377 378#endif // signbit379 380// fpclassify381 382#ifdef fpclassify383 384template <class _A1>385_LIBCUDACXX_INLINE_VISIBILITY386int387__libcpp_fpclassify(_A1 __lcpp_x) noexcept388{389 return fpclassify(__lcpp_x);390}391 392#undef fpclassify393 394template <class _A1>395inline _LIBCUDACXX_INLINE_VISIBILITY396typename std::enable_if<std::is_floating_point<_A1>::value, int>::type397fpclassify(_A1 __lcpp_x) noexcept398{399 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);400}401 402template <class _A1>403inline _LIBCUDACXX_INLINE_VISIBILITY404typename std::enable_if<std::is_integral<_A1>::value, int>::type405fpclassify(_A1 __lcpp_x) noexcept406{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }407 408#elif defined(_LIBCUDACXX_MSVCRT)409 410template <typename _A1>411inline _LIBCUDACXX_INLINE_VISIBILITY412typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type413fpclassify(_A1 __lcpp_x) noexcept414{415 return ::fpclassify(static_cast<typename std::__promote<_A1>::type>(__lcpp_x));416}417 418template <class _A1>419inline _LIBCUDACXX_INLINE_VISIBILITY420typename std::enable_if<std::is_integral<_A1>::value, int>::type421fpclassify(_A1 __lcpp_x) noexcept422{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }423 424#endif // fpclassify425 426// isfinite427 428#ifdef isfinite429 430template <class _A1>431_LIBCUDACXX_INLINE_VISIBILITY432bool433__libcpp_isfinite(_A1 __lcpp_x) noexcept434{435 return isfinite(__lcpp_x);436}437 438#undef isfinite439 440template <class _A1>441inline _LIBCUDACXX_INLINE_VISIBILITY442typename std::enable_if<443 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,444 bool>::type445isfinite(_A1 __lcpp_x) noexcept446{447 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);448}449 450template <class _A1>451inline _LIBCUDACXX_INLINE_VISIBILITY452typename std::enable_if<453 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,454 bool>::type455isfinite(_A1) noexcept456{ return true; }457 458#endif // isfinite459 460// isinf461 462#ifdef isinf463 464template <class _A1>465_LIBCUDACXX_INLINE_VISIBILITY466bool467__libcpp_isinf(_A1 __lcpp_x) noexcept468{469 return isinf(__lcpp_x);470}471 472#undef isinf473 474template <class _A1>475inline _LIBCUDACXX_INLINE_VISIBILITY476typename std::enable_if<477 std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,478 bool>::type479isinf(_A1 __lcpp_x) noexcept480{481 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);482}483 484template <class _A1>485inline _LIBCUDACXX_INLINE_VISIBILITY486typename std::enable_if<487 std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,488 bool>::type489isinf(_A1) noexcept490{ return false; }491 492#ifdef _LIBCUDACXX_PREFERRED_OVERLOAD493inline _LIBCUDACXX_INLINE_VISIBILITY494bool495isinf(float __lcpp_x) noexcept { return __libcpp_isinf(__lcpp_x); }496 497inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_PREFERRED_OVERLOAD498bool499isinf(double __lcpp_x) noexcept { return __libcpp_isinf(__lcpp_x); }500 501inline _LIBCUDACXX_INLINE_VISIBILITY502bool503isinf(long double __lcpp_x) noexcept { return __libcpp_isinf(__lcpp_x); }504#endif505 506#endif // isinf507 508// isnan509 510#ifdef isnan511 512template <class _A1>513_LIBCUDACXX_INLINE_VISIBILITY514bool515__libcpp_isnan(_A1 __lcpp_x) noexcept516{517 return isnan(__lcpp_x);518}519 520#undef isnan521 522template <class _A1>523inline _LIBCUDACXX_INLINE_VISIBILITY524typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type525isnan(_A1 __lcpp_x) noexcept526{527 return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x);528}529 530template <class _A1>531inline _LIBCUDACXX_INLINE_VISIBILITY532typename std::enable_if<std::is_integral<_A1>::value, bool>::type533isnan(_A1) noexcept534{ return false; }535 536#ifdef _LIBCUDACXX_PREFERRED_OVERLOAD537inline _LIBCUDACXX_INLINE_VISIBILITY538bool539isnan(float __lcpp_x) noexcept { return __libcpp_isnan(__lcpp_x); }540 541inline _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_PREFERRED_OVERLOAD542bool543isnan(double __lcpp_x) noexcept { return __libcpp_isnan(__lcpp_x); }544 545inline _LIBCUDACXX_INLINE_VISIBILITY546bool547isnan(long double __lcpp_x) noexcept { return __libcpp_isnan(__lcpp_x); }548#endif549 550#endif // isnan551 552// isnormal553 554#ifdef isnormal555 556template <class _A1>557_LIBCUDACXX_INLINE_VISIBILITY558bool559__libcpp_isnormal(_A1 __lcpp_x) noexcept560{561 return isnormal(__lcpp_x);562}563 564#undef isnormal565 566template <class _A1>567inline _LIBCUDACXX_INLINE_VISIBILITY568typename std::enable_if<std::is_floating_point<_A1>::value, bool>::type569isnormal(_A1 __lcpp_x) noexcept570{571 return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x);572}573 574template <class _A1>575inline _LIBCUDACXX_INLINE_VISIBILITY576typename std::enable_if<std::is_integral<_A1>::value, bool>::type577isnormal(_A1 __lcpp_x) noexcept578{ return __lcpp_x != 0; }579 580#endif // isnormal581 582// isgreater583 584#ifdef isgreater585 586template <class _A1, class _A2>587_LIBCUDACXX_INLINE_VISIBILITY588bool589__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) noexcept590{591 return isgreater(__lcpp_x, __lcpp_y);592}593 594#undef isgreater595 596template <class _A1, class _A2>597inline _LIBCUDACXX_INLINE_VISIBILITY598typename std::enable_if599<600 std::is_arithmetic<_A1>::value &&601 std::is_arithmetic<_A2>::value,602 bool603>::type604isgreater(_A1 __lcpp_x, _A2 __lcpp_y) noexcept605{606 typedef typename std::__promote<_A1, _A2>::type type;607 return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y);608}609 610#endif // isgreater611 612// isgreaterequal613 614#ifdef isgreaterequal615 616template <class _A1, class _A2>617_LIBCUDACXX_INLINE_VISIBILITY618bool619__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) noexcept620{621 return isgreaterequal(__lcpp_x, __lcpp_y);622}623 624#undef isgreaterequal625 626template <class _A1, class _A2>627inline _LIBCUDACXX_INLINE_VISIBILITY628typename std::enable_if629<630 std::is_arithmetic<_A1>::value &&631 std::is_arithmetic<_A2>::value,632 bool633>::type634isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) noexcept635{636 typedef typename std::__promote<_A1, _A2>::type type;637 return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y);638}639 640#endif // isgreaterequal641 642// isless643 644#ifdef isless645 646template <class _A1, class _A2>647_LIBCUDACXX_INLINE_VISIBILITY648bool649__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) noexcept650{651 return isless(__lcpp_x, __lcpp_y);652}653 654#undef isless655 656template <class _A1, class _A2>657inline _LIBCUDACXX_INLINE_VISIBILITY658typename std::enable_if659<660 std::is_arithmetic<_A1>::value &&661 std::is_arithmetic<_A2>::value,662 bool663>::type664isless(_A1 __lcpp_x, _A2 __lcpp_y) noexcept665{666 typedef typename std::__promote<_A1, _A2>::type type;667 return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y);668}669 670#endif // isless671 672// islessequal673 674#ifdef islessequal675 676template <class _A1, class _A2>677_LIBCUDACXX_INLINE_VISIBILITY678bool679__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) noexcept680{681 return islessequal(__lcpp_x, __lcpp_y);682}683 684#undef islessequal685 686template <class _A1, class _A2>687inline _LIBCUDACXX_INLINE_VISIBILITY688typename std::enable_if689<690 std::is_arithmetic<_A1>::value &&691 std::is_arithmetic<_A2>::value,692 bool693>::type694islessequal(_A1 __lcpp_x, _A2 __lcpp_y) noexcept695{696 typedef typename std::__promote<_A1, _A2>::type type;697 return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y);698}699 700#endif // islessequal701 702// islessgreater703 704#ifdef islessgreater705 706template <class _A1, class _A2>707_LIBCUDACXX_INLINE_VISIBILITY708bool709__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) noexcept710{711 return islessgreater(__lcpp_x, __lcpp_y);712}713 714#undef islessgreater715 716template <class _A1, class _A2>717inline _LIBCUDACXX_INLINE_VISIBILITY718typename std::enable_if719<720 std::is_arithmetic<_A1>::value &&721 std::is_arithmetic<_A2>::value,722 bool723>::type724islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) noexcept725{726 typedef typename std::__promote<_A1, _A2>::type type;727 return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y);728}729 730#endif // islessgreater731 732// isunordered733 734#ifdef isunordered735 736template <class _A1, class _A2>737_LIBCUDACXX_INLINE_VISIBILITY738bool739__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) noexcept740{741 return isunordered(__lcpp_x, __lcpp_y);742}743 744#undef isunordered745 746template <class _A1, class _A2>747inline _LIBCUDACXX_INLINE_VISIBILITY748typename std::enable_if749<750 std::is_arithmetic<_A1>::value &&751 std::is_arithmetic<_A2>::value,752 bool753>::type754isunordered(_A1 __lcpp_x, _A2 __lcpp_y) noexcept755{756 typedef typename std::__promote<_A1, _A2>::type type;757 return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y);758}759 760#endif // isunordered761 762// abs763 764#undef abs765#undef labs766#ifndef _LIBCUDACXX_HAS_NO_LONG_LONG767#undef llabs768#endif769 770// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined771#if !defined(_LIBCUDACXX_MSVCRT) && !defined(__sun__) && !defined(_AIX)772inline _LIBCUDACXX_INLINE_VISIBILITY long abs(long __x) noexcept {773 return ::labs(__x);774}775#ifndef _LIBCUDACXX_HAS_NO_LONG_LONG776inline _LIBCUDACXX_INLINE_VISIBILITY long long abs(long long __x) noexcept {777 return ::llabs(__x);778}779#endif // _LIBCUDACXX_HAS_NO_LONG_LONG780#endif // !defined(_LIBCUDACXX_MSVCRT) && !defined(__sun__) && !defined(_AIX)781 782 783#if !(defined(_AIX) || defined(__sun__))784inline _LIBCUDACXX_INLINE_VISIBILITY float abs(float __lcpp_x) noexcept {785 return ::fabsf(__lcpp_x);786}787 788inline _LIBCUDACXX_INLINE_VISIBILITY double abs(double __lcpp_x) noexcept {789 return ::fabs(__lcpp_x);790}791 792inline _LIBCUDACXX_INLINE_VISIBILITY long double793abs(long double __lcpp_x) noexcept {794 return ::fabsl(__lcpp_x);795}796#endif // !(defined(_AIX) || defined(__sun__))797 798// div799 800#undef div801#undef ldiv802#ifndef _LIBCUDACXX_HAS_NO_LONG_LONG803#undef lldiv804#endif805 806// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined807#if !defined(_LIBCUDACXX_MSVCRT) && !defined(__sun__) && !defined(_AIX)808inline _LIBCUDACXX_INLINE_VISIBILITY ldiv_t div(long __x, long __y) noexcept {809 return ::ldiv(__x, __y);810}811#ifndef _LIBCUDACXX_HAS_NO_LONG_LONG812inline _LIBCUDACXX_INLINE_VISIBILITY lldiv_t div(long long __x,813 long long __y) noexcept {814 return ::lldiv(__x, __y);815}816#endif // _LIBCUDACXX_HAS_NO_LONG_LONG817#endif // _LIBCUDACXX_MSVCRT / __sun__ / _AIX818 819// acos820 821#if !(defined(_AIX) || defined(__sun__))822inline _LIBCUDACXX_INLINE_VISIBILITY float acos(float __lcpp_x) noexcept {return ::acosf(__lcpp_x);}823inline _LIBCUDACXX_INLINE_VISIBILITY long double acos(long double __lcpp_x) noexcept {return ::acosl(__lcpp_x);}824#endif825 826template <class _A1>827inline _LIBCUDACXX_INLINE_VISIBILITY828typename std::enable_if<std::is_integral<_A1>::value, double>::type829acos(_A1 __lcpp_x) noexcept {return ::acos((double)__lcpp_x);}830 831// asin832 833#if !(defined(_AIX) || defined(__sun__))834inline _LIBCUDACXX_INLINE_VISIBILITY float asin(float __lcpp_x) noexcept {return ::asinf(__lcpp_x);}835inline _LIBCUDACXX_INLINE_VISIBILITY long double asin(long double __lcpp_x) noexcept {return ::asinl(__lcpp_x);}836#endif837 838template <class _A1>839inline _LIBCUDACXX_INLINE_VISIBILITY840typename std::enable_if<std::is_integral<_A1>::value, double>::type841asin(_A1 __lcpp_x) noexcept {return ::asin((double)__lcpp_x);}842 843// atan844 845#if !(defined(_AIX) || defined(__sun__))846inline _LIBCUDACXX_INLINE_VISIBILITY float atan(float __lcpp_x) noexcept {return ::atanf(__lcpp_x);}847inline _LIBCUDACXX_INLINE_VISIBILITY long double atan(long double __lcpp_x) noexcept {return ::atanl(__lcpp_x);}848#endif849 850template <class _A1>851inline _LIBCUDACXX_INLINE_VISIBILITY852typename std::enable_if<std::is_integral<_A1>::value, double>::type853atan(_A1 __lcpp_x) noexcept {return ::atan((double)__lcpp_x);}854 855// atan2856 857#if !(defined(_AIX) || defined(__sun__))858inline _LIBCUDACXX_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) noexcept {return ::atan2f(__lcpp_y, __lcpp_x);}859inline _LIBCUDACXX_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) noexcept {return ::atan2l(__lcpp_y, __lcpp_x);}860#endif861 862template <class _A1, class _A2>863inline _LIBCUDACXX_INLINE_VISIBILITY864typename std::_EnableIf865<866 std::is_arithmetic<_A1>::value &&867 std::is_arithmetic<_A2>::value,868 std::__promote<_A1, _A2>869>::type870atan2(_A1 __lcpp_y, _A2 __lcpp_x) noexcept871{872 typedef typename std::__promote<_A1, _A2>::type __result_type;873 static_assert((!(std::_IsSame<_A1, __result_type>::value &&874 std::_IsSame<_A2, __result_type>::value)), "");875 return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);876}877 878// ceil879 880#if !(defined(_AIX) || defined(__sun__))881inline _LIBCUDACXX_INLINE_VISIBILITY float ceil(float __lcpp_x) noexcept {return ::ceilf(__lcpp_x);}882inline _LIBCUDACXX_INLINE_VISIBILITY long double ceil(long double __lcpp_x) noexcept {return ::ceill(__lcpp_x);}883#endif884 885template <class _A1>886inline _LIBCUDACXX_INLINE_VISIBILITY887typename std::enable_if<std::is_integral<_A1>::value, double>::type888ceil(_A1 __lcpp_x) noexcept {return ::ceil((double)__lcpp_x);}889 890// cos891 892#if !(defined(_AIX) || defined(__sun__))893inline _LIBCUDACXX_INLINE_VISIBILITY float cos(float __lcpp_x) noexcept {return ::cosf(__lcpp_x);}894inline _LIBCUDACXX_INLINE_VISIBILITY long double cos(long double __lcpp_x) noexcept {return ::cosl(__lcpp_x);}895#endif896 897template <class _A1>898inline _LIBCUDACXX_INLINE_VISIBILITY899typename std::enable_if<std::is_integral<_A1>::value, double>::type900cos(_A1 __lcpp_x) noexcept {return ::cos((double)__lcpp_x);}901 902// cosh903 904#if !(defined(_AIX) || defined(__sun__))905inline _LIBCUDACXX_INLINE_VISIBILITY float cosh(float __lcpp_x) noexcept {return ::coshf(__lcpp_x);}906inline _LIBCUDACXX_INLINE_VISIBILITY long double cosh(long double __lcpp_x) noexcept {return ::coshl(__lcpp_x);}907#endif908 909template <class _A1>910inline _LIBCUDACXX_INLINE_VISIBILITY911typename std::enable_if<std::is_integral<_A1>::value, double>::type912cosh(_A1 __lcpp_x) noexcept {return ::cosh((double)__lcpp_x);}913 914// exp915 916#if !(defined(_AIX) || defined(__sun__))917inline _LIBCUDACXX_INLINE_VISIBILITY float exp(float __lcpp_x) noexcept {return ::expf(__lcpp_x);}918inline _LIBCUDACXX_INLINE_VISIBILITY long double exp(long double __lcpp_x) noexcept {return ::expl(__lcpp_x);}919#endif920 921template <class _A1>922inline _LIBCUDACXX_INLINE_VISIBILITY923typename std::enable_if<std::is_integral<_A1>::value, double>::type924exp(_A1 __lcpp_x) noexcept {return ::exp((double)__lcpp_x);}925 926// fabs927 928#if !(defined(_AIX) || defined(__sun__))929inline _LIBCUDACXX_INLINE_VISIBILITY float fabs(float __lcpp_x) noexcept {return ::fabsf(__lcpp_x);}930inline _LIBCUDACXX_INLINE_VISIBILITY long double fabs(long double __lcpp_x) noexcept {return ::fabsl(__lcpp_x);}931#endif932 933template <class _A1>934inline _LIBCUDACXX_INLINE_VISIBILITY935typename std::enable_if<std::is_integral<_A1>::value, double>::type936fabs(_A1 __lcpp_x) noexcept {return ::fabs((double)__lcpp_x);}937 938// floor939 940#if !(defined(_AIX) || defined(__sun__))941inline _LIBCUDACXX_INLINE_VISIBILITY float floor(float __lcpp_x) noexcept {return ::floorf(__lcpp_x);}942inline _LIBCUDACXX_INLINE_VISIBILITY long double floor(long double __lcpp_x) noexcept {return ::floorl(__lcpp_x);}943#endif944 945template <class _A1>946inline _LIBCUDACXX_INLINE_VISIBILITY947typename std::enable_if<std::is_integral<_A1>::value, double>::type948floor(_A1 __lcpp_x) noexcept {return ::floor((double)__lcpp_x);}949 950// fmod951 952#if !(defined(_AIX) || defined(__sun__))953inline _LIBCUDACXX_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) noexcept {return ::fmodf(__lcpp_x, __lcpp_y);}954inline _LIBCUDACXX_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) noexcept {return ::fmodl(__lcpp_x, __lcpp_y);}955#endif956 957template <class _A1, class _A2>958inline _LIBCUDACXX_INLINE_VISIBILITY959typename std::_EnableIf960<961 std::is_arithmetic<_A1>::value &&962 std::is_arithmetic<_A2>::value,963 std::__promote<_A1, _A2>964>::type965fmod(_A1 __lcpp_x, _A2 __lcpp_y) noexcept966{967 typedef typename std::__promote<_A1, _A2>::type __result_type;968 static_assert((!(std::_IsSame<_A1, __result_type>::value &&969 std::_IsSame<_A2, __result_type>::value)), "");970 return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);971}972 973// frexp974 975#if !(defined(_AIX) || defined(__sun__))976inline _LIBCUDACXX_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) noexcept {return ::frexpf(__lcpp_x, __lcpp_e);}977inline _LIBCUDACXX_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) noexcept {return ::frexpl(__lcpp_x, __lcpp_e);}978#endif979 980template <class _A1>981inline _LIBCUDACXX_INLINE_VISIBILITY982typename std::enable_if<std::is_integral<_A1>::value, double>::type983frexp(_A1 __lcpp_x, int* __lcpp_e) noexcept {return ::frexp((double)__lcpp_x, __lcpp_e);}984 985// ldexp986 987#if !(defined(_AIX) || defined(__sun__))988inline _LIBCUDACXX_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) noexcept {return ::ldexpf(__lcpp_x, __lcpp_e);}989inline _LIBCUDACXX_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) noexcept {return ::ldexpl(__lcpp_x, __lcpp_e);}990#endif991 992template <class _A1>993inline _LIBCUDACXX_INLINE_VISIBILITY994typename std::enable_if<std::is_integral<_A1>::value, double>::type995ldexp(_A1 __lcpp_x, int __lcpp_e) noexcept {return ::ldexp((double)__lcpp_x, __lcpp_e);}996 997// log998 999#if !(defined(_AIX) || defined(__sun__))1000inline _LIBCUDACXX_INLINE_VISIBILITY float log(float __lcpp_x) noexcept {return ::logf(__lcpp_x);}1001inline _LIBCUDACXX_INLINE_VISIBILITY long double log(long double __lcpp_x) noexcept {return ::logl(__lcpp_x);}1002#endif1003 1004template <class _A1>1005inline _LIBCUDACXX_INLINE_VISIBILITY1006typename std::enable_if<std::is_integral<_A1>::value, double>::type1007log(_A1 __lcpp_x) noexcept {return ::log((double)__lcpp_x);}1008 1009// log101010 1011#if !(defined(_AIX) || defined(__sun__))1012inline _LIBCUDACXX_INLINE_VISIBILITY float log10(float __lcpp_x) noexcept {return ::log10f(__lcpp_x);}1013inline _LIBCUDACXX_INLINE_VISIBILITY long double log10(long double __lcpp_x) noexcept {return ::log10l(__lcpp_x);}1014#endif1015 1016template <class _A1>1017inline _LIBCUDACXX_INLINE_VISIBILITY1018typename std::enable_if<std::is_integral<_A1>::value, double>::type1019log10(_A1 __lcpp_x) noexcept {return ::log10((double)__lcpp_x);}1020 1021// modf1022 1023#if !(defined(_AIX) || defined(__sun__))1024inline _LIBCUDACXX_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) noexcept {return ::modff(__lcpp_x, __lcpp_y);}1025inline _LIBCUDACXX_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) noexcept {return ::modfl(__lcpp_x, __lcpp_y);}1026#endif1027 1028// pow1029 1030#if !(defined(_AIX) || defined(__sun__))1031inline _LIBCUDACXX_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) noexcept {return ::powf(__lcpp_x, __lcpp_y);}1032inline _LIBCUDACXX_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) noexcept {return ::powl(__lcpp_x, __lcpp_y);}1033#endif1034 1035template <class _A1, class _A2>1036inline _LIBCUDACXX_INLINE_VISIBILITY1037typename std::_EnableIf1038<1039 std::is_arithmetic<_A1>::value &&1040 std::is_arithmetic<_A2>::value,1041 std::__promote<_A1, _A2>1042>::type1043pow(_A1 __lcpp_x, _A2 __lcpp_y) noexcept1044{1045 typedef typename std::__promote<_A1, _A2>::type __result_type;1046 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1047 std::_IsSame<_A2, __result_type>::value)), "");1048 return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);1049}1050 1051// sin1052 1053#if !(defined(_AIX) || defined(__sun__))1054inline _LIBCUDACXX_INLINE_VISIBILITY float sin(float __lcpp_x) noexcept {return ::sinf(__lcpp_x);}1055inline _LIBCUDACXX_INLINE_VISIBILITY long double sin(long double __lcpp_x) noexcept {return ::sinl(__lcpp_x);}1056#endif1057 1058template <class _A1>1059inline _LIBCUDACXX_INLINE_VISIBILITY1060typename std::enable_if<std::is_integral<_A1>::value, double>::type1061sin(_A1 __lcpp_x) noexcept {return ::sin((double)__lcpp_x);}1062 1063// sinh1064 1065#if !(defined(_AIX) || defined(__sun__))1066inline _LIBCUDACXX_INLINE_VISIBILITY float sinh(float __lcpp_x) noexcept {return ::sinhf(__lcpp_x);}1067inline _LIBCUDACXX_INLINE_VISIBILITY long double sinh(long double __lcpp_x) noexcept {return ::sinhl(__lcpp_x);}1068#endif1069 1070template <class _A1>1071inline _LIBCUDACXX_INLINE_VISIBILITY1072typename std::enable_if<std::is_integral<_A1>::value, double>::type1073sinh(_A1 __lcpp_x) noexcept {return ::sinh((double)__lcpp_x);}1074 1075// sqrt1076 1077#if !(defined(_AIX) || defined(__sun__))1078inline _LIBCUDACXX_INLINE_VISIBILITY float sqrt(float __lcpp_x) noexcept {return ::sqrtf(__lcpp_x);}1079inline _LIBCUDACXX_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) noexcept {return ::sqrtl(__lcpp_x);}1080#endif1081 1082template <class _A1>1083inline _LIBCUDACXX_INLINE_VISIBILITY1084typename std::enable_if<std::is_integral<_A1>::value, double>::type1085sqrt(_A1 __lcpp_x) noexcept {return ::sqrt((double)__lcpp_x);}1086 1087// tan1088 1089#if !(defined(_AIX) || defined(__sun__))1090inline _LIBCUDACXX_INLINE_VISIBILITY float tan(float __lcpp_x) noexcept {return ::tanf(__lcpp_x);}1091inline _LIBCUDACXX_INLINE_VISIBILITY long double tan(long double __lcpp_x) noexcept {return ::tanl(__lcpp_x);}1092#endif1093 1094template <class _A1>1095inline _LIBCUDACXX_INLINE_VISIBILITY1096typename std::enable_if<std::is_integral<_A1>::value, double>::type1097tan(_A1 __lcpp_x) noexcept {return ::tan((double)__lcpp_x);}1098 1099// tanh1100 1101#if !(defined(_AIX) || defined(__sun__))1102inline _LIBCUDACXX_INLINE_VISIBILITY float tanh(float __lcpp_x) noexcept {return ::tanhf(__lcpp_x);}1103inline _LIBCUDACXX_INLINE_VISIBILITY long double tanh(long double __lcpp_x) noexcept {return ::tanhl(__lcpp_x);}1104#endif1105 1106template <class _A1>1107inline _LIBCUDACXX_INLINE_VISIBILITY1108typename std::enable_if<std::is_integral<_A1>::value, double>::type1109tanh(_A1 __lcpp_x) noexcept {return ::tanh((double)__lcpp_x);}1110 1111// acosh1112 1113inline _LIBCUDACXX_INLINE_VISIBILITY float acosh(float __lcpp_x) noexcept {return ::acoshf(__lcpp_x);}1114inline _LIBCUDACXX_INLINE_VISIBILITY long double acosh(long double __lcpp_x) noexcept {return ::acoshl(__lcpp_x);}1115 1116template <class _A1>1117inline _LIBCUDACXX_INLINE_VISIBILITY1118typename std::enable_if<std::is_integral<_A1>::value, double>::type1119acosh(_A1 __lcpp_x) noexcept {return ::acosh((double)__lcpp_x);}1120 1121// asinh1122 1123inline _LIBCUDACXX_INLINE_VISIBILITY float asinh(float __lcpp_x) noexcept {return ::asinhf(__lcpp_x);}1124inline _LIBCUDACXX_INLINE_VISIBILITY long double asinh(long double __lcpp_x) noexcept {return ::asinhl(__lcpp_x);}1125 1126template <class _A1>1127inline _LIBCUDACXX_INLINE_VISIBILITY1128typename std::enable_if<std::is_integral<_A1>::value, double>::type1129asinh(_A1 __lcpp_x) noexcept {return ::asinh((double)__lcpp_x);}1130 1131// atanh1132 1133inline _LIBCUDACXX_INLINE_VISIBILITY float atanh(float __lcpp_x) noexcept {return ::atanhf(__lcpp_x);}1134inline _LIBCUDACXX_INLINE_VISIBILITY long double atanh(long double __lcpp_x) noexcept {return ::atanhl(__lcpp_x);}1135 1136template <class _A1>1137inline _LIBCUDACXX_INLINE_VISIBILITY1138typename std::enable_if<std::is_integral<_A1>::value, double>::type1139atanh(_A1 __lcpp_x) noexcept {return ::atanh((double)__lcpp_x);}1140 1141// cbrt1142 1143inline _LIBCUDACXX_INLINE_VISIBILITY float cbrt(float __lcpp_x) noexcept {return ::cbrtf(__lcpp_x);}1144inline _LIBCUDACXX_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) noexcept {return ::cbrtl(__lcpp_x);}1145 1146template <class _A1>1147inline _LIBCUDACXX_INLINE_VISIBILITY1148typename std::enable_if<std::is_integral<_A1>::value, double>::type1149cbrt(_A1 __lcpp_x) noexcept {return ::cbrt((double)__lcpp_x);}1150 1151// copysign1152 1153inline _LIBCUDACXX_INLINE_VISIBILITY float copysign(float __lcpp_x,1154 float __lcpp_y) noexcept {1155 return ::copysignf(__lcpp_x, __lcpp_y);1156}1157inline _LIBCUDACXX_INLINE_VISIBILITY long double1158copysign(long double __lcpp_x, long double __lcpp_y) noexcept {1159 return ::copysignl(__lcpp_x, __lcpp_y);1160}1161 1162template <class _A1, class _A2>1163inline _LIBCUDACXX_INLINE_VISIBILITY1164typename std::_EnableIf1165<1166 std::is_arithmetic<_A1>::value &&1167 std::is_arithmetic<_A2>::value,1168 std::__promote<_A1, _A2>1169>::type1170copysign(_A1 __lcpp_x, _A2 __lcpp_y) noexcept1171{1172 typedef typename std::__promote<_A1, _A2>::type __result_type;1173 static_assert((!(std::_IsSame<_A1, __result_type>::value &&1174 std::_IsSame<_A2, __result_type>::value)), "");1175 return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);1176}1177 1178// erf1179 1180inline _LIBCUDACXX_INLINE_VISIBILITY float erf(float __lcpp_x) noexcept {return ::erff(__lcpp_x);}1181inline _LIBCUDACXX_INLINE_VISIBILITY long double erf(long double __lcpp_x) noexcept {return ::erfl(__lcpp_x);}1182 1183template <class _A1>1184inline _LIBCUDACXX_INLINE_VISIBILITY1185typename std::enable_if<std::is_integral<_A1>::value, double>::type1186erf(_A1 __lcpp_x) noexcept {return ::erf((double)__lcpp_x);}1187 1188// erfc1189 1190inline _LIBCUDACXX_INLINE_VISIBILITY float erfc(float __lcpp_x) noexcept {return ::erfcf(__lcpp_x);}1191inline _LIBCUDACXX_INLINE_VISIBILITY long double erfc(long double __lcpp_x) noexcept {return ::erfcl(__lcpp_x);}1192 1193template <class _A1>1194inline _LIBCUDACXX_INLINE_VISIBILITY1195typename std::enable_if<std::is_integral<_A1>::value, double>::type1196erfc(_A1 __lcpp_x) noexcept {return ::erfc((double)__lcpp_x);}1197 1198// exp21199 1200inline _LIBCUDACXX_INLINE_VISIBILITY float exp2(float __lcpp_x) noexcept {return ::exp2f(__lcpp_x);}