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