1 |
39 |
lampret |
/* math.h -- Definitions for the math floating point package. */
|
2 |
|
|
|
3 |
|
|
#ifndef _MATH_H_
|
4 |
|
|
#ifdef __cplusplus
|
5 |
|
|
extern "C" {
|
6 |
|
|
#endif
|
7 |
|
|
#define _MATH_H_
|
8 |
|
|
|
9 |
|
|
#include <sys/reent.h>
|
10 |
|
|
#include <machine/ieeefp.h>
|
11 |
|
|
#include "_ansi.h"
|
12 |
|
|
|
13 |
|
|
#ifndef HUGE_VAL
|
14 |
|
|
|
15 |
|
|
/* Define HUGE_VAL as infinity, unless HUGE_VAL is already defined
|
16 |
|
|
(which might have been done by something like math-68881.h). */
|
17 |
|
|
|
18 |
|
|
union __dmath
|
19 |
|
|
{
|
20 |
|
|
__uint32_t i[2];
|
21 |
|
|
double d;
|
22 |
|
|
};
|
23 |
|
|
|
24 |
|
|
extern const union __dmath __infinity;
|
25 |
|
|
|
26 |
|
|
#define HUGE_VAL (__infinity.d)
|
27 |
|
|
|
28 |
|
|
#endif /* ! defined (HUGE_VAL) */
|
29 |
|
|
|
30 |
|
|
/* Reentrant ANSI C functions. */
|
31 |
|
|
|
32 |
|
|
#ifndef __math_68881
|
33 |
|
|
extern double atan _PARAMS((double));
|
34 |
|
|
extern double cos _PARAMS((double));
|
35 |
|
|
extern double sin _PARAMS((double));
|
36 |
|
|
extern double tan _PARAMS((double));
|
37 |
|
|
extern double tanh _PARAMS((double));
|
38 |
|
|
extern double frexp _PARAMS((double, int *));
|
39 |
|
|
extern double modf _PARAMS((double, double *));
|
40 |
|
|
extern double ceil _PARAMS((double));
|
41 |
|
|
extern double fabs _PARAMS((double));
|
42 |
|
|
extern double floor _PARAMS((double));
|
43 |
|
|
#endif /* ! defined (__math_68881) */
|
44 |
|
|
|
45 |
|
|
/* Non reentrant ANSI C functions. */
|
46 |
|
|
|
47 |
|
|
#ifndef _REENT_ONLY
|
48 |
|
|
#ifndef __math_6881
|
49 |
|
|
extern double acos _PARAMS((double));
|
50 |
|
|
extern double asin _PARAMS((double));
|
51 |
|
|
extern double atan2 _PARAMS((double, double));
|
52 |
|
|
extern double cosh _PARAMS((double));
|
53 |
|
|
extern double sinh _PARAMS((double));
|
54 |
|
|
extern double exp _PARAMS((double));
|
55 |
|
|
extern double ldexp _PARAMS((double, int));
|
56 |
|
|
extern double log _PARAMS((double));
|
57 |
|
|
extern double log10 _PARAMS((double));
|
58 |
|
|
extern double pow _PARAMS((double, double));
|
59 |
|
|
extern double sqrt _PARAMS((double));
|
60 |
|
|
extern double fmod _PARAMS((double, double));
|
61 |
|
|
#endif /* ! defined (__math_68881) */
|
62 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
63 |
|
|
|
64 |
|
|
#ifndef _STRICT_ANSI
|
65 |
|
|
|
66 |
|
|
/* Non ANSI double precision functions. */
|
67 |
|
|
|
68 |
|
|
extern double infinity _PARAMS((void));
|
69 |
|
|
extern double nan _PARAMS((void));
|
70 |
|
|
extern int isnan _PARAMS((double));
|
71 |
|
|
extern int isinf _PARAMS((double));
|
72 |
|
|
extern int finite _PARAMS((double));
|
73 |
|
|
extern double copysign _PARAMS((double, double));
|
74 |
|
|
extern int ilogb _PARAMS((double));
|
75 |
|
|
|
76 |
|
|
extern double asinh _PARAMS((double));
|
77 |
|
|
extern double cbrt _PARAMS((double));
|
78 |
|
|
extern double nextafter _PARAMS((double, double));
|
79 |
|
|
extern double rint _PARAMS((double));
|
80 |
|
|
extern double scalbn _PARAMS((double, int));
|
81 |
|
|
|
82 |
|
|
#ifndef __math_68881
|
83 |
|
|
extern double log1p _PARAMS((double));
|
84 |
|
|
extern double expm1 _PARAMS((double));
|
85 |
|
|
#endif /* ! defined (__math_68881) */
|
86 |
|
|
|
87 |
|
|
#ifndef _REENT_ONLY
|
88 |
|
|
extern double acosh _PARAMS((double));
|
89 |
|
|
extern double atanh _PARAMS((double));
|
90 |
|
|
extern double remainder _PARAMS((double, double));
|
91 |
|
|
extern double gamma _PARAMS((double));
|
92 |
|
|
extern double gamma_r _PARAMS((double, int *));
|
93 |
|
|
extern double lgamma _PARAMS((double));
|
94 |
|
|
extern double lgamma_r _PARAMS((double, int *));
|
95 |
|
|
extern double erf _PARAMS((double));
|
96 |
|
|
extern double erfc _PARAMS((double));
|
97 |
|
|
extern double y0 _PARAMS((double));
|
98 |
|
|
extern double y1 _PARAMS((double));
|
99 |
|
|
extern double yn _PARAMS((int, double));
|
100 |
|
|
extern double j0 _PARAMS((double));
|
101 |
|
|
extern double j1 _PARAMS((double));
|
102 |
|
|
extern double jn _PARAMS((int, double));
|
103 |
|
|
#define log2(x) (log (x) / M_LOG2_E)
|
104 |
|
|
|
105 |
|
|
#ifndef __math_68881
|
106 |
|
|
extern double hypot _PARAMS((double, double));
|
107 |
|
|
#endif
|
108 |
|
|
|
109 |
|
|
extern double cabs();
|
110 |
|
|
extern double drem _PARAMS((double, double));
|
111 |
|
|
|
112 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
113 |
|
|
|
114 |
|
|
/* Single precision versions of ANSI functions. */
|
115 |
|
|
|
116 |
|
|
extern float atanf _PARAMS((float));
|
117 |
|
|
extern float cosf _PARAMS((float));
|
118 |
|
|
extern float sinf _PARAMS((float));
|
119 |
|
|
extern float tanf _PARAMS((float));
|
120 |
|
|
extern float tanhf _PARAMS((float));
|
121 |
|
|
extern float frexpf _PARAMS((float, int *));
|
122 |
|
|
extern float modff _PARAMS((float, float *));
|
123 |
|
|
extern float ceilf _PARAMS((float));
|
124 |
|
|
extern float fabsf _PARAMS((float));
|
125 |
|
|
extern float floorf _PARAMS((float));
|
126 |
|
|
|
127 |
|
|
#ifndef _REENT_ONLY
|
128 |
|
|
extern float acosf _PARAMS((float));
|
129 |
|
|
extern float asinf _PARAMS((float));
|
130 |
|
|
extern float atan2f _PARAMS((float, float));
|
131 |
|
|
extern float coshf _PARAMS((float));
|
132 |
|
|
extern float sinhf _PARAMS((float));
|
133 |
|
|
extern float expf _PARAMS((float));
|
134 |
|
|
extern float ldexpf _PARAMS((float, int));
|
135 |
|
|
extern float logf _PARAMS((float));
|
136 |
|
|
extern float log10f _PARAMS((float));
|
137 |
|
|
extern float powf _PARAMS((float, float));
|
138 |
|
|
extern float sqrtf _PARAMS((float));
|
139 |
|
|
extern float fmodf _PARAMS((float, float));
|
140 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
141 |
|
|
|
142 |
|
|
/* Other single precision functions. */
|
143 |
|
|
|
144 |
|
|
extern float infinityf _PARAMS((void));
|
145 |
|
|
extern float nanf _PARAMS((void));
|
146 |
|
|
extern int isnanf _PARAMS((float));
|
147 |
|
|
extern int isinff _PARAMS((float));
|
148 |
|
|
extern int finitef _PARAMS((float));
|
149 |
|
|
extern float copysignf _PARAMS((float, float));
|
150 |
|
|
extern int ilogbf _PARAMS((float));
|
151 |
|
|
|
152 |
|
|
extern float asinhf _PARAMS((float));
|
153 |
|
|
extern float cbrtf _PARAMS((float));
|
154 |
|
|
extern float nextafterf _PARAMS((float, float));
|
155 |
|
|
extern float rintf _PARAMS((float));
|
156 |
|
|
extern float scalbnf _PARAMS((float, int));
|
157 |
|
|
extern float log1pf _PARAMS((float));
|
158 |
|
|
extern float expm1f _PARAMS((float));
|
159 |
|
|
|
160 |
|
|
#ifndef _REENT_ONLY
|
161 |
|
|
extern float acoshf _PARAMS((float));
|
162 |
|
|
extern float atanhf _PARAMS((float));
|
163 |
|
|
extern float remainderf _PARAMS((float, float));
|
164 |
|
|
extern float gammaf _PARAMS((float));
|
165 |
|
|
extern float gammaf_r _PARAMS((float, int *));
|
166 |
|
|
extern float lgammaf _PARAMS((float));
|
167 |
|
|
extern float lgammaf_r _PARAMS((float, int *));
|
168 |
|
|
extern float erff _PARAMS((float));
|
169 |
|
|
extern float erfcf _PARAMS((float));
|
170 |
|
|
extern float y0f _PARAMS((float));
|
171 |
|
|
extern float y1f _PARAMS((float));
|
172 |
|
|
extern float ynf _PARAMS((int, float));
|
173 |
|
|
extern float j0f _PARAMS((float));
|
174 |
|
|
extern float j1f _PARAMS((float));
|
175 |
|
|
extern float jnf _PARAMS((int, float));
|
176 |
|
|
#define log2f(x) (logf (x) / (float) M_LOG2_E)
|
177 |
|
|
extern float hypotf _PARAMS((float, float));
|
178 |
|
|
|
179 |
|
|
extern float cabsf();
|
180 |
|
|
extern float dremf _PARAMS((float, float));
|
181 |
|
|
|
182 |
|
|
#endif /* ! defined (_REENT_ONLY) */
|
183 |
|
|
|
184 |
|
|
/* The gamma functions use a global variable, signgam. */
|
185 |
|
|
|
186 |
|
|
extern int signgam;
|
187 |
|
|
|
188 |
|
|
/* The exception structure passed to the matherr routine. */
|
189 |
|
|
|
190 |
|
|
#ifdef __cplusplus
|
191 |
|
|
struct __exception
|
192 |
|
|
#else
|
193 |
|
|
struct exception
|
194 |
|
|
#endif
|
195 |
|
|
{
|
196 |
|
|
int type;
|
197 |
|
|
char *name;
|
198 |
|
|
double arg1;
|
199 |
|
|
double arg2;
|
200 |
|
|
double retval;
|
201 |
|
|
int err;
|
202 |
|
|
};
|
203 |
|
|
|
204 |
|
|
#ifdef __cplusplus
|
205 |
|
|
extern int matherr _PARAMS((struct __exception *e));
|
206 |
|
|
#else
|
207 |
|
|
extern int matherr _PARAMS((struct exception *e));
|
208 |
|
|
#endif
|
209 |
|
|
|
210 |
|
|
/* Values for the type field of struct exception. */
|
211 |
|
|
|
212 |
|
|
#define DOMAIN 1
|
213 |
|
|
#define SING 2
|
214 |
|
|
#define OVERFLOW 3
|
215 |
|
|
#define UNDERFLOW 4
|
216 |
|
|
#define TLOSS 5
|
217 |
|
|
#define PLOSS 6
|
218 |
|
|
|
219 |
|
|
/* Useful constants. */
|
220 |
|
|
|
221 |
|
|
#define M_E 2.7182818284590452354
|
222 |
|
|
#define M_LOG2E 1.4426950408889634074
|
223 |
|
|
#define M_LOG10E 0.43429448190325182765
|
224 |
|
|
#define M_LN2 0.69314718055994530942
|
225 |
|
|
#define M_LN10 2.30258509299404568402
|
226 |
|
|
#define M_PI 3.14159265358979323846
|
227 |
|
|
#define M_TWOPI (M_PI * 2.0)
|
228 |
|
|
#define M_PI_2 1.57079632679489661923
|
229 |
|
|
#define M_PI_4 0.78539816339744830962
|
230 |
|
|
#define M_3PI_4 2.3561944901923448370E0
|
231 |
|
|
#define M_SQRTPI 1.77245385090551602792981
|
232 |
|
|
#define M_1_PI 0.31830988618379067154
|
233 |
|
|
#define M_2_PI 0.63661977236758134308
|
234 |
|
|
#define M_2_SQRTPI 1.12837916709551257390
|
235 |
|
|
#define M_SQRT2 1.41421356237309504880
|
236 |
|
|
#define M_SQRT1_2 0.70710678118654752440
|
237 |
|
|
#define M_LN2LO 1.9082149292705877000E-10
|
238 |
|
|
#define M_LN2HI 6.9314718036912381649E-1
|
239 |
|
|
#define M_SQRT3 1.73205080756887719000
|
240 |
|
|
#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */
|
241 |
|
|
#define M_LOG2_E 0.693147180559945309417
|
242 |
|
|
#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */
|
243 |
|
|
|
244 |
|
|
/* Global control over fdlibm error handling. */
|
245 |
|
|
|
246 |
|
|
enum __fdlibm_version
|
247 |
|
|
{
|
248 |
|
|
__fdlibm_ieee = -1,
|
249 |
|
|
__fdlibm_svid,
|
250 |
|
|
__fdlibm_xopen,
|
251 |
|
|
__fdlibm_posix
|
252 |
|
|
};
|
253 |
|
|
|
254 |
|
|
#define _LIB_VERSION_TYPE enum __fdlibm_version
|
255 |
|
|
#define _LIB_VERSION __fdlib_version
|
256 |
|
|
|
257 |
|
|
extern _LIB_VERSION_TYPE _LIB_VERSION;
|
258 |
|
|
|
259 |
|
|
#define _IEEE_ __fdlibm_ieee
|
260 |
|
|
#define _SVID_ __fdlibm_svid
|
261 |
|
|
#define _XOPEN_ __fdlibm_xopen
|
262 |
|
|
#define _POSIX_ __fdlibm_posix
|
263 |
|
|
|
264 |
|
|
#endif /* ! defined (_STRICT_ANSI) */
|
265 |
|
|
|
266 |
|
|
#ifdef __cplusplus
|
267 |
|
|
}
|
268 |
|
|
#endif
|
269 |
|
|
#endif /* _MATH_H_ */
|