mirror of https://github.com/flysand7/ciabatta.git
Complete tgmath.h
This commit is contained in:
parent
06aa9a096c
commit
be2c9d132e
155
inc/tgmath.h
155
inc/tgmath.h
|
@ -4,85 +4,98 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define _tg_is_ld(x) (sizeof(x) == sizeof(long double))
|
#define _tg_is_ld(x) (sizeof(x) == sizeof(long double))
|
||||||
#define _tg_is_d (x) (sizeof(x) == sizeof(double))
|
#define _tg_is_d(x) (sizeof(x) == sizeof(double))
|
||||||
|
|
||||||
#define _tg_is_ld2(x,y) (_tg_is_ld(x) || _tg_is_ld(y))
|
#define _tg_is_ld2(x,y) (_tg_is_ld(x) || _tg_is_ld(y))
|
||||||
#define _tg_is_d2 (x,y) (_tg_is_d (x) || _tg_is_d (y))
|
#define _tg_is_d2(x,y) (_tg_is_d (x) || _tg_is_d (y))
|
||||||
|
|
||||||
#define _tg_func1(func, x) ( _tg_is_ld(x) ? (func ## l)(x) \
|
#define _tg_is_ld3(x,y,z) (_tg_is_ld(x) || _tg_is_ld(y) || _tg_is_ld(z))
|
||||||
: _tg_is_d(x) ? (func)(x) \
|
#define _tg_is_d3(x,y,z) (_tg_is_d (x) || _tg_is_d (y) || _tg_is_d (z))
|
||||||
: (func ## f)(x) )
|
|
||||||
|
|
||||||
#define _tf_func2(func, x, t) ( _tg_is_ld2(x,y) ? (func ## l)(x,y) \
|
|
||||||
: _tg_is_d2(x,y) ? (func)(x,y) \
|
|
||||||
: (func ## f)(x,y) )
|
|
||||||
|
|
||||||
#define cos (x) _tg_func1(cos, x)
|
#define _tg_func1(func,x) ( _tg_is_ld(x) ? (func ## l)(x) \
|
||||||
#define sin (x) _tg_func1(sin, x)
|
: _tg_is_d(x) ? (func)(x) \
|
||||||
#define tan (x) _tg_func1(tan, x)
|
: (func ## f)(x) )
|
||||||
#define acos (x) _tg_func1(acos, x)
|
|
||||||
#define asin (x) _tg_func1(asin, x)
|
|
||||||
#define atan (x) _tg_func1(atan, x)
|
|
||||||
#define atan2 (x,y) _tg_func2(atan2, x, y)
|
|
||||||
|
|
||||||
#define cosh (x) _tg_func1(cosh, x)
|
|
||||||
#define sinh (x) _tg_func1(sinh, x)
|
|
||||||
#define tanh (x) _tg_func1(tanh, x)
|
|
||||||
#define acosh (x) _tg_func1(acosh, x)
|
|
||||||
#define asinh (x) _tg_func1(asinh, x)
|
|
||||||
#define atanh (x) _tg_func1(atanh, x)
|
|
||||||
|
|
||||||
#define exp (x) _tg_func1(exp, x)
|
#define _tg_func1p(func,x,p) ( _tg_is_ld(x) ? (func ## l)(x,p) \
|
||||||
#define exp2 (x) _tg_func1(exp2, x)
|
: _tg_is_d(x) ? (func)(x,p) \
|
||||||
#define pow (x,y) _tg_func2(pow, x, y)
|
: (func ## f)(x,p) )
|
||||||
#define log (x,y) _tg_func2(log, x, y)
|
|
||||||
#define sqrt (x) _tg_func1(sqrt, x)
|
|
||||||
#define cbrt (x) _tg_func1(cbrt, x)
|
|
||||||
#define fabs (x) _tg_func1(fabs, x)
|
|
||||||
|
|
||||||
#define ceil (x) _tg_func1(ceil, x)
|
#define _tg_func2(func,x,y) ( _tg_is_ld2(x,y) ? (func ## l)(x,y) \
|
||||||
#define floor (x) _tg_func1(floor, x)
|
: _tg_is_d2(x,y) ? (func)(x,y) \
|
||||||
#define round (x) _tg_func1(round, x)
|
: (func ## f)(x,y) )
|
||||||
#define trunc (x) _tg_func1(trunc, x)
|
|
||||||
|
|
||||||
#define copysign(x,y) _tg_func2(copysign, x, y)
|
#define _tg_func2p(func,x,y,p) ( _tg_is_ld2(x,y) ? (func ## l)(x,y,p) \
|
||||||
|
: _tg_is_d2(x,y) ? (func)(x,y,p) \
|
||||||
|
: (func ## f)(x,y,p) )
|
||||||
|
|
||||||
#define fmax (x,y) _tg_func2(fmax, x, y)
|
|
||||||
#define fmin (x,y) _tg_func2(fmin, x, y)
|
|
||||||
#define fmod (x,y) _tg_func2(fmod, x, y)
|
|
||||||
|
|
||||||
/*
|
#define _tg_func3(func,x,y,z) ( _tg_is_ld3(x,y,z) ? (func ## l)(x,y,z) \
|
||||||
erf
|
: _tg_is_d3(x,y,z) ? (func)(x,y,z) \
|
||||||
erfc
|
: (func ## f)(x,y,z) )
|
||||||
exp2
|
|
||||||
expm1
|
#define cos(x) _tg_func1(cos, x)
|
||||||
fdim
|
#define sin(x) _tg_func1(sin, x)
|
||||||
fma
|
#define tan(x) _tg_func1(tan, x)
|
||||||
frexp
|
#define acos(x) _tg_func1(acos, x)
|
||||||
hypot
|
#define asin(x) _tg_func1(asin, x)
|
||||||
ilogb
|
#define atan(x) _tg_func1(atan, x)
|
||||||
ldexp
|
#define atan2(x,y) _tg_func2(atan2, x, y)
|
||||||
lgamma
|
|
||||||
llrint
|
#define cosh(x) _tg_func1(cosh, x)
|
||||||
llround
|
#define sinh(x) _tg_func1(sinh, x)
|
||||||
log10
|
#define tanh(x) _tg_func1(tanh, x)
|
||||||
log1p
|
#define acosh(x) _tg_func1(acosh, x)
|
||||||
log2
|
#define asinh(x) _tg_func1(asinh, x)
|
||||||
logb
|
#define atanh(x) _tg_func1(atanh, x)
|
||||||
lrint
|
|
||||||
lround
|
#define exp(x) _tg_func1(exp, x)
|
||||||
nearbyint
|
#define exp2(x) _tg_func1(exp2, x)
|
||||||
nextafter
|
#define expm1(x) _tg_func1(expm1, x)
|
||||||
nexttoward
|
#define pow(x,y) _tg_func2(pow, x, y)
|
||||||
remainder
|
#define log(x,y) _tg_func2(log, x, y)
|
||||||
remquo
|
#define sqrt(x) _tg_func1(sqrt, x)
|
||||||
rint
|
#define cbrt(x) _tg_func1(cbrt, x)
|
||||||
scalbn
|
#define hypot(x,y) _tg_func2(hypot, x, y)
|
||||||
scalbln
|
|
||||||
tgamma
|
#define log10(x) _tg_func1(log10, x)
|
||||||
carg
|
#define log1p(x) _tg_func1(log1p, x)
|
||||||
cimag
|
#define log2(x) _tg_func1(log2, x)
|
||||||
conj
|
#define logb(x) _tg_func1(logb, x)
|
||||||
cproj
|
#define ilogb(x) _tg_func1(ilogb, x)
|
||||||
creal
|
|
||||||
*/
|
#define ceil(x) _tg_func1(ceil, x)
|
||||||
|
#define floor(x) _tg_func1(floor, x)
|
||||||
|
#define trunc(x) _tg_func1(trunc, x)
|
||||||
|
#define llrint(x) _tg_func1(llrint, x)
|
||||||
|
#define lrint(x) _tg_func1(lrint, x)
|
||||||
|
#define rint(x) _tg_func1(rint, x)
|
||||||
|
#define llround(x) _tg_func1(llround, x)
|
||||||
|
#define lround(x) _tg_func1(lround, x)
|
||||||
|
#define round(x) _tg_func1(round, x)
|
||||||
|
#define nearbyint(x) _tg_func1(nearbyint, x)
|
||||||
|
|
||||||
|
#define erf(x) _tg_func1(erf, x)
|
||||||
|
#define erfc(x) _tg_func1(erfc, x)
|
||||||
|
#define tgamma(x) _tg_func1(tgamma, x)
|
||||||
|
#define lgamma(x) _tg_func1(lgamma, x)
|
||||||
|
|
||||||
|
#define fabs(x) _tg_func1(fabs, x)
|
||||||
|
#define fdim(x,y) _tg_func2(fdim, x, y)
|
||||||
|
#define fmax(x,y) _tg_func2(fmax, x, y)
|
||||||
|
#define fmin(x,y) _tg_func2(fmin, x, y)
|
||||||
|
#define fmod(x,y) _tg_func2(fmod, x, y)
|
||||||
|
#define remainder(x,y) _tg_func2(remainder, x, y)
|
||||||
|
#define remquo(x,y,p) _tg_func2p(remquo, x, y, p)
|
||||||
|
#define fma(x,y,z) _tg_func3(fma, x, y, z)
|
||||||
|
|
||||||
|
#define copysign(x,y) _tg_func2(copysign, x, y)
|
||||||
|
#define frexp(x,p) _tg_func1p(frexp, x, p)
|
||||||
|
#define ldexp(x,p) _tg_func1p(ldexp, x, p)
|
||||||
|
#define modf(x,p) _tg_func1p(modf, x, p)
|
||||||
|
#define scalbn(x,p) _tg_func1p(scalbn, x, p)
|
||||||
|
#define scalbln(x,p) _tg_func1p(scalbln, x, p)
|
||||||
|
|
||||||
|
#define nextafter(x,y) _tg_func2(nextafter, x, y)
|
||||||
|
#define nexttoward(x,y) _tg_func2(nexttoward, x, y)
|
||||||
|
|
8
todo
8
todo
|
@ -31,14 +31,12 @@ math.h:
|
||||||
other stuff?
|
other stuff?
|
||||||
|
|
||||||
stdio.h:
|
stdio.h:
|
||||||
Basically everything
|
Formatted print, scan
|
||||||
|
|
||||||
stdlib.h:
|
stdlib.h:
|
||||||
qsort
|
Strtod base 16 must be correctly rounded
|
||||||
|
Multibyte string functions
|
||||||
Better PRNG
|
Better PRNG
|
||||||
MB_CUR_MAX should be locale-dependent
|
|
||||||
strtod base 16 should be correctly rounded
|
|
||||||
Probably other stuff
|
|
||||||
|
|
||||||
threads.h:
|
threads.h:
|
||||||
TODO: add todo items
|
TODO: add todo items
|
||||||
|
|
Loading…
Reference in New Issue