Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:46

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___CXX03_MATH_H
0011 #  define _LIBCPP___CXX03_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 #  include <__cxx03/__config>
0295 
0296 #  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0297 #    pragma GCC system_header
0298 #  endif
0299 
0300 #  if __has_include_next(<math.h>)
0301 #    include_next <math.h>
0302 #  endif
0303 
0304 #  ifdef __cplusplus
0305 
0306 // We support including .h headers inside 'extern "C"' contexts, so switch
0307 // back to C++ linkage before including these C++ headers.
0308 extern "C++" {
0309 
0310 #    ifdef fpclassify
0311 #      undef fpclassify
0312 #    endif
0313 
0314 #    ifdef signbit
0315 #      undef signbit
0316 #    endif
0317 
0318 #    ifdef isfinite
0319 #      undef isfinite
0320 #    endif
0321 
0322 #    ifdef isinf
0323 #      undef isinf
0324 #    endif
0325 
0326 #    ifdef isnan
0327 #      undef isnan
0328 #    endif
0329 
0330 #    ifdef isnormal
0331 #      undef isnormal
0332 #    endif
0333 
0334 #    ifdef isgreater
0335 #      undef isgreater
0336 #    endif
0337 
0338 #    ifdef isgreaterequal
0339 #      undef isgreaterequal
0340 #    endif
0341 
0342 #    ifdef isless
0343 #      undef isless
0344 #    endif
0345 
0346 #    ifdef islessequal
0347 #      undef islessequal
0348 #    endif
0349 
0350 #    ifdef islessgreater
0351 #      undef islessgreater
0352 #    endif
0353 
0354 #    ifdef isunordered
0355 #      undef isunordered
0356 #    endif
0357 
0358 #    include <__cxx03/__math/abs.h>
0359 #    include <__cxx03/__math/copysign.h>
0360 #    include <__cxx03/__math/error_functions.h>
0361 #    include <__cxx03/__math/exponential_functions.h>
0362 #    include <__cxx03/__math/fdim.h>
0363 #    include <__cxx03/__math/fma.h>
0364 #    include <__cxx03/__math/gamma.h>
0365 #    include <__cxx03/__math/hyperbolic_functions.h>
0366 #    include <__cxx03/__math/hypot.h>
0367 #    include <__cxx03/__math/inverse_hyperbolic_functions.h>
0368 #    include <__cxx03/__math/inverse_trigonometric_functions.h>
0369 #    include <__cxx03/__math/logarithms.h>
0370 #    include <__cxx03/__math/min_max.h>
0371 #    include <__cxx03/__math/modulo.h>
0372 #    include <__cxx03/__math/remainder.h>
0373 #    include <__cxx03/__math/roots.h>
0374 #    include <__cxx03/__math/rounding_functions.h>
0375 #    include <__cxx03/__math/traits.h>
0376 #    include <__cxx03/__math/trigonometric_functions.h>
0377 #    include <__cxx03/__type_traits/enable_if.h>
0378 #    include <__cxx03/__type_traits/is_floating_point.h>
0379 #    include <__cxx03/__type_traits/is_integral.h>
0380 #    include <__cxx03/stdlib.h>
0381 
0382 // fpclassify relies on implementation-defined constants, so we can't move it to a detail header
0383 _LIBCPP_BEGIN_NAMESPACE_STD
0384 
0385 namespace __math {
0386 
0387 // fpclassify
0388 
0389 // template on non-double overloads to make them weaker than same overloads from MSVC runtime
0390 template <class = int>
0391 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT {
0392   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
0393 }
0394 
0395 template <class = int>
0396 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT {
0397   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
0398 }
0399 
0400 template <class = int>
0401 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT {
0402   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
0403 }
0404 
0405 template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
0406 _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
0407   return __x == 0 ? FP_ZERO : FP_NORMAL;
0408 }
0409 
0410 } // namespace __math
0411 
0412 _LIBCPP_END_NAMESPACE_STD
0413 
0414 using std::__math::fpclassify;
0415 using std::__math::signbit;
0416 
0417 // The MSVC runtime already provides these functions as templates
0418 #    ifndef _LIBCPP_MSVCRT
0419 using std::__math::isfinite;
0420 using std::__math::isgreater;
0421 using std::__math::isgreaterequal;
0422 using std::__math::isinf;
0423 using std::__math::isless;
0424 using std::__math::islessequal;
0425 using std::__math::islessgreater;
0426 using std::__math::isnan;
0427 using std::__math::isnormal;
0428 using std::__math::isunordered;
0429 #    endif // _LIBCPP_MSVCRT
0430 
0431 // abs
0432 //
0433 // handled in stdlib.h
0434 
0435 // div
0436 //
0437 // handled in stdlib.h
0438 
0439 // We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math
0440 // functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads
0441 // templates. Functions are preferred over function templates during overload resolution, which means that our overload
0442 // will only be selected when the C library doesn't provide one.
0443 
0444 using std::__math::acos;
0445 using std::__math::acosh;
0446 using std::__math::asin;
0447 using std::__math::asinh;
0448 using std::__math::atan;
0449 using std::__math::atan2;
0450 using std::__math::atanh;
0451 using std::__math::cbrt;
0452 using std::__math::ceil;
0453 using std::__math::copysign;
0454 using std::__math::cos;
0455 using std::__math::cosh;
0456 using std::__math::erf;
0457 using std::__math::erfc;
0458 using std::__math::exp;
0459 using std::__math::exp2;
0460 using std::__math::expm1;
0461 using std::__math::fabs;
0462 using std::__math::fdim;
0463 using std::__math::floor;
0464 using std::__math::fma;
0465 using std::__math::fmax;
0466 using std::__math::fmin;
0467 using std::__math::fmod;
0468 using std::__math::frexp;
0469 using std::__math::hypot;
0470 using std::__math::ilogb;
0471 using std::__math::ldexp;
0472 using std::__math::lgamma;
0473 using std::__math::llrint;
0474 using std::__math::llround;
0475 using std::__math::log;
0476 using std::__math::log10;
0477 using std::__math::log1p;
0478 using std::__math::log2;
0479 using std::__math::logb;
0480 using std::__math::lrint;
0481 using std::__math::lround;
0482 using std::__math::modf;
0483 using std::__math::nearbyint;
0484 using std::__math::nextafter;
0485 using std::__math::nexttoward;
0486 using std::__math::pow;
0487 using std::__math::remainder;
0488 using std::__math::remquo;
0489 using std::__math::rint;
0490 using std::__math::round;
0491 using std::__math::scalbln;
0492 using std::__math::scalbn;
0493 using std::__math::signbit;
0494 using std::__math::sin;
0495 using std::__math::sinh;
0496 using std::__math::sqrt;
0497 using std::__math::tan;
0498 using std::__math::tanh;
0499 using std::__math::tgamma;
0500 using std::__math::trunc;
0501 
0502 } // extern "C++"
0503 
0504 #  endif // __cplusplus
0505 
0506 #else // _LIBCPP___CXX03_MATH_H
0507 
0508 // This include lives outside the header guard in order to support an MSVC
0509 // extension which allows users to do:
0510 //
0511 // #define _USE_MATH_DEFINES
0512 // #include <__cxx03/math.h>
0513 //
0514 // and receive the definitions of mathematical constants, even if <math.h>
0515 // has previously been included.
0516 #  if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES)
0517 #    include_next <math.h>
0518 #  endif
0519 
0520 #endif // _LIBCPP___CXX03_MATH_H