|
|
|||
File indexing completed on 2026-05-03 08:14:08
0001 // -*- C++ -*- 0002 //===----------------------------------------------------------------------===// 0003 // 0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0005 // See https://llvm.org/LICENSE.txt for license information. 0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0007 // 0008 //===----------------------------------------------------------------------===// 0009 0010 #ifndef _LIBCPP_MATH_H 0011 # define _LIBCPP_MATH_H 0012 0013 /* 0014 math.h synopsis 0015 0016 Macros: 0017 0018 HUGE_VAL 0019 HUGE_VALF // C99 0020 HUGE_VALL // C99 0021 INFINITY // C99 0022 NAN // C99 0023 FP_INFINITE // C99 0024 FP_NAN // C99 0025 FP_NORMAL // C99 0026 FP_SUBNORMAL // C99 0027 FP_ZERO // C99 0028 FP_FAST_FMA // C99 0029 FP_FAST_FMAF // C99 0030 FP_FAST_FMAL // C99 0031 FP_ILOGB0 // C99 0032 FP_ILOGBNAN // C99 0033 MATH_ERRNO // C99 0034 MATH_ERREXCEPT // C99 0035 math_errhandling // C99 0036 0037 Types: 0038 0039 float_t // C99 0040 double_t // C99 0041 0042 // C90 0043 0044 floating_point abs(floating_point x); 0045 0046 floating_point acos (arithmetic x); 0047 float acosf(float x); 0048 long double acosl(long double x); 0049 0050 floating_point asin (arithmetic x); 0051 float asinf(float x); 0052 long double asinl(long double x); 0053 0054 floating_point atan (arithmetic x); 0055 float atanf(float x); 0056 long double atanl(long double x); 0057 0058 floating_point atan2 (arithmetic y, arithmetic x); 0059 float atan2f(float y, float x); 0060 long double atan2l(long double y, long double x); 0061 0062 floating_point ceil (arithmetic x); 0063 float ceilf(float x); 0064 long double ceill(long double x); 0065 0066 floating_point cos (arithmetic x); 0067 float cosf(float x); 0068 long double cosl(long double x); 0069 0070 floating_point cosh (arithmetic x); 0071 float coshf(float x); 0072 long double coshl(long double x); 0073 0074 floating_point exp (arithmetic x); 0075 float expf(float x); 0076 long double expl(long double x); 0077 0078 floating_point fabs (arithmetic x); 0079 float fabsf(float x); 0080 long double fabsl(long double x); 0081 0082 floating_point floor (arithmetic x); 0083 float floorf(float x); 0084 long double floorl(long double x); 0085 0086 floating_point fmod (arithmetic x, arithmetic y); 0087 float fmodf(float x, float y); 0088 long double fmodl(long double x, long double y); 0089 0090 floating_point frexp (arithmetic value, int* exp); 0091 float frexpf(float value, int* exp); 0092 long double frexpl(long double value, int* exp); 0093 0094 floating_point ldexp (arithmetic value, int exp); 0095 float ldexpf(float value, int exp); 0096 long double ldexpl(long double value, int exp); 0097 0098 floating_point log (arithmetic x); 0099 float logf(float x); 0100 long double logl(long double x); 0101 0102 floating_point log10 (arithmetic x); 0103 float log10f(float x); 0104 long double log10l(long double x); 0105 0106 floating_point modf (floating_point value, floating_point* iptr); 0107 float modff(float value, float* iptr); 0108 long double modfl(long double value, long double* iptr); 0109 0110 floating_point pow (arithmetic x, arithmetic y); 0111 float powf(float x, float y); 0112 long double powl(long double x, long double y); 0113 0114 floating_point sin (arithmetic x); 0115 float sinf(float x); 0116 long double sinl(long double x); 0117 0118 floating_point sinh (arithmetic x); 0119 float sinhf(float x); 0120 long double sinhl(long double x); 0121 0122 floating_point sqrt (arithmetic x); 0123 float sqrtf(float x); 0124 long double sqrtl(long double x); 0125 0126 floating_point tan (arithmetic x); 0127 float tanf(float x); 0128 long double tanl(long double x); 0129 0130 floating_point tanh (arithmetic x); 0131 float tanhf(float x); 0132 long double tanhl(long double x); 0133 0134 // C99 0135 0136 bool signbit(arithmetic x); 0137 0138 int fpclassify(arithmetic x); 0139 0140 bool isfinite(arithmetic x); 0141 bool isinf(arithmetic x); 0142 bool isnan(arithmetic x); 0143 bool isnormal(arithmetic x); 0144 0145 bool isgreater(arithmetic x, arithmetic y); 0146 bool isgreaterequal(arithmetic x, arithmetic y); 0147 bool isless(arithmetic x, arithmetic y); 0148 bool islessequal(arithmetic x, arithmetic y); 0149 bool islessgreater(arithmetic x, arithmetic y); 0150 bool isunordered(arithmetic x, arithmetic y); 0151 0152 floating_point acosh (arithmetic x); 0153 float acoshf(float x); 0154 long double acoshl(long double x); 0155 0156 floating_point asinh (arithmetic x); 0157 float asinhf(float x); 0158 long double asinhl(long double x); 0159 0160 floating_point atanh (arithmetic x); 0161 float atanhf(float x); 0162 long double atanhl(long double x); 0163 0164 floating_point cbrt (arithmetic x); 0165 float cbrtf(float x); 0166 long double cbrtl(long double x); 0167 0168 floating_point copysign (arithmetic x, arithmetic y); 0169 float copysignf(float x, float y); 0170 long double copysignl(long double x, long double y); 0171 0172 floating_point erf (arithmetic x); 0173 float erff(float x); 0174 long double erfl(long double x); 0175 0176 floating_point erfc (arithmetic x); 0177 float erfcf(float x); 0178 long double erfcl(long double x); 0179 0180 floating_point exp2 (arithmetic x); 0181 float exp2f(float x); 0182 long double exp2l(long double x); 0183 0184 floating_point expm1 (arithmetic x); 0185 float expm1f(float x); 0186 long double expm1l(long double x); 0187 0188 floating_point fdim (arithmetic x, arithmetic y); 0189 float fdimf(float x, float y); 0190 long double fdiml(long double x, long double y); 0191 0192 floating_point fma (arithmetic x, arithmetic y, arithmetic z); 0193 float fmaf(float x, float y, float z); 0194 long double fmal(long double x, long double y, long double z); 0195 0196 floating_point fmax (arithmetic x, arithmetic y); 0197 float fmaxf(float x, float y); 0198 long double fmaxl(long double x, long double y); 0199 0200 floating_point fmin (arithmetic x, arithmetic y); 0201 float fminf(float x, float y); 0202 long double fminl(long double x, long double y); 0203 0204 floating_point hypot (arithmetic x, arithmetic y); 0205 float hypotf(float x, float y); 0206 long double hypotl(long double x, long double y); 0207 0208 int ilogb (arithmetic x); 0209 int ilogbf(float x); 0210 int ilogbl(long double x); 0211 0212 floating_point lgamma (arithmetic x); 0213 float lgammaf(float x); 0214 long double lgammal(long double x); 0215 0216 long long llrint (arithmetic x); 0217 long long llrintf(float x); 0218 long long llrintl(long double x); 0219 0220 long long llround (arithmetic x); 0221 long long llroundf(float x); 0222 long long llroundl(long double x); 0223 0224 floating_point log1p (arithmetic x); 0225 float log1pf(float x); 0226 long double log1pl(long double x); 0227 0228 floating_point log2 (arithmetic x); 0229 float log2f(float x); 0230 long double log2l(long double x); 0231 0232 floating_point logb (arithmetic x); 0233 float logbf(float x); 0234 long double logbl(long double x); 0235 0236 long lrint (arithmetic x); 0237 long lrintf(float x); 0238 long lrintl(long double x); 0239 0240 long lround (arithmetic x); 0241 long lroundf(float x); 0242 long lroundl(long double x); 0243 0244 double nan (const char* str); 0245 float nanf(const char* str); 0246 long double nanl(const char* str); 0247 0248 floating_point nearbyint (arithmetic x); 0249 float nearbyintf(float x); 0250 long double nearbyintl(long double x); 0251 0252 floating_point nextafter (arithmetic x, arithmetic y); 0253 float nextafterf(float x, float y); 0254 long double nextafterl(long double x, long double y); 0255 0256 floating_point nexttoward (arithmetic x, long double y); 0257 float nexttowardf(float x, long double y); 0258 long double nexttowardl(long double x, long double y); 0259 0260 floating_point remainder (arithmetic x, arithmetic y); 0261 float remainderf(float x, float y); 0262 long double remainderl(long double x, long double y); 0263 0264 floating_point remquo (arithmetic x, arithmetic y, int* pquo); 0265 float remquof(float x, float y, int* pquo); 0266 long double remquol(long double x, long double y, int* pquo); 0267 0268 floating_point rint (arithmetic x); 0269 float rintf(float x); 0270 long double rintl(long double x); 0271 0272 floating_point round (arithmetic x); 0273 float roundf(float x); 0274 long double roundl(long double x); 0275 0276 floating_point scalbln (arithmetic x, long ex); 0277 float scalblnf(float x, long ex); 0278 long double scalblnl(long double x, long ex); 0279 0280 floating_point scalbn (arithmetic x, int ex); 0281 float scalbnf(float x, int ex); 0282 long double scalbnl(long double x, int ex); 0283 0284 floating_point tgamma (arithmetic x); 0285 float tgammaf(float x); 0286 long double tgammal(long double x); 0287 0288 floating_point trunc (arithmetic x); 0289 float truncf(float x); 0290 long double truncl(long double x); 0291 0292 */ 0293 0294 # if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 0295 # include <__cxx03/math.h> 0296 # else 0297 # include <__config> 0298 0299 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 0300 # pragma GCC system_header 0301 # endif 0302 0303 # if __has_include_next(<math.h>) 0304 # include_next <math.h> 0305 # endif 0306 0307 # ifdef __cplusplus 0308 0309 // We support including .h headers inside 'extern "C"' contexts, so switch 0310 // back to C++ linkage before including these C++ headers. 0311 extern "C++" { 0312 0313 # ifdef fpclassify 0314 # undef fpclassify 0315 # endif 0316 0317 # ifdef signbit 0318 # undef signbit 0319 # endif 0320 0321 # ifdef isfinite 0322 # undef isfinite 0323 # endif 0324 0325 # ifdef isinf 0326 # undef isinf 0327 # endif 0328 0329 # ifdef isnan 0330 # undef isnan 0331 # endif 0332 0333 # ifdef isnormal 0334 # undef isnormal 0335 # endif 0336 0337 # ifdef isgreater 0338 # undef isgreater 0339 # endif 0340 0341 # ifdef isgreaterequal 0342 # undef isgreaterequal 0343 # endif 0344 0345 # ifdef isless 0346 # undef isless 0347 # endif 0348 0349 # ifdef islessequal 0350 # undef islessequal 0351 # endif 0352 0353 # ifdef islessgreater 0354 # undef islessgreater 0355 # endif 0356 0357 # ifdef isunordered 0358 # undef isunordered 0359 # endif 0360 0361 # include <__math/abs.h> 0362 # include <__math/copysign.h> 0363 # include <__math/error_functions.h> 0364 # include <__math/exponential_functions.h> 0365 # include <__math/fdim.h> 0366 # include <__math/fma.h> 0367 # include <__math/gamma.h> 0368 # include <__math/hyperbolic_functions.h> 0369 # include <__math/hypot.h> 0370 # include <__math/inverse_hyperbolic_functions.h> 0371 # include <__math/inverse_trigonometric_functions.h> 0372 # include <__math/logarithms.h> 0373 # include <__math/min_max.h> 0374 # include <__math/modulo.h> 0375 # include <__math/remainder.h> 0376 # include <__math/roots.h> 0377 # include <__math/rounding_functions.h> 0378 # include <__math/traits.h> 0379 # include <__math/trigonometric_functions.h> 0380 # include <__type_traits/enable_if.h> 0381 # include <__type_traits/is_floating_point.h> 0382 # include <__type_traits/is_integral.h> 0383 # include <stdlib.h> 0384 0385 // fpclassify relies on implementation-defined constants, so we can't move it to a detail header 0386 _LIBCPP_BEGIN_NAMESPACE_STD 0387 0388 namespace __math { 0389 0390 // fpclassify 0391 0392 // template on non-double overloads to make them weaker than same overloads from MSVC runtime 0393 template <class = int> 0394 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT { 0395 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); 0396 } 0397 0398 template <class = int> 0399 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT { 0400 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); 0401 } 0402 0403 template <class = int> 0404 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT { 0405 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); 0406 } 0407 0408 template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> 0409 [[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { 0410 return __x == 0 ? FP_ZERO : FP_NORMAL; 0411 } 0412 0413 } // namespace __math 0414 0415 _LIBCPP_END_NAMESPACE_STD 0416 0417 using std::__math::fpclassify; 0418 using std::__math::signbit; 0419 0420 // The MSVC runtime already provides these functions as templates 0421 # ifndef _LIBCPP_MSVCRT 0422 using std::__math::isfinite; 0423 using std::__math::isgreater; 0424 using std::__math::isgreaterequal; 0425 using std::__math::isinf; 0426 using std::__math::isless; 0427 using std::__math::islessequal; 0428 using std::__math::islessgreater; 0429 using std::__math::isnan; 0430 using std::__math::isnormal; 0431 using std::__math::isunordered; 0432 # endif // _LIBCPP_MSVCRT 0433 0434 // abs 0435 // 0436 // handled in stdlib.h 0437 0438 // div 0439 // 0440 // handled in stdlib.h 0441 0442 // We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math 0443 // functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads 0444 // templates. Functions are preferred over function templates during overload resolution, which means that our overload 0445 // will only be selected when the C library doesn't provide one. 0446 0447 using std::__math::acos; 0448 using std::__math::acosh; 0449 using std::__math::asin; 0450 using std::__math::asinh; 0451 using std::__math::atan; 0452 using std::__math::atan2; 0453 using std::__math::atanh; 0454 using std::__math::cbrt; 0455 using std::__math::ceil; 0456 using std::__math::copysign; 0457 using std::__math::cos; 0458 using std::__math::cosh; 0459 using std::__math::erf; 0460 using std::__math::erfc; 0461 using std::__math::exp; 0462 using std::__math::exp2; 0463 using std::__math::expm1; 0464 using std::__math::fabs; 0465 using std::__math::fdim; 0466 using std::__math::floor; 0467 using std::__math::fma; 0468 using std::__math::fmax; 0469 using std::__math::fmin; 0470 using std::__math::fmod; 0471 using std::__math::frexp; 0472 using std::__math::hypot; 0473 using std::__math::ilogb; 0474 using std::__math::ldexp; 0475 using std::__math::lgamma; 0476 using std::__math::llrint; 0477 using std::__math::llround; 0478 using std::__math::log; 0479 using std::__math::log10; 0480 using std::__math::log1p; 0481 using std::__math::log2; 0482 using std::__math::logb; 0483 using std::__math::lrint; 0484 using std::__math::lround; 0485 using std::__math::modf; 0486 using std::__math::nearbyint; 0487 using std::__math::nextafter; 0488 using std::__math::nexttoward; 0489 using std::__math::pow; 0490 using std::__math::remainder; 0491 using std::__math::remquo; 0492 using std::__math::rint; 0493 using std::__math::round; 0494 using std::__math::scalbln; 0495 using std::__math::scalbn; 0496 using std::__math::signbit; 0497 using std::__math::sin; 0498 using std::__math::sinh; 0499 using std::__math::sqrt; 0500 using std::__math::tan; 0501 using std::__math::tanh; 0502 using std::__math::tgamma; 0503 using std::__math::trunc; 0504 0505 } // extern "C++" 0506 0507 # endif // __cplusplus 0508 # endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) 0509 0510 #else // _LIBCPP_MATH_H 0511 0512 // This include lives outside the header guard in order to support an MSVC 0513 // extension which allows users to do: 0514 // 0515 // #define _USE_MATH_DEFINES 0516 // #include <math.h> 0517 // 0518 // and receive the definitions of mathematical constants, even if <math.h> 0519 // has previously been included. 0520 # if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES) 0521 # include_next <math.h> 0522 # endif 0523 0524 #endif // _LIBCPP_MATH_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|