home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c017 / 7.ddi / GPPLIB.ZIP / MATH.H < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-17  |  5.1 KB  |  184 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of GNU CC.
  7.  
  8. GNU CC is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY.  No author or distributor
  10. accepts responsibility to anyone for the consequences of using it
  11. or for whether it serves any particular purpose or works at all,
  12. unless he says so in writing.  Refer to the GNU CC General Public
  13. License for full details.
  14.  
  15. Everyone is granted permission to copy, modify and redistribute
  16. GNU CC, but only under the conditions described in the
  17. GNU CC General Public License.   A copy of this license is
  18. supposed to have been given to you along with GNU CC so you
  19. can know your rights and responsibilities.  It should be in a
  20. file named COPYING.  Among other things, the copyright notice
  21. and this notice must be preserved on all copies.  
  22. */
  23.  
  24.  
  25. #ifndef _math_h
  26. #define _math_h 1
  27.  
  28. #ifndef DECLARE_C_EXTERN
  29. #define DECLARE_C_EXTERN(RETVAL, FNAME, ARGTYPES)  \
  30.   extern RETVAL FNAME ARGTYPES asm ("_" #FNAME)
  31. #endif
  32.  
  33. overload acos;
  34. overload acosh;
  35. overload asin;
  36. overload asinh;
  37. overload atan2;
  38. overload atanh;
  39. overload ceil;
  40. overload cos;
  41. overload cosh;
  42. overload exp;
  43. overload floor;
  44. overload gamma;
  45. overload hypot;
  46. overload log;
  47. overload log10;
  48. overload pow;
  49. overload sin;
  50. overload sinh;
  51. overload sqrt;
  52. overload tan;
  53. overload tanh;
  54.  
  55. DECLARE_C_EXTERN(double, acos, (double));
  56. DECLARE_C_EXTERN(double, acosh, (double));
  57. DECLARE_C_EXTERN(double, asin, (double));
  58. DECLARE_C_EXTERN(double, asinh, (double));
  59. DECLARE_C_EXTERN(double, atan, (double));
  60. DECLARE_C_EXTERN(double, atan2, (double, double));
  61. DECLARE_C_EXTERN(double, atanh, (double));
  62. DECLARE_C_EXTERN(double, cbrt, (double));
  63. DECLARE_C_EXTERN(double, ceil, (double));
  64. DECLARE_C_EXTERN(double, copysign, (double,double));
  65. DECLARE_C_EXTERN(double, cos, (double));
  66. DECLARE_C_EXTERN(double, cosh, (double));
  67. DECLARE_C_EXTERN(double, drem, (double,double));
  68. DECLARE_C_EXTERN(double, erf, (double));
  69. DECLARE_C_EXTERN(double, erfc, (double));
  70. DECLARE_C_EXTERN(double, exp, (double));
  71. DECLARE_C_EXTERN(double, expm1, (double));
  72. DECLARE_C_EXTERN(double, fabs, (double));
  73. DECLARE_C_EXTERN(double, finite, (double));
  74. DECLARE_C_EXTERN(double, floor, (double));
  75. DECLARE_C_EXTERN(double, frexp, (double, int*));
  76. DECLARE_C_EXTERN(double, gamma, (double));
  77. DECLARE_C_EXTERN(double, hypot, (double,double));
  78. DECLARE_C_EXTERN(double, infnan, (int));
  79. DECLARE_C_EXTERN(int,    isinf, (double));
  80. DECLARE_C_EXTERN(int,    isnan, (double));
  81. DECLARE_C_EXTERN(double, j0, (double));
  82. DECLARE_C_EXTERN(double, j1, (double));
  83. DECLARE_C_EXTERN(double, jn, (int, double));
  84. DECLARE_C_EXTERN(double, ldexp, (double, int));
  85. DECLARE_C_EXTERN(double, lgamma, (double));
  86. DECLARE_C_EXTERN(double, log, (double));
  87. DECLARE_C_EXTERN(double, log10, (double));
  88. DECLARE_C_EXTERN(double, log1p, (double));
  89. DECLARE_C_EXTERN(double, logb, (double));
  90. DECLARE_C_EXTERN(double, modf, (double, double*));
  91. DECLARE_C_EXTERN(double, pow, (double, double));
  92. DECLARE_C_EXTERN(double, rint, (double));
  93. DECLARE_C_EXTERN(double, scalb, (double, int));
  94. DECLARE_C_EXTERN(double, sin, (double));
  95. DECLARE_C_EXTERN(double, sinh, (double));
  96. DECLARE_C_EXTERN(double, sqrt, (double));
  97. DECLARE_C_EXTERN(double, tan, (double));
  98. DECLARE_C_EXTERN(double, tanh, (double));
  99. DECLARE_C_EXTERN(double, y0, (double));
  100. DECLARE_C_EXTERN(double, y1, (double));
  101. DECLARE_C_EXTERN(double, yn, (int, double));
  102.  
  103. /* libg++ doesn't use this since it is not available on some systems */
  104.  
  105. /* the following ifdef is just for compiling OOPS */
  106.  
  107. #ifndef DONT_DECLARE_EXCEPTION
  108. struct exception
  109. {
  110.   int type;
  111.   char* name;
  112.   double arg1, arg2, retval;
  113. };
  114.  
  115. #define DOMAIN      1
  116. #define SING        2
  117. #define OVERFLOW    3
  118. #define UNDERFLOW   4
  119. #define TLOSS       5
  120. #define PLOSS       6
  121.  
  122. int matherr(exception*);
  123.  
  124. #endif
  125.  
  126. #include <values.h>
  127.  
  128. /* On some systems, HUGE ought to be MAXFLOAT or IEEE infinity */
  129.  
  130. #ifndef HUGE
  131. #define HUGE    MAXDOUBLE
  132. #endif
  133.  
  134. /* These seem to be sun & sysV names of these constants */
  135.  
  136. #ifndef M_E
  137. #define M_E         2.7182818284590452354
  138. #endif
  139. #ifndef M_LOG2E
  140. #define M_LOG2E     1.4426950408889634074
  141. #endif
  142. #ifndef M_LOG10E
  143. #define M_LOG10E    0.43429448190325182765
  144. #endif
  145. #ifndef M_LN2
  146. #define M_LN2       0.69314718055994530942
  147. #endif
  148. #ifndef M_LN10
  149. #define M_LN10      2.30258509299404568402
  150. #endif
  151. #ifndef M_PI
  152. #define M_PI        3.14159265358979323846
  153. #endif
  154. #ifndef M_PI_2
  155. #define M_PI_2      1.57079632679489661923
  156. #endif
  157. #ifndef M_1_PI
  158. #define M_1_PI      0.31830988618379067154
  159. #endif
  160. #ifndef M_PI_4
  161. #define M_PI_4      0.78539816339744830962
  162. #endif
  163. #ifndef M_2_PI
  164. #define M_2_PI      0.63661977236758134308
  165. #endif
  166. #ifndef M_2_SQRTPI
  167. #define M_2_SQRTPI  1.12837916709551257390
  168. #endif
  169. #ifndef M_SQRT2
  170. #define M_SQRT2     1.41421356237309504880
  171. #endif
  172. #ifndef M_SQRT1_2
  173. #define M_SQRT1_2   0.70710678118654752440
  174. #endif
  175.  
  176. #ifndef PI                      // as in stroustrup
  177. #define PI  M_PI
  178. #endif
  179. #ifndef PI2
  180. #define PI2  M_PI_2
  181. #endif
  182.  
  183. #endif
  184.