标准库标头 <cmath> - cppreference.com
对于每个至少有一个形参类型是 /* 浮点数类型 */ 的函数,实现都会为每个无 cv 限定的浮点数类型提供一个重载,该重载的函数签名中所有 /* 浮点数类型 */ 都会替换成该浮点数类型。
对于 std::abs 以外每个至少有一个形参类型是 /* 浮点数类型 */ 的函数,实现都会提供额外重载以确保在每个类型是 /* 浮点数类型 */ 的形参对应的实参都具有整数类型时,所有这些实参都会等效地转型到它们的类型中具有最高浮点数转换等级和最高浮点数转换子等级的类型,其中具有整数类型的实参被视为具有和 double 相同的浮点数转换等级。如果不存在浮点数转换等级和浮点数转换子等级最高的类型,那么重载决议不会从提供的重载中得到可用候选。
namespace std { using float_t = /* 见描述 */; using double_t = /* 见描述 */; } #define HUGE_VAL /* 见描述 */ #define HUGE_VALF /* 见描述 */ #define HUGE_VALL /* 见描述 */ #define INFINITY /* 见描述 */ #define NAN /* 见描述 */ #define FP_INFINITE /* 见描述 */ #define FP_NAN /* 见描述 */ #define FP_NORMAL /* 见描述 */ #define FP_SUBNORMAL /* 见描述 */ #define FP_ZERO /* 见描述 */ #define FP_FAST_FMA /* 见描述 */ #define FP_FAST_FMAF /* 见描述 */ #define FP_FAST_FMAL /* 见描述 */ #define FP_ILOGB0 /* 见描述 */ #define FP_ILOGBNAN /* 见描述 */ #define MATH_ERRNO /* 见描述 */ #define MATH_ERREXCEPT /* 见描述 */ #define math_errhandling /* 见描述 */ namespace std { /* 浮点数类型 */ acos(/* 浮点数类型 */ x); float acosf(float x); long double acosl(long double x); /* 浮点数类型 */ asin(/* 浮点数类型 */ x); float asinf(float x); long double asinl(long double x); /* 浮点数类型 */ atan(/* 浮点数类型 */ x); float atanf(float x); long double atanl(long double x); /* 浮点数类型 */ atan2(/* 浮点数类型 */ y, /* 浮点数类型 */ x); float atan2f(float y, float x); long double atan2l(long double y, long double x); /* 浮点数类型 */ cos(/* 浮点数类型 */e x); float cosf(float x); long double cosl(long double x); /* 浮点数类型 */ sin(/* 浮点数类型 */ x); float sinf(float x); long double sinl(long double x); /* 浮点数类型 */ tan(/* 浮点数类型 */ x); float tanf(float x); long double tanl(long double x); /* 浮点数类型 */ acosh(/* 浮点数类型 */ x); float acoshf(float x); long double acoshl(long double x); /* 浮点数类型 */ asinh(/* 浮点数类型 */ x); float asinhf(float x); long double asinhl(long double x); /* 浮点数类型 */ atanh(/* 浮点数类型 */ x); float atanhf(float x); long double atanhl(long double x); /* 浮点数类型 */ cosh(/* 浮点数类型 */ x); float coshf(float x); long double coshl(long double x); /* 浮点数类型 */ sinh(/* 浮点数类型 */ x); float sinhf(float x); long double sinhl(long double x); /* 浮点数类型 */ tanh(/* 浮点数类型 */ x); float tanhf(float x); long double tanhl(long double x); /* 浮点数类型 */ exp(/* 浮点数类型 */ x); float expf(float x); long double expl(long double x); /* 浮点数类型 */ exp2(/* 浮点数类型 */ x); float exp2f(float x); long double exp2l(long double x); /* 浮点数类型 */ expm1(/* 浮点数类型 */ x); float expm1f(float x); long double expm1l(long double x); constexpr /* 浮点数类型 */ frexp(/* 浮点数类型 */ value, int* exp); constexpr float frexpf(float value, int* exp); constexpr long double frexpl(long double value, int* exp); constexpr int ilogb(/* 浮点数类型 */ x); constexpr int ilogbf(float x); constexpr int ilogbl(long double x); constexpr /* 浮点数类型 */ ldexp(/* 浮点数类型 */ x, int exp); constexpr float ldexpf(float x, int exp); constexpr long double ldexpl(long double x, int exp); /* 浮点数类型 */ log(/* 浮点数类型 */ x); float logf(float x); long double logl(long double x); /* 浮点数类型 */ log10(/* 浮点数类型 */ x); float log10f(float x); long double log10l(long double x); /* 浮点数类型 */ log1p(/* 浮点数类型 */ x); float log1pf(float x); long double log1pl(long double x); /* 浮点数类型 */ log2(/* 浮点数类型 */ x); float log2f(float x); long double log2l(long double x); constexpr /* 浮点数类型 */ logb(/* 浮点数类型 */ x); constexpr float logbf(float x); constexpr long double logbl(long double x); constexpr /* 浮点数类型 */ modf(/* 浮点数类型 */ value, /* 浮点数类型 */* iptr); constexpr float modff(float value, float* iptr); constexpr long double modfl(long double value, long double* iptr); constexpr /* 浮点数类型 */ scalbn(/* 浮点数类型 */ x, int n); constexpr float scalbnf(float x, int n); constexpr long double scalbnl(long double x, int n); constexpr /* 浮点数类型 */ scalbln(/* 浮点数类型 */ x, long int n); constexpr float scalblnf(float x, long int n); constexpr long double scalblnl(long double x, long int n); /* 浮点数类型 */ cbrt(/* 浮点数类型 */ x); float cbrtf(float x); long double cbrtl(long double x); // 绝对值 constexpr int abs(int j); // 独立 constexpr long int abs(long int j); // 独立 constexpr long long int abs(long long int j); // 独立 constexpr /* 浮点数类型 */ abs(/* 浮点数类型 */ j); // 独立或被删除 constexpr /* 浮点数类型 */ fabs(/* 浮点数类型 */ x); constexpr float fabsf(float x); constexpr long double fabsl(long double x); /* 浮点数类型 */ hypot(/* 浮点数类型 */ x, /* 浮点数类型 */ y); float hypotf(float x, float y); long double hypotl(long double x, long double y); // 三维斜边 float hypot(/* 浮点数类型 */ x, /* 浮点数类型 */ y, /* 浮点数类型 */ z); /* 浮点数类型 */ pow(/* 浮点数类型 */ x, /* 浮点数类型 */ y); float powf(float x, float y); long double powl(long double x, long double y); /* 浮点数类型 */ sqrt(/* 浮点数类型 */ x); float sqrtf(float x); long double sqrtl(long double x); /* 浮点数类型 */ erf(/* 浮点数类型 */ x); float erff(float x); long double erfl(long double x); /* 浮点数类型 */ erfc(/* 浮点数类型 */ x); float erfcf(float x); long double erfcl(long double x); /* 浮点数类型 */ lgamma(/* 浮点数类型 */ x); float lgammaf(float x); long double lgammal(long double x); /* 浮点数类型 */ tgamma(/* 浮点数类型 */ x); float tgammaf(float x); long double tgammal(long double x); constexpr /* 浮点数类型 */ ceil(/* 浮点数类型 */ x); constexpr float ceilf(float x); constexpr long double ceill(long double x); constexpr /* 浮点数类型 */ floor(/* 浮点数类型 */ x); constexpr float floorf(float x); constexpr long double floorl(long double x); /* 浮点数类型 */ nearbyint(/* 浮点数类型 */ x); float nearbyintf(float x); long double nearbyintl(long double x); /* 浮点数类型 */ rint(/* 浮点数类型 */ x); float rintf(float x); long double rintl(long double x); long int lrint(/* 浮点数类型 */ x); long int lrintf(float x); long int lrintl(long double x); long long int llrint(/* 浮点数类型 */ x); long long int llrintf(float x); long long int llrintl(long double x); constexpr /* 浮点数类型 */ round(/* 浮点数类型 */ x); constexpr float roundf(float x); constexpr long double roundl(long double x); constexpr long int lround(/* 浮点数类型 */ x); constexpr long int lroundf(float x); constexpr long int lroundl(long double x); constexpr long long int llround(/* 浮点数类型 */ x); constexpr long long int llroundf(float x); constexpr long long int llroundl(long double x); constexpr /* 浮点数类型 */ trunc(/* 浮点数类型 */ x); constexpr float truncf(float x); constexpr long double truncl(long double x); constexpr /* 浮点数类型 */ fmod(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr float fmodf(float x, float y); constexpr long double fmodl(long double x, long double y); constexpr /* 浮点数类型 */ remainder(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr float remainderf(float x, float y); constexpr long double remainderl(long double x, long double y); constexpr /* 浮点数类型 */ remquo(/* 浮点数类型 */ x, /* 浮点数类型 */ y, int* quo); constexpr float remquof(float x, float y, int* quo); constexpr long double remquol(long double x, long double y, int* quo); constexpr /* 浮点数类型 */ copysign(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr float copysignf(float x, float y); constexpr long double copysignl(long double x, long double y); double nan(const char* tagp); float nanf(const char* tagp); long double nanl(const char* tagp); constexpr /* 浮点数类型 */ nextafter(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr float nextafterf(float x, float y); constexpr long double nextafterl(long double x, long double y); constexpr /* 浮点数类型 */ nexttoward(/* 浮点数类型 */ x, long double y); constexpr float nexttowardf(float x, long double y); constexpr long double nexttowardl(long double x, long double y); constexpr /* 浮点数类型 */ nextup(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr float nextupf(float x, float y); constexpr long double nextupl(long double x, long double y); constexpr /* 浮点数类型 */ nextdown(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr float nextdownf(float x, float y); constexpr long double nextdownl(long double x, long double y); constexpr /* 浮点数类型 */ fdim(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr float fdimf(float x, float y); constexpr long double fdiml(long double x, long double y); constexpr /* 浮点数类型 */ fmax(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr float fmaxf(float x, float y); constexpr long double fmaxl(long double x, long double y); constexpr /* 浮点数类型 */ fmin(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr float fminf(float x, float y); constexpr long double fminl(long double x, long double y); constexpr /* 浮点数类型 */ fma(/* 浮点数类型 */ x, /* 浮点数类型 */ y, /* 浮点数类型 */ z); constexpr float fmaf(float x, float y, float z); constexpr long double fmal(long double x, long double y, long double z); // 线性插值 constexpr /* 浮点数类型 */ lerp(/* 浮点数类型 */ a, /* 浮点数类型 */ b, /* 浮点数类型 */ t) noexcept; // 分类/比较函数 constexpr int fpclassify(/* 浮点数类型 */ x); constexpr bool isfinite(/* 浮点数类型 */ x); constexpr bool isinf(/* 浮点数类型 */ x); constexpr bool isnan(/* 浮点数类型 */ x); constexpr bool isnormal(/* 浮点数类型 */ x); constexpr bool signbit(/* 浮点数类型 */ x); constexpr bool isgreater(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr bool isgreaterequal(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr bool isless(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr bool islessequal(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr bool islessgreater(/* 浮点数类型 */ x, /* 浮点数类型 */ y); constexpr bool isunordered(/* 浮点数类型 */ x, /* 浮点数类型 */ y); // 数学特殊函数 // 连带拉盖尔多项式 /* 浮点数类型 */ assoc_laguerre(unsigned n, unsigned m, /* 浮点数类型 */ x); float assoc_laguerref(unsigned n, unsigned m, float x); long double assoc_laguerrel(unsigned n, unsigned m, long double x); // 连带勒让德多项式 /* 浮点数类型 */ assoc_legendre(unsigned l, unsigned m, /* 浮点数类型 */ x); float assoc_legendref(unsigned l, unsigned m, float x); long double assoc_legendrel(unsigned l, unsigned m, long double x); // beta 函数 /* 浮点数类型 */ beta(/* 浮点数类型 */ x, /* 浮点数类型 */ y); float betaf(float x, float y); long double betal(long double x, long double y); // 第一类完全椭圆积分 /* 浮点数类型 */ comp_ellint_1(/* 浮点数类型 */ k); float comp_ellint_1f(float k); long double comp_ellint_1l(long double k); // 第二类完全椭圆积分 /* 浮点数类型 */ comp_ellint_2(/* 浮点数类型 */ k); float comp_ellint_2f(float k); long double comp_ellint_2l(long double k); // 第三类完全椭圆积分 /* 浮点数类型 */ comp_ellint_3(/* 浮点数类型 */ k, /* 浮点数类型 */ nu); float comp_ellint_3f(float k, float nu); long double comp_ellint_3l(long double k, long double nu); // 规则变形圆柱贝塞尔函数 /* 浮点数类型 */ cyl_bessel_i(/* 浮点数类型 */ nu, /* 浮点数类型 */ x); float cyl_bessel_if(float nu, float x); long double cyl_bessel_il(long double nu, long double x); // 第一类圆柱贝塞尔函数 /* 浮点数类型 */ cyl_bessel_j(/* 浮点数类型 */ nu, /* 浮点数类型 */ x); float cyl_bessel_jf(float nu, float x); long double cyl_bessel_jl(long double nu, long double x); // 不规则变形圆柱贝塞尔函数 /* 浮点数类型 */ cyl_bessel_k(/* 浮点数类型 */ nu, /* 浮点数类型 */ x); float cyl_bessel_kf(float nu, float x); long double cyl_bessel_kl(long double nu, long double x); // 圆柱诺伊曼函数; // 第二类圆柱贝塞尔函数 /* 浮点数类型 */ cyl_neumann(/* 浮点数类型 */ nu, /* 浮点数类型 */ x); float cyl_neumannf(float nu, float x); long double cyl_neumannl(long double nu, long double x); // 第一类不完全椭圆积分 /* 浮点数类型 */ ellint_1(/* 浮点数类型 */ k, /* 浮点数类型 */ phi); float ellint_1f(float k, float phi); long double ellint_1l(long double k, long double phi); // 第二类不完全椭圆积分 /* 浮点数类型 */ ellint_2(/* 浮点数类型 */ k, /* 浮点数类型 */ phi); float ellint_2f(float k, float phi); long double ellint_2l(long double k, long double phi); // 第三类不完全椭圆积分 /* 浮点数类型 */ ellint_3(/* 浮点数类型 */ k, /* 浮点数类型 */ nu, /* 浮点数类型 */ phi); float ellint_3f(float k, float nu, float phi); long double ellint_3l(long double k, long double nu, long double phi); // 指数积分 /* 浮点数类型 */ expint(/* 浮点数类型 */ x); float expintf(float x); long double expintl(long double x); // 埃尔米特多项式 /* 浮点数类型 */ hermite(unsigned n, /* 浮点数类型 */ x); float hermitef(unsigned n, float x); long double hermitel(unsigned n, long double x); // 拉盖尔多项式 /* 浮点数类型 */ laguerre(unsigned n, /* 浮点数类型 */ x); float laguerref(unsigned n, float x); long double laguerrel(unsigned n, long double x); // 勒让德多项式 /* 浮点数类型 */ legendre(unsigned l, /* 浮点数类型 */ x); float legendref(unsigned l, float x); long double legendrel(unsigned l, long double x); // 黎曼 zeta 函数 /* 浮点数类型 */ riemann_zeta(/* 浮点数类型 */ x); float riemann_zetaf(float x); long double riemann_zetal(long double x); // 第一类球面贝塞尔函数 /* 浮点数类型 */ sph_bessel(unsigned n, /* 浮点数类型 */ x); float sph_besself(unsigned n, float x); long double sph_bessell(unsigned n, long double x); // 球面连带勒让德函数 /* 浮点数类型 */ sph_legendre(unsigned l, unsigned m, /* 浮点数类型 */ theta); float sph_legendref(unsigned l, unsigned m, float theta); long double sph_legendrel(unsigned l, unsigned m, long double theta); // 球面诺依曼函数; // 第二类球面贝塞尔函数 /* 浮点数类型 */ sph_neumann(unsigned n, /* 浮点数类型 */ x); float sph_neumannf(unsigned n, float x); long double sph_neumannl(unsigned n, long double x); }