home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6574.LZX / include / math.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-04  |  4.3 KB  |  182 lines

  1. /* Copyright (c) 1992-1993 SAS Institute, Inc., Cary, NC USA */
  2. /* All Rights Reserved */
  3.  
  4.  
  5. #ifndef _MATH_H
  6. #define _MATH_H 1
  7.  
  8. #ifndef _COMMHUGE_H
  9. #include <sys/commhuge.h>
  10. #endif
  11.  
  12. /***
  13. *     ANSI trigonometric functions
  14. ***/
  15.  
  16. #ifndef _COMMARGS_H
  17. #include <sys/commargs.h>
  18. #endif
  19.  
  20. /* Use the __ARGS macro below to suppress errors  */
  21. /* if these functions have been #defined by other */
  22. /* header files.                                  */
  23.  
  24. extern double acos  __ARGS((double));
  25. extern double asin  __ARGS((double));
  26. extern double atan  __ARGS((double));
  27. extern double atan2 __ARGS((double, double));
  28. extern double cos   __ARGS((double));
  29. extern double sin   __ARGS((double));
  30. extern double tan   __ARGS((double));
  31.  
  32.  
  33. /***
  34. *     ANSI hyperbolic functions
  35. ***/
  36.  
  37. extern double cosh __ARGS((double));
  38. extern double sinh __ARGS((double));
  39. extern double tanh __ARGS((double));
  40.  
  41.  
  42. /***
  43. *     ANSI exponential and logarithmic functions
  44. ***/
  45.  
  46. extern double exp __ARGS((double));
  47. extern double frexp __ARGS((double, int *));
  48. extern double ldexp __ARGS((double, int));
  49. extern double log __ARGS((double));
  50. extern double log10 __ARGS((double));
  51. extern double modf __ARGS((double, double *));
  52.  
  53.  
  54. /***
  55. *     ANSI power functions
  56. ***/
  57.  
  58. extern double pow __ARGS((double, double));
  59. extern double sqrt __ARGS((double));
  60.  
  61.  
  62. /***
  63. *     ANSI nearest integer, absolute value, and remainder functions
  64. ***/
  65.  
  66. extern double ceil __ARGS((double));
  67. extern double fabs __ARGS((double));
  68. extern double floor __ARGS((double));
  69. extern double fmod __ARGS((double, double));
  70.  
  71.  
  72. /***
  73. *     Structure to hold information about math exceptions
  74. ***/
  75.  
  76. struct __exception {
  77.     int     type;          /* error type */
  78.     char    *name;         /* math function name */
  79.     double  arg1, arg2;    /* function arguments */
  80.     double  retval;        /* proposed return value */
  81. };
  82.  
  83. /***
  84. *     Exception type codes, found exception.type
  85. ***/
  86.  
  87. #define _DOMAIN      1    /* domain error */
  88. #define _SING        2    /* singularity */
  89. #define _OVERFLOW    3    /* overflow */
  90. #define _UNDERFLOW   4    /* underflow */
  91. #define _TLOSS       5    /* total loss of significance */
  92. #define _RANGE       6    /* range error */
  93. #define _PLOSS       7    /* partial loss of significance */
  94.  
  95.  
  96. /***
  97. *     Error codes generated by basic arithmetic operations (+ - * /)
  98. ***/
  99.  
  100. #define _FPEUND      1    /* underflow */
  101. #define _FPEOVF      2    /* overflow */
  102. #define _FPEZDV      3    /* zero divisor */
  103. #define _FPENAN      4    /* not a number (invalid operation) */
  104. #define _FPECOM      5    /* not comparable */
  105.  
  106. extern int _FPERR;
  107.  
  108. #ifndef _STRICT_ANSI
  109.  
  110. #define DOMAIN    _DOMAIN
  111. #define SING      _SING
  112. #define OVERFLOW  _OVERFLOW
  113. #define UNDERFLOW _UNDERFLOW
  114. #define TLOSS     _TLOSS
  115. #define PLOSS     _PLOSS
  116. #define RANGE     _RANGE
  117.  
  118. #define FPEUND    _FPEUND
  119. #define FPEOVF    _FPEOVF
  120. #define FPEZDV    _FPEZDV
  121. #define FPENAN    _FPENAN
  122. #define FPECOM    _FPECOM
  123.  
  124. /***
  125. *     Floating point constants
  126. ***/
  127.  
  128. #define PI      3.14159265358979323846
  129. #define PID2    1.57079632679489661923       /*  PI/2  */
  130. #define PID4    0.78539816339744830962       /*  PI/4  */
  131. #define I_PI    0.31830988618379067154       /*  1/PI  */
  132. #define I_PID2  0.63661977236758134308       /*  1/(PI/2)  */
  133.  
  134. #define HUGE      HUGE_VAL
  135.  
  136. #ifdef _FFP
  137. #define TINY      5.42101070e-20
  138. #define LOGHUGE   4.366827e1
  139. #define LOGTINY  -3.922479e1
  140. #else
  141. #define TINY      2.2e-308
  142. #define LOGHUGE   709.778
  143. #define LOGTINY  -708.396
  144. #endif
  145.  
  146. /***
  147. *     SAS functions (Non-ANSI)
  148. ***/
  149.  
  150. void __stdargs _CXFERR(int);
  151. extern double cot(double);
  152. extern double drand48(void);
  153. extern double erand48(unsigned short *);
  154. extern double except(int, const char *, double, double, double);
  155. extern char   *ecvt(double, int, int *, int *);
  156. extern char   *fcvt(double, int, int *, int *);
  157. extern char   *gcvt(double, int, char *);
  158. extern long   jrand48(unsigned short *);
  159. extern void   lcong48(unsigned short *);
  160. extern long   lrand48(void);
  161. extern double __except(int, const char *, double, double, double);
  162. extern int    __matherr(struct __exception *);
  163. extern long   mrand48(void);
  164. extern long   nrand48(unsigned short *);
  165. extern double pow2(double);
  166. extern unsigned short *seed48(unsigned short *);
  167. extern void   srand48(long);
  168.  
  169. #ifndef __cplusplus
  170. #ifndef max
  171. #define   max(a,b)    ((a) > (b) ? (a) : (b))
  172. #endif
  173.  
  174. #ifndef min
  175. #define   min(a,b)    ((a) <= (b) ? (a) : (b))
  176. #endif
  177. #endif
  178.  
  179. #endif /* _STRICT_ANSI */
  180.  
  181. #endif
  182.