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