Source to include/math.h
0001 /*
0002 * ====================================================
0003 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
0004 *
0005 * Developed at SunPro, a Sun Microsystems, Inc. business.
0006 * Permission to use, copy, modify, and distribute this
0007 * software is freely granted, provided that this notice
0008 * is preserved.
0009 * ====================================================
0010 */
0011
0012 /*
0013 * from: @(#)fdlibm.h 5.1 93/09/24
0014 * $Id: math.h,v 1.1 1996/04/14 22:42:12 vandys Exp $
0015 */
0016
0017 #ifndef _MATH_H_
0018 #define _MATH_H_
0019
0020 /*
0021 * ANSI/POSIX
0022 */
0023 extern char __infinity[];
0024 #define HUGE_VAL (*(double *) __infinity)
0025
0026 /*
0027 * XOPEN/SVID
0028 */
0029 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
0030 #define M_E 2.7182818284590452354 /* e */
0031 #define M_LOG2E 1.4426950408889634074 /* log 2e */
0032 #define M_LOG10E 0.43429448190325182765 /* log 10e */
0033 #define M_LN2 0.69314718055994530942 /* log e2 */
0034 #define M_LN10 2.30258509299404568402 /* log e10 */
0035 #define M_PI 3.14159265358979323846 /* pi */
0036 #define M_PI_2 1.57079632679489661923 /* pi/2 */
0037 #define M_PI_4 0.78539816339744830962 /* pi/4 */
0038 #define M_1_PI 0.31830988618379067154 /* 1/pi */
0039 #define M_2_PI 0.63661977236758134308 /* 2/pi */
0040 #define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
0041 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
0042 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
0043
0044 #define MAXFLOAT ((float)3.40282346638528860e+38)
0045 extern int signgam;
0046
0047 #if !defined(_XOPEN_SOURCE)
0048 enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
0049
0050 #define _LIB_VERSION_TYPE enum fdversion
0051 #define _LIB_VERSION _fdlib_version
0052
0053 /* if global variable _LIB_VERSION is not desirable, one may
0054 * change the following to be a constant by:
0055 * #define _LIB_VERSION_TYPE const enum version
0056 * In that case, after one initializes the value _LIB_VERSION (see
0057 * s_lib_version.c) during compile time, it cannot be modified
0058 * in the middle of a program
0059 */
0060 extern _LIB_VERSION_TYPE _LIB_VERSION;
0061
0062 #define _IEEE_ fdlibm_ieee
0063 #define _SVID_ fdlibm_svid
0064 #define _XOPEN_ fdlibm_xopen
0065 #define _POSIX_ fdlibm_posix
0066
0067 struct exception {
0068 int type;
0069 char *name;
0070 double arg1;
0071 double arg2;
0072 double retval;
0073 };
0074
0075 #define HUGE MAXFLOAT
0076
0077 /*
0078 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
0079 * (one may replace the following line by "#include <values.h>")
0080 */
0081
0082 #define X_TLOSS 1.41484755040568800000e+16
0083
0084 #define DOMAIN 1
0085 #define SING 2
0086 #define OVERFLOW 3
0087 #define UNDERFLOW 4
0088 #define TLOSS 5
0089 #define PLOSS 6
0090
0091 #endif /* !_XOPEN_SOURCE */
0092 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
0093
0094
0095 /*
0096 * ANSI/POSIX
0097 */
0098 extern double acos (double);
0099 extern double asin (double);
0100 extern double atan (double);
0101 extern double atan2 (double, double);
0102 extern double cos (double);
0103 extern double sin (double);
0104 extern double tan (double);
0105
0106 extern double cosh (double);
0107 extern double sinh (double);
0108 extern double tanh (double);
0109
0110 extern double exp (double);
0111 extern double frexp (double, int *);
0112 extern double ldexp (double, int);
0113 extern double log (double);
0114 extern double log10 (double);
0115 extern double modf (double, double *);
0116
0117 extern double pow (double, double);
0118 extern double sqrt (double);
0119
0120 extern double ceil (double);
0121 extern double fabs (double);
0122 extern double floor (double);
0123 extern double fmod (double, double);
0124
0125 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
0126 extern double erf (double);
0127 extern double erfc (double);
0128 extern double gamma (double);
0129 extern double hypot (double, double);
0130 extern int isinf (double);
0131 extern int isnan (double);
0132 extern int finite (double);
0133 extern double j0 (double);
0134 extern double j1 (double);
0135 extern double jn (int, double);
0136 extern double lgamma (double);
0137 extern double y0 (double);
0138 extern double y1 (double);
0139 extern double yn (int, double);
0140
0141 #if !defined(_XOPEN_SOURCE)
0142 extern double acosh (double);
0143 extern double asinh (double);
0144 extern double atanh (double);
0145 extern double cbrt (double);
0146 extern double logb (double);
0147 extern double nextafter (double, double);
0148 extern double remainder (double, double);
0149 extern double scalb (double, double);
0150
0151 extern int matherr (struct exception *);
0152
0153 /*
0154 * IEEE Test Vector
0155 */
0156 extern double significand (double);
0157
0158 /*
0159 * Functions callable from C, intended to support IEEE arithmetic.
0160 */
0161 extern double copysign (double, double);
0162 extern int ilogb (double);
0163 extern double rint (double);
0164 extern double scalbn (double, int);
0165
0166 /*
0167 * BSD math library entry points
0168 */
0169 extern double cabs();
0170 extern double drem (double, double);
0171 extern double expm1 (double);
0172 extern double log1p (double);
0173
0174 /*
0175 * Reentrant version of gamma & lgamma; passes signgam back by reference
0176 * as the second argument; user must allocate space for signgam.
0177 */
0178 #ifdef _REENTRANT
0179 extern double gamma_r (double, int *);
0180 extern double lgamma_r (double, int *);
0181 #endif /* _REENTRANT */
0182
0183
0184 /* float versions of ANSI/POSIX functions */
0185 extern float acosf (float);
0186 extern float asinf (float);
0187 extern float atanf (float);
0188 extern float atan2f (float, float);
0189 extern float cosf (float);
0190 extern float sinf (float);
0191 extern float tanf (float);
0192
0193 extern float coshf (float);
0194 extern float sinhf (float);
0195 extern float tanhf (float);
0196
0197 extern float expf (float);
0198 extern float frexpf (float, int *);
0199 extern float ldexpf (float, int);
0200 extern float logf (float);
0201 extern float log10f (float);
0202 extern float modff (float, float *);
0203
0204 extern float powf (float, float);
0205 extern float sqrtf (float);
0206
0207 extern float ceilf (float);
0208 extern float fabsf (float);
0209 extern float floorf (float);
0210 extern float fmodf (float, float);
0211
0212 extern float erff (float);
0213 extern float erfcf (float);
0214 extern float gammaf (float);
0215 extern float hypotf (float, float);
0216 extern int isnanf (float);
0217 extern int finitef (float);
0218 extern float j0f (float);
0219 extern float j1f (float);
0220 extern float jnf (int, float);
0221 extern float lgammaf (float);
0222 extern float y0f (float);
0223 extern float y1f (float);
0224 extern float ynf (int, float);
0225
0226 extern float acoshf (float);
0227 extern float asinhf (float);
0228 extern float atanhf (float);
0229 extern float cbrtf (float);
0230 extern float logbf (float);
0231 extern float nextafterf (float, float);
0232 extern float remainderf (float, float);
0233 extern float scalbf (float, float);
0234
0235 /*
0236 * float version of IEEE Test Vector
0237 */
0238 extern float significandf (float);
0239
0240 /*
0241 * Float versions of functions callable from C, intended to support
0242 * IEEE arithmetic.
0243 */
0244 extern float copysignf (float, float);
0245 extern int ilogbf (float);
0246 extern float rintf (float);
0247 extern float scalbnf (float, int);
0248
0249 /*
0250 * float versions of BSD math library entry points
0251 */
0252 extern float cabsf ();
0253 extern float dremf (float, float);
0254 extern float expm1f (float);
0255 extern float log1pf (float);
0256
0257 /*
0258 * Float versions of reentrant version of gamma & lgamma; passes
0259 * signgam back by reference as the second argument; user must
0260 * allocate space for signgam.
0261 */
0262 #ifdef _REENTRANT
0263 extern float gammaf_r (float, int *);
0264 extern float lgammaf_r (float, int *);
0265 #endif /* _REENTRANT */
0266
0267 #endif /* !_XOPEN_SOURCE */
0268 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
0269
0270 #endif /* _MATH_H_ */