math.h revision 1.4
1/*	$OpenBSD: math.h,v 1.4 2000/03/01 22:27:13 todd Exp $	*/
2/*
3 * ====================================================
4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5 *
6 * Developed at SunPro, a Sun Microsystems, Inc. business.
7 * Permission to use, copy, modify, and distribute this
8 * software is freely granted, provided that this notice
9 * is preserved.
10 * ====================================================
11 */
12
13/*
14 * from: @(#)fdlibm.h 5.1 93/09/24
15 */
16
17#ifndef _MATH_H_
18#define _MATH_H_
19
20/*
21 * ANSI/POSIX
22 */
23extern char __infinity[];
24#define HUGE_VAL	(*(double *) __infinity)
25
26/*
27 * XOPEN/SVID
28 */
29#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
30#define	M_E		2.7182818284590452354	/* e */
31#define	M_LOG2E		1.4426950408889634074	/* log 2e */
32#define	M_LOG10E	0.43429448190325182765	/* log 10e */
33#define	M_LN2		0.69314718055994530942	/* log e2 */
34#define	M_LN10		2.30258509299404568402	/* log e10 */
35#define	M_PI		3.14159265358979323846	/* pi */
36#define	M_PI_2		1.57079632679489661923	/* pi/2 */
37#define	M_PI_4		0.78539816339744830962	/* pi/4 */
38#define	M_1_PI		0.31830988618379067154	/* 1/pi */
39#define	M_2_PI		0.63661977236758134308	/* 2/pi */
40#define	M_2_SQRTPI	1.12837916709551257390	/* 2/sqrt(pi) */
41#define	M_SQRT2		1.41421356237309504880	/* sqrt(2) */
42#define	M_SQRT1_2	0.70710678118654752440	/* 1/sqrt(2) */
43
44#define	MAXFLOAT	((float)3.40282346638528860e+38)
45extern int signgam;
46
47#if !defined(_XOPEN_SOURCE)
48enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
49
50#define _LIB_VERSION_TYPE enum fdversion
51#define _LIB_VERSION _fdlib_version
52
53/* if global variable _LIB_VERSION is not desirable, one may
54 * change the following to be a constant by:
55 *	#define _LIB_VERSION_TYPE const enum version
56 * In that case, after one initializes the value _LIB_VERSION (see
57 * s_lib_version.c) during compile time, it cannot be modified
58 * in the middle of a program
59 */
60extern  _LIB_VERSION_TYPE  _LIB_VERSION;
61
62#define _IEEE_  fdlibm_ieee
63#define _SVID_  fdlibm_svid
64#define _XOPEN_ fdlibm_xopen
65#define _POSIX_ fdlibm_posix
66
67#ifdef __LIBM_PRIVATE
68struct exception {
69	int type;
70	char *name;
71	double arg1;
72	double arg2;
73	double retval;
74};
75#endif
76
77#define	HUGE		MAXFLOAT
78
79/*
80 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
81 * (one may replace the following line by "#include <values.h>")
82 */
83
84#define X_TLOSS		1.41484755040568800000e+16
85
86#define	DOMAIN		1
87#define	SING		2
88#define	OVERFLOW	3
89#define	UNDERFLOW	4
90#define	TLOSS		5
91#define	PLOSS		6
92
93#endif /* !_XOPEN_SOURCE */
94#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
95
96
97#include <sys/cdefs.h>
98__BEGIN_DECLS
99/*
100 * ANSI/POSIX
101 */
102extern double acos __P((double));
103extern double asin __P((double));
104extern double atan __P((double));
105extern double atan2 __P((double, double));
106extern double cos __P((double));
107extern double sin __P((double));
108extern double tan __P((double));
109
110extern double cosh __P((double));
111extern double sinh __P((double));
112extern double tanh __P((double));
113
114extern double exp __P((double));
115extern double frexp __P((double, int *));
116extern double ldexp __P((double, int));
117extern double log __P((double));
118extern double log10 __P((double));
119extern double modf __P((double, double *));
120
121extern double pow __P((double, double));
122extern double sqrt __P((double));
123
124extern double ceil __P((double));
125extern double fabs __P((double));
126extern double floor __P((double));
127extern double fmod __P((double, double));
128
129#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
130extern double erf __P((double));
131extern double erfc __P((double));
132extern double gamma __P((double));
133extern double hypot __P((double, double));
134extern int isinf __P((double));
135extern int isnan __P((double));
136extern int finite __P((double));
137extern double j0 __P((double));
138extern double j1 __P((double));
139extern double jn __P((int, double));
140extern double lgamma __P((double));
141extern double y0 __P((double));
142extern double y1 __P((double));
143extern double yn __P((int, double));
144
145#if !defined(_XOPEN_SOURCE)
146extern double acosh __P((double));
147extern double asinh __P((double));
148extern double atanh __P((double));
149extern double cbrt __P((double));
150extern double logb __P((double));
151extern double nextafter __P((double, double));
152extern double remainder __P((double, double));
153extern double scalb __P((double, double));
154
155#ifdef __LIBM_PRIVATE
156extern int matherr __P((struct exception *));
157#endif
158
159/*
160 * IEEE Test Vector
161 */
162extern double significand __P((double));
163
164/*
165 * Functions callable from C, intended to support IEEE arithmetic.
166 */
167extern double copysign __P((double, double));
168extern int ilogb __P((double));
169extern double rint __P((double));
170extern double scalbn __P((double, int));
171
172/*
173 * BSD math library entry points
174 */
175extern double cabs();
176extern double drem __P((double, double));
177extern double expm1 __P((double));
178extern double log1p __P((double));
179
180/*
181 * Reentrant version of gamma & lgamma; passes signgam back by reference
182 * as the second argument; user must allocate space for signgam.
183 */
184#ifdef _REENTRANT
185extern double gamma_r __P((double, int *));
186extern double lgamma_r __P((double, int *));
187#endif /* _REENTRANT */
188
189
190/* float versions of ANSI/POSIX functions */
191extern float acosf __P((float));
192extern float asinf __P((float));
193extern float atanf __P((float));
194extern float atan2f __P((float, float));
195extern float cosf __P((float));
196extern float sinf __P((float));
197extern float tanf __P((float));
198
199extern float coshf __P((float));
200extern float sinhf __P((float));
201extern float tanhf __P((float));
202
203extern float expf __P((float));
204extern float frexpf __P((float, int *));
205extern float ldexpf __P((float, int));
206extern float logf __P((float));
207extern float log10f __P((float));
208extern float modff __P((float, float *));
209
210extern float powf __P((float, float));
211extern float sqrtf __P((float));
212
213extern float ceilf __P((float));
214extern float fabsf __P((float));
215extern float floorf __P((float));
216extern float fmodf __P((float, float));
217
218extern float erff __P((float));
219extern float erfcf __P((float));
220extern float gammaf __P((float));
221extern float hypotf __P((float, float));
222extern int isinff __P((float));
223extern int isnanf __P((float));
224extern int finitef __P((float));
225extern float j0f __P((float));
226extern float j1f __P((float));
227extern float jnf __P((int, float));
228extern float lgammaf __P((float));
229extern float y0f __P((float));
230extern float y1f __P((float));
231extern float ynf __P((int, float));
232
233extern float acoshf __P((float));
234extern float asinhf __P((float));
235extern float atanhf __P((float));
236extern float cbrtf __P((float));
237extern float logbf __P((float));
238extern float nextafterf __P((float, float));
239extern float remainderf __P((float, float));
240extern float scalbf __P((float, float));
241
242/*
243 * float version of IEEE Test Vector
244 */
245extern float significandf __P((float));
246
247/*
248 * Float versions of functions callable from C, intended to support
249 * IEEE arithmetic.
250 */
251extern float copysignf __P((float, float));
252extern int ilogbf __P((float));
253extern float rintf __P((float));
254extern float scalbnf __P((float, int));
255
256/*
257 * float versions of BSD math library entry points
258 */
259extern float cabsf ();
260extern float dremf __P((float, float));
261extern float expm1f __P((float));
262extern float log1pf __P((float));
263
264/*
265 * Float versions of reentrant version of gamma & lgamma; passes
266 * signgam back by reference as the second argument; user must
267 * allocate space for signgam.
268 */
269#ifdef _REENTRANT
270extern float gammaf_r __P((float, int *));
271extern float lgammaf_r __P((float, int *));
272#endif	/* _REENTRANT */
273
274#endif /* !_XOPEN_SOURCE */
275#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
276__END_DECLS
277
278#endif /* _MATH_H_ */
279