feat(math): exp/log/pow/sqrt/cbrt/hypot/log1p/expm1
This commit is contained in:
+164
@@ -463,6 +463,170 @@ llround(double x);
|
||||
long long
|
||||
llroundl(long double x);
|
||||
|
||||
/*
|
||||
* e raised to the power x (C23 7.12.6.1). exp(+0) == exp(-0) == 1;
|
||||
* exp(-Inf) == +0; exp(+Inf) == +Inf; exp(NaN) == NaN. A result too
|
||||
* large or too small is a range error and sets errno to ERANGE, so no
|
||||
* const attribute.
|
||||
*/
|
||||
double
|
||||
exp(double x);
|
||||
|
||||
float
|
||||
expf(float x);
|
||||
|
||||
long double
|
||||
expl(long double x);
|
||||
|
||||
/*
|
||||
* 2 raised to the power x (C23 7.12.6.2). exp2(+0) == exp2(-0) == 1;
|
||||
* exp2(-Inf) == +0; exp2(+Inf) == +Inf; exp2(NaN) == NaN. A result too
|
||||
* large or too small is a range error and sets errno to ERANGE, so no
|
||||
* const attribute.
|
||||
*/
|
||||
double
|
||||
exp2(double x);
|
||||
|
||||
float
|
||||
exp2f(float x);
|
||||
|
||||
long double
|
||||
exp2l(long double x);
|
||||
|
||||
/*
|
||||
* e raised to the power x minus 1 (C23 7.12.6.3). expm1(+0) == +0;
|
||||
* expm1(-0) == -0; expm1(-Inf) == -1; expm1(+Inf) == +Inf;
|
||||
* expm1(NaN) == NaN. A result too large is a range error and sets
|
||||
* errno to ERANGE, so no const attribute.
|
||||
*/
|
||||
double
|
||||
expm1(double x);
|
||||
|
||||
float
|
||||
expm1f(float x);
|
||||
|
||||
long double
|
||||
expm1l(long double x);
|
||||
|
||||
/*
|
||||
* Natural logarithm of x (C23 7.12.6.7). log(+0) == log(-0) == -Inf;
|
||||
* log(1) == 0; log(-x) == NaN (domain error); log(+Inf) == +Inf;
|
||||
* log(NaN) == NaN. A negative argument is a domain error setting errno
|
||||
* to EDOM and a zero argument is a range error setting errno to ERANGE,
|
||||
* so no const attribute.
|
||||
*/
|
||||
double
|
||||
log(double x);
|
||||
|
||||
float
|
||||
logf(float x);
|
||||
|
||||
long double
|
||||
logl(long double x);
|
||||
|
||||
/*
|
||||
* Base-2 logarithm of x (C23 7.12.6.8). log2(1) == 0; log2(2) == 1.
|
||||
* Special values, domain errors, and range errors as for log, so no
|
||||
* const attribute.
|
||||
*/
|
||||
double
|
||||
log2(double x);
|
||||
|
||||
float
|
||||
log2f(float x);
|
||||
|
||||
long double
|
||||
log2l(long double x);
|
||||
|
||||
/*
|
||||
* Base-10 logarithm of x (C23 7.12.6.9). log10(1) == 0; log10(10) == 1.
|
||||
* Special values, domain errors, and range errors as for log, so no
|
||||
* const attribute.
|
||||
*/
|
||||
double
|
||||
log10(double x);
|
||||
|
||||
float
|
||||
log10f(float x);
|
||||
|
||||
long double
|
||||
log10l(long double x);
|
||||
|
||||
/*
|
||||
* Natural logarithm of 1 + x (C23 7.12.6.13). log1p(+-0) == +-0;
|
||||
* log1p(-1) == -Inf (a pole error setting errno to ERANGE); log1p(x) for
|
||||
* x < -1 is a domain error setting errno to EDOM; log1p(+Inf) == +Inf;
|
||||
* log1p(NaN) == NaN. Accurate for x close to 0, so no const attribute.
|
||||
*/
|
||||
double
|
||||
log1p(double x);
|
||||
|
||||
float
|
||||
log1pf(float x);
|
||||
|
||||
long double
|
||||
log1pl(long double x);
|
||||
|
||||
/*
|
||||
* Principal square root of x (C23 7.12.5.4). sqrt(+-0) == +-0; sqrt(x)
|
||||
* for x < 0 is a domain error returning NaN and setting errno to EDOM;
|
||||
* sqrt(+Inf) == +Inf; sqrt(NaN) == NaN. Correctly rounded; no const
|
||||
* attribute because of the errno path.
|
||||
*/
|
||||
double
|
||||
sqrt(double x);
|
||||
|
||||
float
|
||||
sqrtf(float x);
|
||||
|
||||
long double
|
||||
sqrtl(long double x);
|
||||
|
||||
/*
|
||||
* Cube root of x (C23 7.12.5.5). cbrt(+-0) == +-0; cbrt(+-Inf) == +-Inf;
|
||||
* cbrt(NaN) == NaN; cbrt(-x) == -cbrt(x). Defined for all reals and never
|
||||
* sets errno.
|
||||
*/
|
||||
double
|
||||
cbrt(double x);
|
||||
|
||||
float
|
||||
cbrtf(float x);
|
||||
|
||||
long double
|
||||
cbrtl(long double x);
|
||||
|
||||
/*
|
||||
* Square root of x*x + y*y without undue overflow or underflow
|
||||
* (C23 7.12.5.6). hypot(+-0, +-0) == +0; hypot(+-Inf, y) == +Inf even for
|
||||
* NaN y; hypot(x, NaN) == NaN for finite x. The internal scaling avoids
|
||||
* spurious overflow, so no errno path exists.
|
||||
*/
|
||||
double
|
||||
hypot(double x, double y);
|
||||
|
||||
float
|
||||
hypotf(float x, float y);
|
||||
|
||||
long double
|
||||
hypotl(long double x, long double y);
|
||||
|
||||
/*
|
||||
* x raised to the power y (C23 7.12.6.11). pow(x, 0) == 1; pow(1, y) == 1
|
||||
* even for NaN y; pow(NaN, 0) == 1; pow(+-0, negative y) == +-Inf (a pole
|
||||
* error setting errno to ERANGE); pow(negative finite x, non-integer y) is
|
||||
* a domain error setting errno to EDOM; overflow and underflow set errno to
|
||||
* ERANGE. No const attribute.
|
||||
*/
|
||||
double
|
||||
pow(double x, double y);
|
||||
|
||||
float
|
||||
powf(float x, float y);
|
||||
|
||||
long double
|
||||
powl(long double x, long double y);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user