home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / N < prev    next >
Encoding:
Text File  |  1992-12-09  |  6.1 KB  |  232 lines

  1. /*
  2.  *   math.h -- ANSI 
  3.  *
  4.  *   Mathematical functions and constants.
  5.  *
  6.  *           Copyright (c) 1990, MetaWare Incorporated
  7.  */
  8.  
  9. #ifndef _MATH_H
  10. #define _MATH_H
  11. #pragma push_align_members(64);
  12.  
  13. #ifdef __CPLUSPLUS__
  14. extern "C" {
  15. #endif
  16.  
  17. #ifndef EDOM
  18. #define EDOM     33     /* errno's value for out of domain */
  19. #endif
  20.  
  21. #ifndef ERANGE
  22. #define ERANGE   34     /* errno's value for out of range  */
  23. #endif
  24.  
  25. #define HUGE_VAL (_fphuge[0])
  26. extern double _fphuge[];
  27.  
  28.  
  29. #define _PI 3.141592653589793238462643383279502884197169399
  30. #define _E  2.718281828459045235360287471352662497757247093
  31.  
  32.  
  33. extern double cos(double __x);
  34. extern double sin(double __x);
  35. extern double tan(double __x);
  36. extern double atan(double __x);
  37.  
  38. extern double exp(double __x);
  39. extern double log(double __x);
  40. extern double sqrt(double __x);
  41.  
  42. extern double acos(double __x);
  43. extern double asin(double __x);
  44.  
  45. extern double cosh(double __x);
  46. extern double sinh(double __x);
  47. extern double tanh(double __x);
  48.  
  49. extern double log10(double __x);
  50.  
  51. extern double fabs(double __x);
  52.  
  53. extern double ceil(double __x);
  54. extern double floor(double __x);
  55.  
  56. extern double atan2(double __y, double __x);
  57.  
  58. extern double frexp(double __value, int *__exp);
  59. extern double ldexp(double __x, int __exp);
  60. extern double modf(double __value, double *__iptr);
  61.  
  62. extern double pow(double __x, double __y);
  63.  
  64. extern double fmod(double __x, double __y);
  65.  
  66. #if _AM29K
  67. extern float cosf(float __x);
  68. extern float sinf(float __x);
  69. extern float tanf(float __x);
  70. extern float atanf(float __x);
  71.  
  72. extern float expf(float __x);
  73. extern float logf(float __x);
  74. extern float sqrtf(float __x);
  75.  
  76. extern float acosf(float __x);
  77. extern float asinf(float __x);
  78.  
  79. extern float coshf(float __x);
  80. extern float sinhf(float __x);
  81. extern float tanhf(float __x);
  82.  
  83. extern float log10f(float __x);
  84.  
  85. extern float fabsf(float __x);
  86.  
  87. extern float ceilf(float __x);
  88. extern float floorf(float __x);
  89.  
  90. extern float atan2f(float __y, float __x);
  91.  
  92. extern float frexpf(float __value, int *__exp);
  93. extern float ldexpf(float __x, int __exp);
  94.  
  95. extern float powf(float __x, float __y);
  96.  
  97. extern float fmodf(float __x, float __y);
  98. #endif
  99.  
  100. #ifndef __CPLUSPLUS__
  101.     #ifndef _COMPLEX_DEFINED
  102.     #define _COMPLEX_DEFINED
  103.     #define _HUGE HUGE_VAL
  104.  
  105.     #if _HOBBIT            /* conforms to WATCOM member names */
  106.         struct _complex { double real,imag; };
  107.         #define _CPLXREAL(c) ((c).real)
  108.         #define _CPLXIMAG(c) ((c).imag)
  109.     #else
  110.         struct _complex { double x,y; };
  111.         #define _CPLXREAL(c) ((c).x)
  112.         #define _CPLXIMAG(c) ((c).y)
  113.     #endif
  114.  
  115.     #if __HIGHC__
  116.         #define complex _complex
  117.         #define HUGE HUGE_VAL
  118.     #endif
  119.     #endif
  120.  
  121.     /* definition of exception struct - this struct is passed to the matherr
  122.      * function when a floating point exception is detected
  123.      */
  124.  
  125.     #ifndef _EXCEPTION_DEFINED
  126.     struct _exception {
  127.         int type;           /* exception type - see constants below */
  128.         char *name;         /* name of function where error occured */
  129.         double arg1;        /* first argument to function           */
  130.         double arg2;        /* second argument (if any) to function */
  131.         double retval;      /* value to be returned by function     */
  132.         } ;
  133.     #define _EXCEPTION_DEFINED
  134.     #if __HIGHC__
  135.         #define exception _exception
  136.     #endif
  137.     #endif
  138.  
  139.     #define _NULL_MATHERR (int (*)())0
  140.     int _matherr (struct _exception *__s);
  141.     extern void _set_matherr( int (*rtn)(struct exception *err_info) );
  142.     #if _HOBBIT
  143.     #define _DO_MATHERR 1  /* we only do matherr for limited targets now */
  144.     #else
  145.     #define _DO_MATHERR 0  /* disable matherr for compatibility */
  146.     #endif
  147.  
  148.     extern double _cabs(struct _complex);
  149.     extern double _hypot(double __x, double __y);
  150.     extern double _log2(double __x);
  151.  
  152.     /* Bessel function routines  */
  153.  
  154.     double _yn(int __n, double __x);
  155.     double _jn(int __n, double __x);
  156.     double _y0(double __x);
  157.     double _y1(double __x);
  158.     double _j0(double __x);
  159.     double _j1(double __x);
  160.  
  161.     /* inverse hyperbolic trigonometric functions */
  162.     extern double _atanh(double __x);
  163.     extern double _acosh(double __x);
  164.     extern double _asinh(double __x);
  165.  
  166.     #if __HIGHC__ 
  167.  
  168. /* non-ansi versions of cabs and hypot */
  169.     extern double cabs(struct complex __z);
  170.     extern double hypot(double __x, double __y);
  171.     extern double log2(double __x);
  172.  
  173.     /* Constant definitions for the exception type passed
  174.      *   in the exception struct
  175.      */
  176.  
  177.     #define DOMAIN      1   /* argument domain error                */
  178.     #define SING        2   /* argument singularity                 */
  179.     #define OVERFLOW    3   /* overflow range error                 */
  180.     #define UNDERFLOW   4   /* underflow range error                */
  181.     #define TLOSS       5   /* total loss of precision              */
  182.     #define PLOSS       6   /* partial loss of precision            */
  183.     int matherr (struct exception *__s);
  184.  
  185.     /* Bessel function routines  */
  186.  
  187.     double yn(int __n, double __x);
  188.     double jn(int __n, double __x);
  189.     double y0(double __x);
  190.     double y1(double __x);
  191.     double j0(double __x);
  192.     double j1(double __x);
  193.  
  194.     /* inverse hyperbolic trigonometric functions */
  195.     extern double atanh(double __x);
  196.     extern double acosh(double __x);
  197.     extern double asinh(double __x);
  198.     #endif /*__HIGHC__*/
  199. #endif  /* ifndef __CPLUSPLUS__ */
  200.  
  201. #if _MSDOS && !defined(__CPLUSPLUS__)
  202.  
  203.     /* floating point format conversion   */
  204.     int _fieeetomsbin(float *__x, float *__x1);
  205.     int _fmsbintoieee(float *__x, float *__x1);
  206.     int _dieeetomsbin(double *__x, double *__x1);
  207.     int _dmsbintoieee(double *__x, double *__x1);
  208.  
  209.     int _matherrx (struct _exception *__s);
  210.  
  211.     #ifdef __HIGHC__
  212.     int matherrx (struct exception *__s);
  213.  
  214.     /* floating point format conversion   */
  215.     int fieeetomsbin(float *__x, float *__x1);
  216.     int fmsbintoieee(float *__x, float *__x1);
  217.     int dieeetomsbin(double *__x, double *__x1);
  218.     int dmsbintoieee(double *__x, double *__x1);
  219.     #endif /*__HIGHC__*/
  220.  
  221. #endif /*_MSDOS*/
  222.  
  223. #if __HIGHC__
  224. extern double atof(const char *__nptr);
  225. #endif
  226.  
  227. #ifdef __CPLUSPLUS__
  228. }
  229. #endif
  230. #pragma pop_align_members();
  231. #endif /*_MATH_H*/
  232.