home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / progs / CB / DATA.Z / MATH.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-11  |  11.5 KB  |  337 lines

  1.  
  2. /*  math.h
  3.  
  4.     Definitions for the math floating point package.
  5.  
  6. */
  7.  
  8. /* $Copyright: 1987$ */
  9. /* $Revision:   8.3  $ */
  10.  
  11. #ifndef  __MATH_H
  12. #define  __MATH_H
  13.  
  14. #if !defined(___DEFS_H)
  15. #include <_defs.h>
  16. #endif
  17.  
  18.  
  19. #if !defined(RC_INVOKED)
  20.  
  21. #if defined(__STDC__)
  22. #pragma warn -nak
  23. #endif
  24.  
  25. #pragma pack(push, 1)
  26.  
  27. #endif  /* !RC_INVOKED */
  28.  
  29.  
  30. #if !defined(__STDC__) /* NON-ANSI */
  31.  
  32. #ifdef __cplusplus
  33.     /* use class complex instead of _cabs in C++ */
  34. #else
  35. struct complex      /* as used by "_cabs" function */
  36. {
  37.     double  x, y;
  38. };
  39.  
  40. struct _complexl    /* as used by "_cabsl" function */
  41. {
  42.     long double  x, y;
  43. };
  44.  
  45. #define cabs(z)     (hypot  ((z).x, (z).y))
  46. #define cabsl(z)    (hypotl ((z).x, (z).y))
  47. #endif /* NON-ANSI */
  48.  
  49. #endif
  50.  
  51. typedef enum
  52. {
  53.     DOMAIN = 1,    /* argument domain error -- log (-1)        */
  54.     SING,          /* argument singularity  -- pow (0,-2))     */
  55.     OVERFLOW,      /* overflow range error  -- exp (1000)      */
  56.     UNDERFLOW,     /* underflow range error -- exp (-1000)     */
  57.     TLOSS,         /* total loss of significance -- sin(10e70) */
  58.     PLOSS,         /* partial loss of signif. -- not used      */
  59.     STACKFAULT     /* floating point unit stack overflow       */
  60. }   _mexcep;
  61.  
  62. /* Constants rounded for 21 decimals. */
  63. #define M_E         2.71828182845904523536
  64. #define M_LOG2E     1.44269504088896340736
  65. #define M_LOG10E    0.434294481903251827651
  66. #define M_LN2       0.693147180559945309417
  67. #define M_LN10      2.30258509299404568402
  68. #define M_PI        3.14159265358979323846
  69. #define M_PI_2      1.57079632679489661923
  70. #define M_PI_4      0.785398163397448309616
  71. #define M_1_PI      0.318309886183790671538
  72. #define M_2_PI      0.636619772367581343076
  73. #define M_1_SQRTPI  0.564189583547756286948
  74. #define M_2_SQRTPI  1.12837916709551257390
  75. #define M_SQRT2     1.41421356237309504880
  76. #define M_SQRT_2    0.707106781186547524401
  77.  
  78. #define EDOM    33      /* Math argument */
  79. #define ERANGE  34      /* Result too large */
  80.  
  81. struct  exception
  82. {
  83.     int type;
  84.     char   _FAR *name;
  85.     double  arg1, arg2, retval;
  86. };
  87.  
  88. struct  _exceptionl
  89. {
  90.     int type;
  91.     char   _FAR *name;
  92.     long double  arg1, arg2, retval;
  93. };
  94.  
  95. #if !defined(__FLAT__)
  96.  
  97. #define HUGE_VAL    _huge_dble
  98. extern double _RTLENTRY _huge_dble;
  99. #define _LHUGE_VAL   _huge_ldble
  100. extern long double _RTLENTRY _huge_ldble;
  101.  
  102. #ifdef __cplusplus
  103. extern "C" {
  104. #endif
  105. double      _RTLENTRY _EXPFUNC acos    (double __x);
  106. double      _RTLENTRY _EXPFUNC asin    (double __x);
  107. double      _RTLENTRY          atan    (double __x);
  108. double      _RTLENTRY _EXPFUNC atan2   (double __y, double __x);
  109. double      _RTLENTRY _EXPFUNC ceil    (double __x);
  110. double      _RTLENTRY _EXPFUNC cos     (double __x);
  111. double      _RTLENTRY _EXPFUNC cosh    (double __x);
  112. double      _RTLENTRY _EXPFUNC exp     (double __x);
  113. double      _RTLENTRY          fabs    (double __x);
  114. double      _RTLENTRY          __fabs__(double __x); /* Intrinsic */
  115. double      _RTLENTRY _EXPFUNC floor   (double __x);
  116. double      _RTLENTRY _EXPFUNC fmod    (double __x, double __y);
  117. double      _RTLENTRY _EXPFUNC frexp   (double __x, int _FAR *__exponent);
  118. double      _RTLENTRY _EXPFUNC ldexp   (double __x, int __exponent);
  119. double      _RTLENTRY _EXPFUNC log     (double __x);
  120. double      _RTLENTRY _EXPFUNC log10   (double __x);
  121. double      _RTLENTRY _EXPFUNC modf    (double __x, double _FAR *__ipart);
  122. double      _RTLENTRY _EXPFUNC pow     (double __x, double __y);
  123. double      _RTLENTRY _EXPFUNC sin     (double __x);
  124. double      _RTLENTRY _EXPFUNC sinh    (double __x);
  125. double      _RTLENTRY _EXPFUNC sqrt    (double __x);
  126. double      _RTLENTRY _EXPFUNC tan     (double __x);
  127. double      _RTLENTRY _EXPFUNC tanh    (double __x);
  128.  
  129. long double _RTLENTRY _EXPFUNC acosl  (long double __x);
  130. long double _RTLENTRY _EXPFUNC asinl  (long double __x);
  131. long double _RTLENTRY _EXPFUNC atan2l (long double __x, long double __y);
  132. long double _RTLENTRY          atanl  (long double __x);
  133. long double _RTLENTRY _EXPFUNC ceill  (long double __x);
  134. long double _RTLENTRY _EXPFUNC coshl  (long double __x);
  135. long double _RTLENTRY _EXPFUNC cosl   (long double __x);
  136. long double _RTLENTRY _EXPFUNC expl   (long double __x);
  137. long double _RTLENTRY          fabsl  (long double __x);
  138. long double _RTLENTRY _EXPFUNC floorl (long double __x);
  139. long double _RTLENTRY _EXPFUNC fmodl  (long double __x, long double __y);
  140. long double _RTLENTRY _EXPFUNC frexpl (long double __x, int _FAR *__exponent);
  141. long double _RTLENTRY _EXPFUNC ldexpl (long double __x, int __exponent);
  142. long double _RTLENTRY _EXPFUNC log10l (long double __x);
  143. long double _RTLENTRY _EXPFUNC logl   (long double __x);
  144. long double _RTLENTRY _EXPFUNC modfl  (long double __x, long double _FAR *__ipart);
  145. long double _RTLENTRY _EXPFUNC powl   (long double __x, long double __y);
  146. long double _RTLENTRY _EXPFUNC sinhl  (long double __x);
  147. long double _RTLENTRY _EXPFUNC sinl   (long double __x);
  148. long double _RTLENTRY _EXPFUNC sqrtl  (long double __x);
  149. long double _RTLENTRY _EXPFUNC tanhl  (long double __x);
  150. long double _RTLENTRY _EXPFUNC tanl   (long double __x);
  151.  
  152. #ifdef __cplusplus
  153. }
  154. #endif
  155.  
  156.  
  157. #if !defined(__STDC__)
  158.  
  159. #ifdef __cplusplus
  160. extern "C" {
  161. #endif
  162.  
  163. double      _RTLENTRY _EXPFUNC hypot (double __x, double __y);
  164. int         _RTLENTRY _EXPFUNC _matherr (struct exception _FAR *__e);
  165. double      _RTLENTRY _EXPFUNC poly  (double __x, int __degree, double _FAR *__coeffs);
  166. double      _RTLENTRY _EXPFUNC pow10 (int __p);
  167. long double _RTLENTRY          hypotl (long double __x, long double __y);
  168. long double _RTLENTRY          polyl  (long double __x, int __degree, long double _FAR *__coeffs);
  169. long double _RTLENTRY _EXPFUNC pow10l (int __p);
  170.  
  171. #if !defined(__ABS_DEFINED)
  172. #define __ABS_DEFINED
  173. int         _RTLENTRY __abs__(int);
  174. #ifdef __cplusplus
  175. inline int _RTLENTRY  abs(int __x) { return __abs__(__x); }
  176. #else
  177. int         _RTLENTRY abs(int __x);
  178. #  define abs(x)   __abs__(x)
  179. #endif
  180.  
  181. #endif /* __ABS_DEFINED */
  182.  
  183. double      _RTLENTRY _EXPFUNC atof  (const char _FAR *__s);
  184. int         _RTLENTRY _EXPFUNC atoi(const char _FAR *__s);
  185. long        _RTLENTRY _EXPFUNC atol(const char _FAR *__s);
  186. __int64     _RTLENTRY _EXPFUNC _atoi64(const char * __s);
  187. long double _RTLENTRY _EXPFUNC _atold (const char _FAR *__s);
  188.  
  189. long        _RTLENTRY          labs  (long __x);
  190. int         _RTLENTRY _EXPFUNC _matherrl (struct _exceptionl _FAR *__e);
  191.  
  192.  
  193. long double _RTLENTRY          hypotl (long double __x, long double __y);
  194. long double _RTLENTRY          polyl  (long double __x, int __degree, long double _FAR *__coeffs);
  195. long double _RTLENTRY _EXPFUNC pow10l (int __p);
  196.  
  197. #if defined(__FLAT__)
  198. double      _RTLENTRY _EXPFUNC   _wtof(const wchar_t * __s);
  199. int         _RTLENTRY _EXPFUNC   _wtoi(const wchar_t * __s);
  200. long        _RTLENTRY _EXPFUNC   _wtol(const wchar_t * __s);
  201. __int64     _RTLENTRY _EXPFUNC   _wtoi64(const wchar_t * __s);
  202. long double _RTLENTRY _EXPFUNC   _wtold(const wchar_t * __s);
  203. #endif
  204.  
  205. #ifdef __cplusplus
  206. }
  207. #endif
  208.  
  209. #endif  /* !__STDC__ */
  210.  
  211. #else   /* defined __FLAT__ */
  212.  
  213. #define HUGE_VAL    _huge_dble
  214. extern double _RTLENTRY _EXPDATA _huge_dble;
  215. #define _LHUGE_VAL   _huge_ldble
  216. extern long double _RTLENTRY _EXPDATA _huge_ldble;
  217.  
  218. #ifdef __cplusplus
  219. extern "C" {
  220. #endif
  221. double      _RTLENTRY _EXPFUNC acos    (double __x);
  222. double      _RTLENTRY _EXPFUNC asin    (double __x);
  223. double      _RTLENTRY _EXPFUNC atan    (double __x);
  224. double      _RTLENTRY _EXPFUNC atan2   (double __y, double __x);
  225. double      _RTLENTRY _EXPFUNC ceil    (double __x);
  226. double      _RTLENTRY _EXPFUNC cos     (double __x);
  227. double      _RTLENTRY _EXPFUNC cosh    (double __x);
  228. double      _RTLENTRY _EXPFUNC exp     (double __x);
  229. double      _RTLENTRY _EXPFUNC fabs    (double __x);
  230. double      _RTLENTRY _EXPFUNC floor   (double __x);
  231. double      _RTLENTRY _EXPFUNC fmod    (double __x, double __y);
  232. double      _RTLENTRY _EXPFUNC frexp   (double __x, int * __exponent);
  233. double      _RTLENTRY _EXPFUNC ldexp   (double __x, int __exponent);
  234. double      _RTLENTRY _EXPFUNC log     (double __x);
  235. double      _RTLENTRY _EXPFUNC log10   (double __x);
  236. double      _RTLENTRY _EXPFUNC modf    (double __x, double * __ipart);
  237. double      _RTLENTRY _EXPFUNC pow     (double __x, double __y);
  238. double      _RTLENTRY _EXPFUNC sin     (double __x);
  239. double      _RTLENTRY _EXPFUNC sinh    (double __x);
  240. double      _RTLENTRY _EXPFUNC sqrt    (double __x);
  241. double      _RTLENTRY _EXPFUNC tan     (double __x);
  242. double      _RTLENTRY _EXPFUNC tanh    (double __x);
  243.  
  244. long double _RTLENTRY _EXPFUNC acosl  (long double __x);
  245. long double _RTLENTRY _EXPFUNC asinl  (long double __x);
  246. long double _RTLENTRY _EXPFUNC atan2l (long double __x, long double __y);
  247. long double _RTLENTRY _EXPFUNC atanl  (long double __x);
  248. long double _RTLENTRY _EXPFUNC ceill  (long double __x);
  249. long double _RTLENTRY _EXPFUNC coshl  (long double __x);
  250. long double _RTLENTRY _EXPFUNC cosl   (long double __x);
  251. long double _RTLENTRY _EXPFUNC expl   (long double __x);
  252. long double _RTLENTRY _EXPFUNC fabsl  (long double __x);
  253. long double _RTLENTRY _EXPFUNC floorl (long double __x);
  254. long double _RTLENTRY _EXPFUNC fmodl  (long double __x, long double __y);
  255. long double _RTLENTRY _EXPFUNC frexpl (long double __x, int * __exponent);
  256. long double _RTLENTRY _EXPFUNC ldexpl (long double __x, int __exponent);
  257. long double _RTLENTRY _EXPFUNC log10l (long double __x);
  258. long double _RTLENTRY _EXPFUNC logl   (long double __x);
  259. long double _RTLENTRY _EXPFUNC modfl  (long double __x, long double * __ipart);
  260. long double _RTLENTRY _EXPFUNC powl   (long double __x, long double __y);
  261. long double _RTLENTRY _EXPFUNC sinhl  (long double __x);
  262. long double _RTLENTRY _EXPFUNC sinl   (long double __x);
  263. long double _RTLENTRY _EXPFUNC sqrtl  (long double __x);
  264. long double _RTLENTRY _EXPFUNC tanhl  (long double __x);
  265. long double _RTLENTRY _EXPFUNC tanl   (long double __x);
  266.  
  267. /* Intrinsic functions */
  268.  
  269. double      _RTLENTRY _EXPFUNC __sin__ (double __x);
  270. double      _RTLENTRY _EXPFUNC __cos__ (double __x);
  271. long double _RTLENTRY _EXPFUNC __cosl__(long double __x);
  272. long double _RTLENTRY _EXPFUNC __sinl__(long double __x);
  273.  
  274. #ifdef __cplusplus
  275. }
  276. #endif
  277.  
  278.  
  279. #if !defined(__STDC__) /* NON_ANSI */
  280.  
  281. #ifdef __cplusplus
  282. extern "C" {
  283. #endif
  284.  
  285. #if !defined(__ABS_DEFINED)
  286. #define __ABS_DEFINED
  287. int         _RTLENTRY __abs__(int);
  288. #ifdef __cplusplus
  289. inline int _RTLENTRY  abs(int __x) { return __abs__(__x); }
  290. #else
  291. int         _RTLENTRYF _EXPFUNC abs(int __x);
  292. #  define abs(x)   __abs__(x)
  293. #endif
  294. #endif /* __ABS_DEFINED */
  295.  
  296. double      _RTLENTRY _EXPFUNC atof    (const char * __s);
  297. long        _RTLENTRY _EXPFUNC labs    (long __x);
  298. double      _RTLENTRY _EXPFUNC pow10   (int __p);
  299.  
  300. long double _RTLENTRY _EXPFUNC _atold  (const char * __s);
  301.  
  302. int         _RTLENTRY          _matherr(struct exception  *__e);
  303. int         _RTLENTRY          _matherrl(struct _exceptionl *__e);
  304.  
  305. double      _RTLENTRY _EXPFUNC hypot   (double __x, double __y);
  306. double      _RTLENTRY _EXPFUNC poly    (double __x, int __degree, double coeffs []);
  307. long double _RTLENTRY _EXPFUNC hypotl  (long double __x, long double __y);
  308. long double _RTLENTRY _EXPFUNC polyl   (long double __x, int __degree, long double coeffs []);
  309. long double _RTLENTRY _EXPFUNC pow10l  (int __p);
  310.  
  311.  
  312. #ifdef __cplusplus
  313. }
  314. #endif
  315.  
  316. #endif  /* !__STDC__ */
  317.  
  318. #endif  /* __FLAT__ */
  319.  
  320.  
  321. #if !defined(RC_INVOKED)
  322.  
  323. /* restore default packing */
  324. #pragma pack(pop)
  325.  
  326. #if defined(__STDC__)
  327. #pragma warn .nak
  328. #endif
  329.  
  330. #endif  /* !RC_INVOKED */
  331.  
  332.  
  333. #endif  /* __MATH_H */
  334.  
  335.  
  336.  
  337.