Home | History | Annotate | Line # | Download | only in include
cmath revision 1.1
      1  1.1  joerg // -*- C++ -*-
      2  1.1  joerg //===---------------------------- cmath -----------------------------------===//
      3  1.1  joerg //
      4  1.1  joerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
      5  1.1  joerg // See https://llvm.org/LICENSE.txt for license information.
      6  1.1  joerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
      7  1.1  joerg //
      8  1.1  joerg //===----------------------------------------------------------------------===//
      9  1.1  joerg 
     10  1.1  joerg #ifndef _LIBCPP_CMATH
     11  1.1  joerg #define _LIBCPP_CMATH
     12  1.1  joerg 
     13  1.1  joerg /*
     14  1.1  joerg     cmath synopsis
     15  1.1  joerg 
     16  1.1  joerg Macros:
     17  1.1  joerg 
     18  1.1  joerg     HUGE_VAL
     19  1.1  joerg     HUGE_VALF               // C99
     20  1.1  joerg     HUGE_VALL               // C99
     21  1.1  joerg     INFINITY                // C99
     22  1.1  joerg     NAN                     // C99
     23  1.1  joerg     FP_INFINITE             // C99
     24  1.1  joerg     FP_NAN                  // C99
     25  1.1  joerg     FP_NORMAL               // C99
     26  1.1  joerg     FP_SUBNORMAL            // C99
     27  1.1  joerg     FP_ZERO                 // C99
     28  1.1  joerg     FP_FAST_FMA             // C99
     29  1.1  joerg     FP_FAST_FMAF            // C99
     30  1.1  joerg     FP_FAST_FMAL            // C99
     31  1.1  joerg     FP_ILOGB0               // C99
     32  1.1  joerg     FP_ILOGBNAN             // C99
     33  1.1  joerg     MATH_ERRNO              // C99
     34  1.1  joerg     MATH_ERREXCEPT          // C99
     35  1.1  joerg     math_errhandling        // C99
     36  1.1  joerg 
     37  1.1  joerg namespace std
     38  1.1  joerg {
     39  1.1  joerg 
     40  1.1  joerg Types:
     41  1.1  joerg 
     42  1.1  joerg     float_t                 // C99
     43  1.1  joerg     double_t                // C99
     44  1.1  joerg 
     45  1.1  joerg // C90
     46  1.1  joerg 
     47  1.1  joerg floating_point abs(floating_point x);
     48  1.1  joerg 
     49  1.1  joerg floating_point acos (arithmetic x);
     50  1.1  joerg float          acosf(float x);
     51  1.1  joerg long double    acosl(long double x);
     52  1.1  joerg 
     53  1.1  joerg floating_point asin (arithmetic x);
     54  1.1  joerg float          asinf(float x);
     55  1.1  joerg long double    asinl(long double x);
     56  1.1  joerg 
     57  1.1  joerg floating_point atan (arithmetic x);
     58  1.1  joerg float          atanf(float x);
     59  1.1  joerg long double    atanl(long double x);
     60  1.1  joerg 
     61  1.1  joerg floating_point atan2 (arithmetic y, arithmetic x);
     62  1.1  joerg float          atan2f(float y, float x);
     63  1.1  joerg long double    atan2l(long double y, long double x);
     64  1.1  joerg 
     65  1.1  joerg floating_point ceil (arithmetic x);
     66  1.1  joerg float          ceilf(float x);
     67  1.1  joerg long double    ceill(long double x);
     68  1.1  joerg 
     69  1.1  joerg floating_point cos (arithmetic x);
     70  1.1  joerg float          cosf(float x);
     71  1.1  joerg long double    cosl(long double x);
     72  1.1  joerg 
     73  1.1  joerg floating_point cosh (arithmetic x);
     74  1.1  joerg float          coshf(float x);
     75  1.1  joerg long double    coshl(long double x);
     76  1.1  joerg 
     77  1.1  joerg floating_point exp (arithmetic x);
     78  1.1  joerg float          expf(float x);
     79  1.1  joerg long double    expl(long double x);
     80  1.1  joerg 
     81  1.1  joerg floating_point fabs (arithmetic x);
     82  1.1  joerg float          fabsf(float x);
     83  1.1  joerg long double    fabsl(long double x);
     84  1.1  joerg 
     85  1.1  joerg floating_point floor (arithmetic x);
     86  1.1  joerg float          floorf(float x);
     87  1.1  joerg long double    floorl(long double x);
     88  1.1  joerg 
     89  1.1  joerg floating_point fmod (arithmetic x, arithmetic y);
     90  1.1  joerg float          fmodf(float x, float y);
     91  1.1  joerg long double    fmodl(long double x, long double y);
     92  1.1  joerg 
     93  1.1  joerg floating_point frexp (arithmetic value, int* exp);
     94  1.1  joerg float          frexpf(float value, int* exp);
     95  1.1  joerg long double    frexpl(long double value, int* exp);
     96  1.1  joerg 
     97  1.1  joerg floating_point ldexp (arithmetic value, int exp);
     98  1.1  joerg float          ldexpf(float value, int exp);
     99  1.1  joerg long double    ldexpl(long double value, int exp);
    100  1.1  joerg 
    101  1.1  joerg floating_point log (arithmetic x);
    102  1.1  joerg float          logf(float x);
    103  1.1  joerg long double    logl(long double x);
    104  1.1  joerg 
    105  1.1  joerg floating_point log10 (arithmetic x);
    106  1.1  joerg float          log10f(float x);
    107  1.1  joerg long double    log10l(long double x);
    108  1.1  joerg 
    109  1.1  joerg floating_point modf (floating_point value, floating_point* iptr);
    110  1.1  joerg float          modff(float value, float* iptr);
    111  1.1  joerg long double    modfl(long double value, long double* iptr);
    112  1.1  joerg 
    113  1.1  joerg floating_point pow (arithmetic x, arithmetic y);
    114  1.1  joerg float          powf(float x, float y);
    115  1.1  joerg long double    powl(long double x, long double y);
    116  1.1  joerg 
    117  1.1  joerg floating_point sin (arithmetic x);
    118  1.1  joerg float          sinf(float x);
    119  1.1  joerg long double    sinl(long double x);
    120  1.1  joerg 
    121  1.1  joerg floating_point sinh (arithmetic x);
    122  1.1  joerg float          sinhf(float x);
    123  1.1  joerg long double    sinhl(long double x);
    124  1.1  joerg 
    125  1.1  joerg floating_point sqrt (arithmetic x);
    126  1.1  joerg float          sqrtf(float x);
    127  1.1  joerg long double    sqrtl(long double x);
    128  1.1  joerg 
    129  1.1  joerg floating_point tan (arithmetic x);
    130  1.1  joerg float          tanf(float x);
    131  1.1  joerg long double    tanl(long double x);
    132  1.1  joerg 
    133  1.1  joerg floating_point tanh (arithmetic x);
    134  1.1  joerg float          tanhf(float x);
    135  1.1  joerg long double    tanhl(long double x);
    136  1.1  joerg 
    137  1.1  joerg //  C99
    138  1.1  joerg 
    139  1.1  joerg bool signbit(arithmetic x);
    140  1.1  joerg 
    141  1.1  joerg int fpclassify(arithmetic x);
    142  1.1  joerg 
    143  1.1  joerg bool isfinite(arithmetic x);
    144  1.1  joerg bool isinf(arithmetic x);
    145  1.1  joerg bool isnan(arithmetic x);
    146  1.1  joerg bool isnormal(arithmetic x);
    147  1.1  joerg 
    148  1.1  joerg bool isgreater(arithmetic x, arithmetic y);
    149  1.1  joerg bool isgreaterequal(arithmetic x, arithmetic y);
    150  1.1  joerg bool isless(arithmetic x, arithmetic y);
    151  1.1  joerg bool islessequal(arithmetic x, arithmetic y);
    152  1.1  joerg bool islessgreater(arithmetic x, arithmetic y);
    153  1.1  joerg bool isunordered(arithmetic x, arithmetic y);
    154  1.1  joerg 
    155  1.1  joerg floating_point acosh (arithmetic x);
    156  1.1  joerg float          acoshf(float x);
    157  1.1  joerg long double    acoshl(long double x);
    158  1.1  joerg 
    159  1.1  joerg floating_point asinh (arithmetic x);
    160  1.1  joerg float          asinhf(float x);
    161  1.1  joerg long double    asinhl(long double x);
    162  1.1  joerg 
    163  1.1  joerg floating_point atanh (arithmetic x);
    164  1.1  joerg float          atanhf(float x);
    165  1.1  joerg long double    atanhl(long double x);
    166  1.1  joerg 
    167  1.1  joerg floating_point cbrt (arithmetic x);
    168  1.1  joerg float          cbrtf(float x);
    169  1.1  joerg long double    cbrtl(long double x);
    170  1.1  joerg 
    171  1.1  joerg floating_point copysign (arithmetic x, arithmetic y);
    172  1.1  joerg float          copysignf(float x, float y);
    173  1.1  joerg long double    copysignl(long double x, long double y);
    174  1.1  joerg 
    175  1.1  joerg floating_point erf (arithmetic x);
    176  1.1  joerg float          erff(float x);
    177  1.1  joerg long double    erfl(long double x);
    178  1.1  joerg 
    179  1.1  joerg floating_point erfc (arithmetic x);
    180  1.1  joerg float          erfcf(float x);
    181  1.1  joerg long double    erfcl(long double x);
    182  1.1  joerg 
    183  1.1  joerg floating_point exp2 (arithmetic x);
    184  1.1  joerg float          exp2f(float x);
    185  1.1  joerg long double    exp2l(long double x);
    186  1.1  joerg 
    187  1.1  joerg floating_point expm1 (arithmetic x);
    188  1.1  joerg float          expm1f(float x);
    189  1.1  joerg long double    expm1l(long double x);
    190  1.1  joerg 
    191  1.1  joerg floating_point fdim (arithmetic x, arithmetic y);
    192  1.1  joerg float          fdimf(float x, float y);
    193  1.1  joerg long double    fdiml(long double x, long double y);
    194  1.1  joerg 
    195  1.1  joerg floating_point fma (arithmetic x, arithmetic y, arithmetic z);
    196  1.1  joerg float          fmaf(float x, float y, float z);
    197  1.1  joerg long double    fmal(long double x, long double y, long double z);
    198  1.1  joerg 
    199  1.1  joerg floating_point fmax (arithmetic x, arithmetic y);
    200  1.1  joerg float          fmaxf(float x, float y);
    201  1.1  joerg long double    fmaxl(long double x, long double y);
    202  1.1  joerg 
    203  1.1  joerg floating_point fmin (arithmetic x, arithmetic y);
    204  1.1  joerg float          fminf(float x, float y);
    205  1.1  joerg long double    fminl(long double x, long double y);
    206  1.1  joerg 
    207  1.1  joerg floating_point hypot (arithmetic x, arithmetic y);
    208  1.1  joerg float          hypotf(float x, float y);
    209  1.1  joerg long double    hypotl(long double x, long double y);
    210  1.1  joerg 
    211  1.1  joerg double       hypot(double x, double y, double z);                // C++17
    212  1.1  joerg float        hypot(float x, float y, float z);                   // C++17
    213  1.1  joerg long double  hypot(long double x, long double y, long double z); // C++17
    214  1.1  joerg 
    215  1.1  joerg int ilogb (arithmetic x);
    216  1.1  joerg int ilogbf(float x);
    217  1.1  joerg int ilogbl(long double x);
    218  1.1  joerg 
    219  1.1  joerg floating_point lgamma (arithmetic x);
    220  1.1  joerg float          lgammaf(float x);
    221  1.1  joerg long double    lgammal(long double x);
    222  1.1  joerg 
    223  1.1  joerg long long llrint (arithmetic x);
    224  1.1  joerg long long llrintf(float x);
    225  1.1  joerg long long llrintl(long double x);
    226  1.1  joerg 
    227  1.1  joerg long long llround (arithmetic x);
    228  1.1  joerg long long llroundf(float x);
    229  1.1  joerg long long llroundl(long double x);
    230  1.1  joerg 
    231  1.1  joerg floating_point log1p (arithmetic x);
    232  1.1  joerg float          log1pf(float x);
    233  1.1  joerg long double    log1pl(long double x);
    234  1.1  joerg 
    235  1.1  joerg floating_point log2 (arithmetic x);
    236  1.1  joerg float          log2f(float x);
    237  1.1  joerg long double    log2l(long double x);
    238  1.1  joerg 
    239  1.1  joerg floating_point logb (arithmetic x);
    240  1.1  joerg float          logbf(float x);
    241  1.1  joerg long double    logbl(long double x);
    242  1.1  joerg 
    243  1.1  joerg long lrint (arithmetic x);
    244  1.1  joerg long lrintf(float x);
    245  1.1  joerg long lrintl(long double x);
    246  1.1  joerg 
    247  1.1  joerg long lround (arithmetic x);
    248  1.1  joerg long lroundf(float x);
    249  1.1  joerg long lroundl(long double x);
    250  1.1  joerg 
    251  1.1  joerg double      nan (const char* str);
    252  1.1  joerg float       nanf(const char* str);
    253  1.1  joerg long double nanl(const char* str);
    254  1.1  joerg 
    255  1.1  joerg floating_point nearbyint (arithmetic x);
    256  1.1  joerg float          nearbyintf(float x);
    257  1.1  joerg long double    nearbyintl(long double x);
    258  1.1  joerg 
    259  1.1  joerg floating_point nextafter (arithmetic x, arithmetic y);
    260  1.1  joerg float          nextafterf(float x, float y);
    261  1.1  joerg long double    nextafterl(long double x, long double y);
    262  1.1  joerg 
    263  1.1  joerg floating_point nexttoward (arithmetic x, long double y);
    264  1.1  joerg float          nexttowardf(float x, long double y);
    265  1.1  joerg long double    nexttowardl(long double x, long double y);
    266  1.1  joerg 
    267  1.1  joerg floating_point remainder (arithmetic x, arithmetic y);
    268  1.1  joerg float          remainderf(float x, float y);
    269  1.1  joerg long double    remainderl(long double x, long double y);
    270  1.1  joerg 
    271  1.1  joerg floating_point remquo (arithmetic x, arithmetic y, int* pquo);
    272  1.1  joerg float          remquof(float x, float y, int* pquo);
    273  1.1  joerg long double    remquol(long double x, long double y, int* pquo);
    274  1.1  joerg 
    275  1.1  joerg floating_point rint (arithmetic x);
    276  1.1  joerg float          rintf(float x);
    277  1.1  joerg long double    rintl(long double x);
    278  1.1  joerg 
    279  1.1  joerg floating_point round (arithmetic x);
    280  1.1  joerg float          roundf(float x);
    281  1.1  joerg long double    roundl(long double x);
    282  1.1  joerg 
    283  1.1  joerg floating_point scalbln (arithmetic x, long ex);
    284  1.1  joerg float          scalblnf(float x, long ex);
    285  1.1  joerg long double    scalblnl(long double x, long ex);
    286  1.1  joerg 
    287  1.1  joerg floating_point scalbn (arithmetic x, int ex);
    288  1.1  joerg float          scalbnf(float x, int ex);
    289  1.1  joerg long double    scalbnl(long double x, int ex);
    290  1.1  joerg 
    291  1.1  joerg floating_point tgamma (arithmetic x);
    292  1.1  joerg float          tgammaf(float x);
    293  1.1  joerg long double    tgammal(long double x);
    294  1.1  joerg 
    295  1.1  joerg floating_point trunc (arithmetic x);
    296  1.1  joerg float          truncf(float x);
    297  1.1  joerg long double    truncl(long double x);
    298  1.1  joerg 
    299  1.1  joerg constexpr float       lerp(float a, float b, float t) noexcept;                   // C++20
    300  1.1  joerg constexpr double      lerp(double a, double b, double t) noexcept;                // C++20
    301  1.1  joerg constexpr long double lerp(long double a, long double b, long double t) noexcept; // C++20
    302  1.1  joerg 
    303  1.1  joerg }  // std
    304  1.1  joerg 
    305  1.1  joerg */
    306  1.1  joerg 
    307  1.1  joerg #include <__config>
    308  1.1  joerg #include <math.h>
    309  1.1  joerg #include <version>
    310  1.1  joerg #include <type_traits>
    311  1.1  joerg 
    312  1.1  joerg #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
    313  1.1  joerg #pragma GCC system_header
    314  1.1  joerg #endif
    315  1.1  joerg 
    316  1.1  joerg _LIBCPP_PUSH_MACROS
    317  1.1  joerg #include <__undef_macros>
    318  1.1  joerg 
    319  1.1  joerg _LIBCPP_BEGIN_NAMESPACE_STD
    320  1.1  joerg 
    321  1.1  joerg using ::signbit;
    322  1.1  joerg using ::fpclassify;
    323  1.1  joerg using ::isfinite;
    324  1.1  joerg using ::isinf;
    325  1.1  joerg using ::isnan;
    326  1.1  joerg using ::isnormal;
    327  1.1  joerg using ::isgreater;
    328  1.1  joerg using ::isgreaterequal;
    329  1.1  joerg using ::isless;
    330  1.1  joerg using ::islessequal;
    331  1.1  joerg using ::islessgreater;
    332  1.1  joerg using ::isunordered;
    333  1.1  joerg using ::isunordered;
    334  1.1  joerg 
    335  1.1  joerg using ::float_t;
    336  1.1  joerg using ::double_t;
    337  1.1  joerg 
    338  1.1  joerg using ::abs;
    339  1.1  joerg 
    340  1.1  joerg using ::acos;
    341  1.1  joerg using ::acosf;
    342  1.1  joerg using ::asin;
    343  1.1  joerg using ::asinf;
    344  1.1  joerg using ::atan;
    345  1.1  joerg using ::atanf;
    346  1.1  joerg using ::atan2;
    347  1.1  joerg using ::atan2f;
    348  1.1  joerg using ::ceil;
    349  1.1  joerg using ::ceilf;
    350  1.1  joerg using ::cos;
    351  1.1  joerg using ::cosf;
    352  1.1  joerg using ::cosh;
    353  1.1  joerg using ::coshf;
    354  1.1  joerg 
    355  1.1  joerg using ::exp;
    356  1.1  joerg using ::expf;
    357  1.1  joerg 
    358  1.1  joerg using ::fabs;
    359  1.1  joerg using ::fabsf;
    360  1.1  joerg using ::floor;
    361  1.1  joerg using ::floorf;
    362  1.1  joerg 
    363  1.1  joerg using ::fmod;
    364  1.1  joerg using ::fmodf;
    365  1.1  joerg 
    366  1.1  joerg using ::frexp;
    367  1.1  joerg using ::frexpf;
    368  1.1  joerg using ::ldexp;
    369  1.1  joerg using ::ldexpf;
    370  1.1  joerg 
    371  1.1  joerg using ::log;
    372  1.1  joerg using ::logf;
    373  1.1  joerg 
    374  1.1  joerg using ::log10;
    375  1.1  joerg using ::log10f;
    376  1.1  joerg using ::modf;
    377  1.1  joerg using ::modff;
    378  1.1  joerg 
    379  1.1  joerg using ::pow;
    380  1.1  joerg using ::powf;
    381  1.1  joerg 
    382  1.1  joerg using ::sin;
    383  1.1  joerg using ::sinf;
    384  1.1  joerg using ::sinh;
    385  1.1  joerg using ::sinhf;
    386  1.1  joerg 
    387  1.1  joerg using ::sqrt;
    388  1.1  joerg using ::sqrtf;
    389  1.1  joerg using ::tan;
    390  1.1  joerg using ::tanf;
    391  1.1  joerg 
    392  1.1  joerg using ::tanh;
    393  1.1  joerg using ::tanhf;
    394  1.1  joerg 
    395  1.1  joerg using ::acosh;
    396  1.1  joerg using ::acoshf;
    397  1.1  joerg using ::asinh;
    398  1.1  joerg using ::asinhf;
    399  1.1  joerg using ::atanh;
    400  1.1  joerg using ::atanhf;
    401  1.1  joerg using ::cbrt;
    402  1.1  joerg using ::cbrtf;
    403  1.1  joerg 
    404  1.1  joerg using ::copysign;
    405  1.1  joerg using ::copysignf;
    406  1.1  joerg 
    407  1.1  joerg using ::erf;
    408  1.1  joerg using ::erff;
    409  1.1  joerg using ::erfc;
    410  1.1  joerg using ::erfcf;
    411  1.1  joerg using ::exp2;
    412  1.1  joerg using ::exp2f;
    413  1.1  joerg using ::expm1;
    414  1.1  joerg using ::expm1f;
    415  1.1  joerg using ::fdim;
    416  1.1  joerg using ::fdimf;
    417  1.1  joerg using ::fmaf;
    418  1.1  joerg using ::fma;
    419  1.1  joerg using ::fmax;
    420  1.1  joerg using ::fmaxf;
    421  1.1  joerg using ::fmin;
    422  1.1  joerg using ::fminf;
    423  1.1  joerg using ::hypot;
    424  1.1  joerg using ::hypotf;
    425  1.1  joerg using ::ilogb;
    426  1.1  joerg using ::ilogbf;
    427  1.1  joerg using ::lgamma;
    428  1.1  joerg using ::lgammaf;
    429  1.1  joerg using ::llrint;
    430  1.1  joerg using ::llrintf;
    431  1.1  joerg using ::llround;
    432  1.1  joerg using ::llroundf;
    433  1.1  joerg using ::log1p;
    434  1.1  joerg using ::log1pf;
    435  1.1  joerg using ::log2;
    436  1.1  joerg using ::log2f;
    437  1.1  joerg using ::logb;
    438  1.1  joerg using ::logbf;
    439  1.1  joerg using ::lrint;
    440  1.1  joerg using ::lrintf;
    441  1.1  joerg using ::lround;
    442  1.1  joerg using ::lroundf;
    443  1.1  joerg 
    444  1.1  joerg using ::nan;
    445  1.1  joerg using ::nanf;
    446  1.1  joerg 
    447  1.1  joerg using ::nearbyint;
    448  1.1  joerg using ::nearbyintf;
    449  1.1  joerg using ::nextafter;
    450  1.1  joerg using ::nextafterf;
    451  1.1  joerg using ::nexttoward;
    452  1.1  joerg using ::nexttowardf;
    453  1.1  joerg using ::remainder;
    454  1.1  joerg using ::remainderf;
    455  1.1  joerg using ::remquo;
    456  1.1  joerg using ::remquof;
    457  1.1  joerg using ::rint;
    458  1.1  joerg using ::rintf;
    459  1.1  joerg using ::round;
    460  1.1  joerg using ::roundf;
    461  1.1  joerg using ::scalbln;
    462  1.1  joerg using ::scalblnf;
    463  1.1  joerg using ::scalbn;
    464  1.1  joerg using ::scalbnf;
    465  1.1  joerg using ::tgamma;
    466  1.1  joerg using ::tgammaf;
    467  1.1  joerg using ::trunc;
    468  1.1  joerg using ::truncf;
    469  1.1  joerg 
    470  1.1  joerg using ::acosl;
    471  1.1  joerg using ::asinl;
    472  1.1  joerg using ::atanl;
    473  1.1  joerg using ::atan2l;
    474  1.1  joerg using ::ceill;
    475  1.1  joerg using ::cosl;
    476  1.1  joerg using ::coshl;
    477  1.1  joerg using ::expl;
    478  1.1  joerg using ::fabsl;
    479  1.1  joerg using ::floorl;
    480  1.1  joerg using ::fmodl;
    481  1.1  joerg using ::frexpl;
    482  1.1  joerg using ::ldexpl;
    483  1.1  joerg using ::logl;
    484  1.1  joerg using ::log10l;
    485  1.1  joerg using ::modfl;
    486  1.1  joerg using ::powl;
    487  1.1  joerg using ::sinl;
    488  1.1  joerg using ::sinhl;
    489  1.1  joerg using ::sqrtl;
    490  1.1  joerg using ::tanl;
    491  1.1  joerg 
    492  1.1  joerg using ::tanhl;
    493  1.1  joerg using ::acoshl;
    494  1.1  joerg using ::asinhl;
    495  1.1  joerg using ::atanhl;
    496  1.1  joerg using ::cbrtl;
    497  1.1  joerg 
    498  1.1  joerg using ::copysignl;
    499  1.1  joerg 
    500  1.1  joerg using ::erfl;
    501  1.1  joerg using ::erfcl;
    502  1.1  joerg using ::exp2l;
    503  1.1  joerg using ::expm1l;
    504  1.1  joerg using ::fdiml;
    505  1.1  joerg using ::fmal;
    506  1.1  joerg using ::fmaxl;
    507  1.1  joerg using ::fminl;
    508  1.1  joerg using ::hypotl;
    509  1.1  joerg using ::ilogbl;
    510  1.1  joerg using ::lgammal;
    511  1.1  joerg using ::llrintl;
    512  1.1  joerg using ::llroundl;
    513  1.1  joerg using ::log1pl;
    514  1.1  joerg using ::log2l;
    515  1.1  joerg using ::logbl;
    516  1.1  joerg using ::lrintl;
    517  1.1  joerg using ::lroundl;
    518  1.1  joerg using ::nanl;
    519  1.1  joerg using ::nearbyintl;
    520  1.1  joerg using ::nextafterl;
    521  1.1  joerg using ::nexttowardl;
    522  1.1  joerg using ::remainderl;
    523  1.1  joerg using ::remquol;
    524  1.1  joerg using ::rintl;
    525  1.1  joerg using ::roundl;
    526  1.1  joerg using ::scalblnl;
    527  1.1  joerg using ::scalbnl;
    528  1.1  joerg using ::tgammal;
    529  1.1  joerg using ::truncl;
    530  1.1  joerg 
    531  1.1  joerg #if _LIBCPP_STD_VER > 14
    532  1.1  joerg inline _LIBCPP_INLINE_VISIBILITY float       hypot(       float x,       float y,       float z ) { return sqrt(x*x + y*y + z*z); }
    533  1.1  joerg inline _LIBCPP_INLINE_VISIBILITY double      hypot(      double x,      double y,      double z ) { return sqrt(x*x + y*y + z*z); }
    534  1.1  joerg inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }
    535  1.1  joerg 
    536  1.1  joerg template <class _A1, class _A2, class _A3>
    537  1.1  joerg inline _LIBCPP_INLINE_VISIBILITY
    538  1.1  joerg typename _EnableIf
    539  1.1  joerg <
    540  1.1  joerg     is_arithmetic<_A1>::value &&
    541  1.1  joerg     is_arithmetic<_A2>::value &&
    542  1.1  joerg     is_arithmetic<_A3>::value,
    543  1.1  joerg     __promote<_A1, _A2, _A3>
    544  1.1  joerg >::type
    545  1.1  joerg hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
    546  1.1  joerg {
    547  1.1  joerg     typedef typename __promote<_A1, _A2, _A3>::type __result_type;
    548  1.1  joerg     static_assert((!(is_same<_A1, __result_type>::value &&
    549  1.1  joerg                      is_same<_A2, __result_type>::value &&
    550  1.1  joerg                      is_same<_A3, __result_type>::value)), "");
    551  1.1  joerg     return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
    552  1.1  joerg }
    553  1.1  joerg #endif
    554  1.1  joerg 
    555  1.1  joerg template <class _A1>
    556  1.1  joerg _LIBCPP_INLINE_VISIBILITY
    557  1.1  joerg _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
    558  1.1  joerg __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
    559  1.1  joerg {
    560  1.1  joerg #if __has_builtin(__builtin_isnan)
    561  1.1  joerg     return __builtin_isnan(__lcpp_x);
    562  1.1  joerg #else
    563  1.1  joerg     return isnan(__lcpp_x);
    564  1.1  joerg #endif
    565  1.1  joerg }
    566  1.1  joerg 
    567  1.1  joerg template <class _A1>
    568  1.1  joerg _LIBCPP_INLINE_VISIBILITY
    569  1.1  joerg _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
    570  1.1  joerg __libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
    571  1.1  joerg {
    572  1.1  joerg     return isnan(__lcpp_x);
    573  1.1  joerg }
    574  1.1  joerg 
    575  1.1  joerg template <class _A1>
    576  1.1  joerg _LIBCPP_INLINE_VISIBILITY
    577  1.1  joerg _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
    578  1.1  joerg __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
    579  1.1  joerg {
    580  1.1  joerg #if __has_builtin(__builtin_isinf)
    581  1.1  joerg     return __builtin_isinf(__lcpp_x);
    582  1.1  joerg #else
    583  1.1  joerg     return isinf(__lcpp_x);
    584  1.1  joerg #endif
    585  1.1  joerg }
    586  1.1  joerg 
    587  1.1  joerg template <class _A1>
    588  1.1  joerg _LIBCPP_INLINE_VISIBILITY
    589  1.1  joerg _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
    590  1.1  joerg __libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
    591  1.1  joerg {
    592  1.1  joerg     return isinf(__lcpp_x);
    593  1.1  joerg }
    594  1.1  joerg 
    595  1.1  joerg template <class _A1>
    596  1.1  joerg _LIBCPP_INLINE_VISIBILITY
    597  1.1  joerg _LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
    598  1.1  joerg __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
    599  1.1  joerg {
    600  1.1  joerg #if __has_builtin(__builtin_isfinite)
    601  1.1  joerg     return __builtin_isfinite(__lcpp_x);
    602  1.1  joerg #else
    603  1.1  joerg     return isfinite(__lcpp_x);
    604  1.1  joerg #endif
    605  1.1  joerg }
    606  1.1  joerg 
    607  1.1  joerg template <class _A1>
    608  1.1  joerg _LIBCPP_INLINE_VISIBILITY
    609  1.1  joerg _LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
    610  1.1  joerg __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
    611  1.1  joerg {
    612  1.1  joerg     return isfinite(__lcpp_x);
    613  1.1  joerg }
    614  1.1  joerg 
    615  1.1  joerg #if _LIBCPP_STD_VER > 17
    616  1.1  joerg template <typename _Fp>
    617  1.1  joerg constexpr
    618  1.1  joerg _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
    619  1.1  joerg     if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
    620  1.1  joerg         return __t * __b + (1 - __t) * __a;
    621  1.1  joerg 
    622  1.1  joerg     if (__t == 1) return __b;
    623  1.1  joerg     const _Fp __x = __a + __t * (__b - __a);
    624  1.1  joerg     if (__t > 1 == __b > __a)
    625  1.1  joerg         return __b < __x ? __x : __b;
    626  1.1  joerg     else
    627  1.1  joerg         return __x < __b ? __x : __b;
    628  1.1  joerg }
    629  1.1  joerg 
    630  1.1  joerg constexpr float
    631  1.1  joerg lerp(float __a, float __b, float __t)                   _NOEXCEPT { return __lerp(__a, __b, __t); }
    632  1.1  joerg 
    633  1.1  joerg constexpr double
    634  1.1  joerg lerp(double __a, double __b, double __t)                _NOEXCEPT { return __lerp(__a, __b, __t); }
    635  1.1  joerg 
    636  1.1  joerg constexpr long double
    637  1.1  joerg lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
    638  1.1  joerg 
    639  1.1  joerg #endif // _LIBCPP_STD_VER > 17
    640  1.1  joerg 
    641  1.1  joerg template <class _IntT, class _FloatT,
    642  1.1  joerg     bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
    643  1.1  joerg     int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
    644  1.1  joerg _LIBCPP_INLINE_VISIBILITY
    645  1.1  joerg _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
    646  1.1  joerg   static_assert(is_floating_point<_FloatT>::value, "must be a floating point type");
    647  1.1  joerg   static_assert(is_integral<_IntT>::value, "must be an integral type");
    648  1.1  joerg   static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
    649  1.1  joerg   static_assert((_IsSame<_FloatT, float>::value || _IsSame<_FloatT, double>::value
    650  1.1  joerg                  || _IsSame<_FloatT,long double>::value), "unsupported floating point type");
    651  1.1  joerg   return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
    652  1.1  joerg }
    653  1.1  joerg 
    654  1.1  joerg // Convert a floating point number to the specified integral type after
    655  1.1  joerg // clamping to the integral types representable range.
    656  1.1  joerg //
    657  1.1  joerg // The behavior is undefined if `__r` is NaN.
    658  1.1  joerg template <class _IntT, class _RealT>
    659  1.1  joerg _LIBCPP_INLINE_VISIBILITY
    660  1.1  joerg _IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
    661  1.1  joerg   using _Lim = numeric_limits<_IntT>;
    662  1.1  joerg   const _IntT _MaxVal = __max_representable_int_for_float<_IntT, _RealT>();
    663  1.1  joerg   if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) {
    664  1.1  joerg     return _Lim::max();
    665  1.1  joerg   } else if (__r <= _Lim::lowest()) {
    666  1.1  joerg     return _Lim::min();
    667  1.1  joerg   }
    668  1.1  joerg   return static_cast<_IntT>(__r);
    669  1.1  joerg }
    670  1.1  joerg 
    671  1.1  joerg _LIBCPP_END_NAMESPACE_STD
    672  1.1  joerg 
    673  1.1  joerg _LIBCPP_POP_MACROS
    674  1.1  joerg 
    675  1.1  joerg #endif // _LIBCPP_CMATH
    676