home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / LATTIC_3.LZH / HEADERS / MATH.H < prev    next >
C/C++ Source or Header  |  1990-08-08  |  3KB  |  151 lines

  1. /*
  2.  * math.h - mathematics header file
  3.  *
  4.  * Copyright (c) 1990 HiSoft & Lattice, Inc.
  5.  */
  6.  
  7. #ifndef _MATH_H
  8. #define _MATH_H
  9.  
  10. #ifdef NONDP
  11. #include <nondp.h>
  12. #endif
  13.  
  14. #ifndef HUGE_VAL
  15. #define HUGE_VAL 1.797693134862317E+308
  16. #endif
  17.  
  18. #ifndef EDOM
  19. #define EDOM    33    /* Math function argument error */
  20. #endif
  21.  
  22. #ifndef ERANGE
  23. #define ERANGE    34    /* Math function result is out of range */
  24. #endif
  25.  
  26. /*
  27.  * ANSI functions
  28.  */
  29.  
  30. double acos(double);
  31. double asin(double);
  32. double atan(double);
  33. double atan2(double, double);
  34. double cos(double);
  35. double sin(double);
  36. double tan(double);
  37. double cosh(double);
  38. double sinh(double);
  39. double exp(double);
  40. double frexp(double, int *);
  41. double ldexp(double, int);
  42. double log(double);
  43. double log10(double);
  44. double modf(double, double *);
  45. double pow(double, double);
  46. double sqrt(double);
  47. double ceil(double);
  48. double fabs(double);
  49. double floor(double);
  50. double fmod(double, double);
  51.  
  52.  
  53. /*
  54.  * Structure to hold information about math exceptions
  55.  */
  56.  
  57. struct exception
  58. {
  59.     int     type;        /* error type */
  60.     char    *name;        /* math function name */
  61.     double    arg1, arg2; /* function arguments */
  62.     double    retval;     /* proposed return value */
  63. };
  64.  
  65.  
  66. /*
  67.  * Exception type codes, found exception.type
  68.  */
  69.  
  70. #define DOMAIN        1    /* domain error */
  71. #define SING        2    /* singularity */
  72. #define OVERFLOW    3    /* overflow */
  73. #define UNDERFLOW    4    /* underflow */
  74. #define TLOSS        5    /* total loss of significance */
  75. #define PLOSS        6    /* partial loss of significance */
  76. #define RANGE        6    /* range error */
  77.  
  78.  
  79. /*
  80.  * Error codes generated by basic arithmetic operations (+ - * /)
  81.  */
  82.  
  83. #define FPEUND        1    /* underflow */
  84. #define FPEOVF        2    /* overflow */
  85. #define FPEZDV        3    /* zero divisor */
  86. #define FPENAN        4    /* not a number (invalid operation) */
  87. #define FPECOM        5    /* not comparable */
  88.  
  89. __stdargs void _CXFERR(int);
  90.  
  91. /*
  92.  * Floating point constants
  93.  */
  94.  
  95. #define PI        3.14159265358979323846
  96. #define PID2    1.57079632679489661923        /*  PI/2  */
  97. #define PID4    0.78539816339744830962        /*  PI/4  */
  98. #define I_PI    0.31830988618379067154        /*  1/PI  */
  99. #define I_PID2    0.63661977236758134308        /*  1/(PI/2)  */
  100.  
  101. #define HUGE    HUGE_VAL
  102. #define TINY    2.2e-308
  103. #define LOGHUGE    709.778
  104. #define LOGTINY    -708.396
  105.  
  106. typedef struct complex
  107. {
  108.     double re;
  109.     double im;
  110. } COMPLEX;
  111.  
  112. /*
  113.  * Lattice functions (Non-ANSI)
  114.  */
  115.  
  116. double cabs(COMPLEX *);
  117. COMPLEX *cadd(COMPLEX *,COMPLEX *,COMPLEX *);
  118. COMPLEX *cdiv(COMPLEX *,COMPLEX *,COMPLEX *);
  119. COMPLEX *cmul(COMPLEX *,COMPLEX *,COMPLEX *);
  120. COMPLEX *csub(COMPLEX *,COMPLEX *,COMPLEX *);
  121. double cot(double);
  122. double drand48(void);
  123. double erand48(unsigned short *);
  124. double except(int, char *, double, double, double);
  125. char *ecvt(double, int, int *, int *);
  126. char *fcvt(double, int, int *, int *);
  127. char *gcvt(double, int, char *);
  128. long jrand48(unsigned short *);
  129. void lcong48(unsigned short *);
  130. long lrand48(void);
  131. double except(int, char *, double, double, double);
  132. int matherr(struct exception *);
  133. long mrand48(void);
  134. long nrand48(unsigned short *);
  135. double pow2(double);
  136. unsigned short *seed48(unsigned short *);
  137. void srand48(long);
  138. double tanh(double);
  139.  
  140. extern int _FPERR;
  141.  
  142. #ifndef max
  143. #define   max(a,b)    ((a) > (b) ? (a) : (b))
  144. #endif
  145.  
  146. #ifndef min
  147. #define   min(a,b)    ((a) <= (b) ? (a) : (b))
  148. #endif
  149.  
  150. #endif
  151.