123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- #ifndef _MATH_H
- #define _MATH_H 1
- #include <features.h>
- __BEGIN_DECLS
- #include <bits/math-vector.h>
- #include <bits/huge_val.h>
- #ifdef __USE_ISOC99
- # include <bits/huge_valf.h>
- # include <bits/huge_vall.h>
- # include <bits/inf.h>
- # include <bits/nan.h>
- #endif
- #include <bits/mathdef.h>
- #define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function)
- #define __MATHCALL_VEC(function, suffix, args) \
- __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
- __MATHCALL (function, suffix, args)
- #define __MATHDECL_VEC(type, function,suffix, args) \
- __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
- __MATHDECL(type, function,suffix, args)
- #define __MATHCALL(function,suffix, args) \
- __MATHDECL (_Mdouble_,function,suffix, args)
- #define __MATHDECL(type, function,suffix, args) \
- __MATHDECL_1(type, function,suffix, args); \
- __MATHDECL_1(type, __CONCAT(__,function),suffix, args)
- #define __MATHCALLX(function,suffix, args, attrib) \
- __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
- #define __MATHDECLX(type, function,suffix, args, attrib) \
- __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
- __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
- #define __MATHDECL_1(type, function,suffix, args) \
- extern type __MATH_PRECNAME(function,suffix) args __THROW
- #define _Mdouble_ double
- #define __MATH_PRECNAME(name,r) __CONCAT(name,r)
- #define __MATH_DECLARING_DOUBLE 1
- #define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
- #define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD
- #include <bits/mathcalls.h>
- #undef _Mdouble_
- #undef _Mdouble_BEGIN_NAMESPACE
- #undef _Mdouble_END_NAMESPACE
- #undef __MATH_PRECNAME
- #undef __MATH_DECLARING_DOUBLE
- #ifdef __USE_ISOC99
- # ifndef _Mfloat_
- # define _Mfloat_ float
- # endif
- # define _Mdouble_ _Mfloat_
- # define __MATH_PRECNAME(name,r) name##f##r
- # define __MATH_DECLARING_DOUBLE 0
- # define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
- # define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
- # include <bits/mathcalls.h>
- # undef _Mdouble_
- # undef _Mdouble_BEGIN_NAMESPACE
- # undef _Mdouble_END_NAMESPACE
- # undef __MATH_PRECNAME
- # undef __MATH_DECLARING_DOUBLE
- # if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
- || defined __LDBL_COMPAT \
- || defined _LIBC_TEST
- # ifdef __LDBL_COMPAT
- # ifdef __USE_ISOC99
- extern float __nldbl_nexttowardf (float __x, long double __y)
- __THROW __attribute__ ((__const__));
- # ifdef __REDIRECT_NTH
- extern float __REDIRECT_NTH (nexttowardf, (float __x, long double __y),
- __nldbl_nexttowardf)
- __attribute__ ((__const__));
- extern double __REDIRECT_NTH (nexttoward, (double __x, long double __y),
- nextafter) __attribute__ ((__const__));
- extern long double __REDIRECT_NTH (nexttowardl,
- (long double __x, long double __y),
- nextafter) __attribute__ ((__const__));
- # endif
- # endif
- # undef __MATHDECL_1
- # define __MATHDECL_2(type, function,suffix, args, alias) \
- extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \
- args, alias)
- # define __MATHDECL_1(type, function,suffix, args) \
- __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
- # endif
- # ifndef _Mlong_double_
- # define _Mlong_double_ long double
- # endif
- # define _Mdouble_ _Mlong_double_
- # define __MATH_PRECNAME(name,r) name##l##r
- # define __MATH_DECLARING_DOUBLE 0
- # define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
- # define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
- # define __MATH_DECLARE_LDOUBLE 1
- # include <bits/mathcalls.h>
- # undef _Mdouble_
- # undef _Mdouble_BEGIN_NAMESPACE
- # undef _Mdouble_END_NAMESPACE
- # undef __MATH_PRECNAME
- # undef __MATH_DECLARING_DOUBLE
- # endif
- #endif
- #undef __MATHDECL_1
- #undef __MATHDECL
- #undef __MATHCALL
- #if defined __USE_MISC || defined __USE_XOPEN
- extern int signgam;
- #endif
- #ifdef __USE_ISOC99
- enum
- {
- FP_NAN =
- # define FP_NAN 0
- FP_NAN,
- FP_INFINITE =
- # define FP_INFINITE 1
- FP_INFINITE,
- FP_ZERO =
- # define FP_ZERO 2
- FP_ZERO,
- FP_SUBNORMAL =
- # define FP_SUBNORMAL 3
- FP_SUBNORMAL,
- FP_NORMAL =
- # define FP_NORMAL 4
- FP_NORMAL
- };
- # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ \
- && !defined __OPTIMIZE_SIZE__
- # define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \
- FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
- # elif defined __NO_LONG_DOUBLE_MATH
- # define fpclassify(x) \
- (sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))
- # else
- # define fpclassify(x) \
- (sizeof (x) == sizeof (float) \
- ? __fpclassifyf (x) \
- : sizeof (x) == sizeof (double) \
- ? __fpclassify (x) : __fpclassifyl (x))
- # endif
- # if __GNUC_PREREQ (4,0)
- # define signbit(x) \
- (sizeof (x) == sizeof (float) \
- ? __builtin_signbitf (x) \
- : sizeof (x) == sizeof (double) \
- ? __builtin_signbit (x) : __builtin_signbitl (x))
- # else
- # ifdef __NO_LONG_DOUBLE_MATH
- # define signbit(x) \
- (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))
- # else
- # define signbit(x) \
- (sizeof (x) == sizeof (float) \
- ? __signbitf (x) \
- : sizeof (x) == sizeof (double) \
- ? __signbit (x) : __signbitl (x))
- # endif
- # endif
- # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
- # define isfinite(x) __builtin_isfinite (x)
- # elif defined __NO_LONG_DOUBLE_MATH
- # define isfinite(x) \
- (sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x))
- # else
- # define isfinite(x) \
- (sizeof (x) == sizeof (float) \
- ? __finitef (x) \
- : sizeof (x) == sizeof (double) \
- ? __finite (x) : __finitel (x))
- # endif
- # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
- # define isnormal(x) __builtin_isnormal (x)
- # else
- # define isnormal(x) (fpclassify (x) == FP_NORMAL)
- # endif
- # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
- # define isnan(x) __builtin_isnan (x)
- # elif defined __NO_LONG_DOUBLE_MATH
- # define isnan(x) \
- (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
- # else
- # define isnan(x) \
- (sizeof (x) == sizeof (float) \
- ? __isnanf (x) \
- : sizeof (x) == sizeof (double) \
- ? __isnan (x) : __isnanl (x))
- # endif
- # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
- # define isinf(x) __builtin_isinf_sign (x)
- # elif defined __NO_LONG_DOUBLE_MATH
- # define isinf(x) \
- (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))
- # else
- # define isinf(x) \
- (sizeof (x) == sizeof (float) \
- ? __isinff (x) \
- : sizeof (x) == sizeof (double) \
- ? __isinf (x) : __isinfl (x))
- # endif
- # define MATH_ERRNO 1
- # define MATH_ERREXCEPT 2
- # ifndef __FAST_MATH__
- # define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
- # endif
- #endif
- #ifdef __USE_GNU
- # ifdef __NO_LONG_DOUBLE_MATH
- # define issignaling(x) \
- (sizeof (x) == sizeof (float) ? __issignalingf (x) : __issignaling (x))
- # else
- # define issignaling(x) \
- (sizeof (x) == sizeof (float) \
- ? __issignalingf (x) \
- : sizeof (x) == sizeof (double) \
- ? __issignaling (x) : __issignalingl (x))
- # endif
- #endif
- #ifdef __USE_MISC
- typedef enum
- {
- _IEEE_ = -1,
- _SVID_,
- _XOPEN_,
- _POSIX_,
- _ISOC_
- } _LIB_VERSION_TYPE;
- extern _LIB_VERSION_TYPE _LIB_VERSION;
- #endif
- #ifdef __USE_MISC
- # ifdef __cplusplus
- struct __exception
- # else
- struct exception
- # endif
- {
- int type;
- char *name;
- double arg1;
- double arg2;
- double retval;
- };
- # ifdef __cplusplus
- extern int matherr (struct __exception *__exc) throw ();
- # else
- extern int matherr (struct exception *__exc);
- # endif
- # define X_TLOSS 1.41484755040568800000e+16
- # define DOMAIN 1
- # define SING 2
- # define OVERFLOW 3
- # define UNDERFLOW 4
- # define TLOSS 5
- # define PLOSS 6
- # define HUGE 3.40282347e+38F
- #else
- # ifdef __USE_XOPEN
- # define MAXFLOAT 3.40282347e+38F
- # endif
- #endif
- #if defined __USE_MISC || defined __USE_XOPEN
- # define M_E 2.7182818284590452354
- # define M_LOG2E 1.4426950408889634074
- # define M_LOG10E 0.43429448190325182765
- # define M_LN2 0.69314718055994530942
- # define M_LN10 2.30258509299404568402
- # define M_PI 3.14159265358979323846
- # define M_PI_2 1.57079632679489661923
- # define M_PI_4 0.78539816339744830962
- # define M_1_PI 0.31830988618379067154
- # define M_2_PI 0.63661977236758134308
- # define M_2_SQRTPI 1.12837916709551257390
- # define M_SQRT2 1.41421356237309504880
- # define M_SQRT1_2 0.70710678118654752440
- #endif
- #ifdef __USE_GNU
- # define M_El 2.718281828459045235360287471352662498L
- # define M_LOG2El 1.442695040888963407359924681001892137L
- # define M_LOG10El 0.434294481903251827651128918916605082L
- # define M_LN2l 0.693147180559945309417232121458176568L
- # define M_LN10l 2.302585092994045684017991454684364208L
- # define M_PIl 3.141592653589793238462643383279502884L
- # define M_PI_2l 1.570796326794896619231321691639751442L
- # define M_PI_4l 0.785398163397448309615660845819875721L
- # define M_1_PIl 0.318309886183790671537767526745028724L
- # define M_2_PIl 0.636619772367581343075535053490057448L
- # define M_2_SQRTPIl 1.128379167095512573896158903121545172L
- # define M_SQRT2l 1.414213562373095048801688724209698079L
- # define M_SQRT1_2l 0.707106781186547524400844362104849039L
- #endif
- #if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES
- # define __NO_MATH_INLINES 1
- #endif
- #if defined __USE_ISOC99 && __GNUC_PREREQ(2,97)
- # define isgreater(x, y) __builtin_isgreater(x, y)
- # define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
- # define isless(x, y) __builtin_isless(x, y)
- # define islessequal(x, y) __builtin_islessequal(x, y)
- # define islessgreater(x, y) __builtin_islessgreater(x, y)
- # define isunordered(u, v) __builtin_isunordered(u, v)
- #endif
- #ifdef __USE_EXTERN_INLINES
- # include <bits/mathinline.h>
- #endif
- #if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
- # include <bits/math-finite.h>
- #endif
- #ifdef __USE_ISOC99
- # ifndef isgreater
- # define isgreater(x, y) \
- (__extension__ \
- ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered (__x, __y) && __x > __y; }))
- # endif
- # ifndef isgreaterequal
- # define isgreaterequal(x, y) \
- (__extension__ \
- ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered (__x, __y) && __x >= __y; }))
- # endif
- # ifndef isless
- # define isless(x, y) \
- (__extension__ \
- ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered (__x, __y) && __x < __y; }))
- # endif
- # ifndef islessequal
- # define islessequal(x, y) \
- (__extension__ \
- ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered (__x, __y) && __x <= __y; }))
- # endif
- # ifndef islessgreater
- # define islessgreater(x, y) \
- (__extension__ \
- ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered (__x, __y) && (__x < __y || __y < __x); }))
- # endif
- # ifndef isunordered
- # define isunordered(u, v) \
- (__extension__ \
- ({ __typeof__(u) __u = (u); __typeof__(v) __v = (v); \
- fpclassify (__u) == FP_NAN || fpclassify (__v) == FP_NAN; }))
- # endif
- #endif
- __END_DECLS
- #endif
|