ciabatta/inc/math.h

221 lines
4.7 KiB
C
Raw Normal View History

#pragma once
2022-06-02 06:28:17 +00:00
typedef float float_t;
typedef double double_t;
#ifndef _HUGE_ENUF
2022-06-09 01:59:48 +00:00
#define _HUGE_ENUF 1e+300 // _HUGE_ENUF*_HUGE_ENUF must overflow
2022-06-02 06:28:17 +00:00
#endif
#define INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
#define HUGE_VAL ((double)INFINITY)
#define HUGE_VALF ((float)INFINITY)
#define NAN (-(float)(INFINITY * 0.0F))
2022-06-08 04:34:37 +00:00
// FP_ILOGB0
// FP_ILOGBNAN
2022-06-09 09:04:39 +00:00
#define MATH_ERRNO 1
#define MATH_ERREXCEPT 2
2022-06-08 04:34:37 +00:00
#define math_errhandling MATH_ERRNO
2022-06-09 09:04:39 +00:00
// Classification
2022-06-08 04:34:37 +00:00
#define FP_INFINITE 0
#define FP_NAN 1
#define FP_NORMAL 2
#define FP_SUBNORMAL 3
#define FP_ZERO 4
2022-06-09 09:04:39 +00:00
int _fpclassify(double f);
int _fpclassifyf(float f);
#define fpclassify(x) (sizeof(x)==4?_fpclassifyf(x):_fpclassify(x))
#define isfinite(x) (fpclassify(x) != FP_INFINITE && fpclassify(x) != FP_NAN)
#define isinf(x) (fpclassify(x) == FP_INFINITE)
#define isnan(x) (fpclassify(x) == FP_NAN)
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
// Sign bit shit
int _signbit(double f);
int _signbitf(float f);
#define signbit(x) (sizeof(x)==4?_signbitf(x):signbit(x))
float copysignf(float x, float y);
// Ordering
#define isgreater(x) (sizeof(x)==4?_isgrtf(x):_isgrt(x))
#define isgreaterequal(x) (sizeof(x)==4?_isgeqf(x):_isgeq(x))
#define isless(x) (sizeof(x)==4?_islesf(x):_isles(x))
#define islessequal(x) (sizeof(x)==4?_isleqf(x):_isleq(x))
#define islessgreater(x) (sizeof(x)==4?_islegf(x):_isleg(x))
#define isunordered(x) (sizeof(x)==4?_isunof(x):_isuno(x))
double acos(double x);
float acosf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double asin(double x);
float asinf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double atan(double x);
float atanf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double atan2(double y, double x);
float atan2f(float y, float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double cos(double x);
float cosf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double sin(double x);
float sinf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double tan(double x);
float tanf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double acosh(double x);
float acoshf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double asinh(double x);
float asinhf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double atanh(double x);
float atanhf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double cosh(double x);
float coshf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double sinh(double x);
float sinhf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double tanh(double x);
float tanhf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double exp(double x);
float expf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double exp2(double x);
float exp2f(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double expm1(double x);
float expm1f(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double frexp(double value, int *exp);
float frexpf(float value, int *exp);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
int ilogb(double x);
int ilogbf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double ldexp(double x, int exp);
float ldexpf(float x, int exp);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double log(double x);
float logf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double log10(double x);
float log10f(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double log1p(double x);
float log1pf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double log2(double x);
float log2f(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double logb(double x);
float logbf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double modf(double value, double *iptr);
float modff(float value, float *iptr);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double scalbn(double x, int n);
float scalbnf(float x, int n);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double scalbln(double x, long int n);
float scalblnf(float x, long int n);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double cbrt(double x);
float cbrtf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double fabs(double x);
float fabsf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double hypot(double x, double y);
float hypotf(float x, float y);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double pow(double x, double y);
float powf(float x, float y);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double sqrt(double x);
float sqrtf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double erf(double x);
float erff(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double erfc(double x);
float erfcf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double lgamma(double x);
float lgammaf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double tgamma(double x);
float tgammaf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double ceil(double x);
float ceilf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double floor(double x);
float floorf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double nearbyint(double x);
float nearbyintf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double rint(double x);
float rintf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
long int lrint(double x);
long int lrintf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
long long int llrint(double x);
long long int llrintf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double round(double x);
float roundf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
long int lround(double x);
long int lroundf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
long long int llround(double x);
long long int llroundf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double trunc(double x);
float truncf(float x);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double fmod(double x, double y);
float fmodf(float x, float y);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double remainder(double x, double y);
float remainderf(float x, float y);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double remquo(double x, double y, int *quo);
float remquof(float x, float y, int *quo);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double copysign(double x, double y);
float copysignf(float x, float y);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double nan(const char *tagp);
float nanf(const char *tagp);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double nextafter(double x, double y);
float nextafterf(float x, float y);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double fdim(double x, double y);
float fdimf(float x, float y);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double fmax(double x, double y);
float fmaxf(float x, float y);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double fmin(double x, double y);
float fminf(float x, float y);
2022-06-08 04:34:37 +00:00
2022-06-02 06:28:17 +00:00
double fma(double x, double y, double z);
float fmaf(float x, float y, float z);
2022-06-08 04:34:37 +00:00