home *** CD-ROM | disk | FTP | other *** search
/ Zodiac Super OZ / MEDIADEPOT.ISO / FILES / 13 / DJCRX201.ZIP / include / libm / math.h
C/C++ Source or Header  |  1995-08-26  |  8KB  |  284 lines

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