home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / NeXT / GnuSource / cc-61.0.1 / cc / math-convex.h < prev    next >
C/C++ Source or Header  |  1990-10-08  |  5KB  |  200 lines

  1. #pragma once
  2. #ifndef __HAVE_MATH_CONVEX__
  3. #define __HAVE_MATH_CONVEX__
  4.  
  5. #define HUGE_VAL 8.98846567431157854e+307
  6.  
  7. #define HUGE     8.98846567431157854e+307
  8. #define HUGEI    1.79769313486231570e+308
  9.  
  10. #define M_E        2.71828182845904523536
  11. #define M_LN10        2.30258509299404568402
  12. #define M_LN2        0.69314718055994530942
  13. #define M_LOG10E    0.43429448190325182765
  14. #define M_LOG2E        1.44269504088896340736
  15. #define M_PI        3.14159265358979323846
  16. #define M_PI_2        1.57079632679489661923
  17. #define M_PI_4        0.78539816339744830962
  18. #define M_SQRT1_2    0.70710678118654752440
  19. #define M_SQRT2        1.41421356237309504880
  20. #define M_1_PI        0.31830988618379067154
  21. #define M_2_PI        0.63661977236758134308
  22. #define M_2_SQRTPI    1.12837916709551257390
  23.  
  24. extern const double acos (double x);
  25. extern const double asin (double x);
  26. extern const double atan (double x);
  27. extern const double atan2 (double y, double x);
  28. extern const double atof (const char *p);
  29. extern const double cabs ();
  30. extern const double ceil (double x);
  31. extern const double cos (double x);
  32. extern const double cosh (double x);
  33. extern const double dcvtid (double x);
  34. extern const double exp (double x);
  35. extern const double fabs (double x);
  36. extern const double floor (double x);
  37. extern double frexp (double x, int *ep);
  38. extern const double gamma (double x);
  39. extern const double hypot (double x, double y);
  40. extern const double idcvtd (double x);
  41. extern const double ircvtr (double x);
  42. extern const double j0 (double x);
  43. extern const double j1 (double x);
  44. extern const double jn (int n, double x);
  45. extern const double ldexp (double x, int e);
  46. extern const double log (double x);
  47. extern const double log10 (double x);
  48. extern double modf (double x, double *np);
  49. extern const double pow (double x, double y);
  50. extern const double rcvtir (double x);
  51. extern const double sacos (double x);
  52. extern const double sasin (double x);
  53. extern const double satan (double x);
  54. extern const double satan2 (double x);
  55. extern const double scabs ();
  56. extern const double scos (double x);
  57. extern const double scosh (double x);
  58. extern const double sexp (double x);
  59. extern const double sfabs (double x);
  60. extern const double shypot (double x, double y);
  61. extern const double sin (double x);
  62. extern const double sinh (double x);
  63. extern const double slog (double x);
  64. extern const double slog10 (double x);
  65. extern const double spow (double x);
  66. extern const double sqrt (double x);
  67. extern const double ssin (double x);
  68. extern const double ssinh (double x);
  69. extern const double ssqrt (double x);
  70. extern const double stan (double x);
  71. extern const double stanh (double x);
  72. extern const double tan (double x);
  73. extern const double tanh (double x);
  74. extern const double y0 (double x);
  75. extern const double y1 (double x);
  76. extern const double yn (int n, double x);
  77. extern const long int ipow (int x, int y);
  78. extern const long long int lpow (long long int x, long long int y);
  79.  
  80.  
  81. #define fabs(x)         __builtin_fabs(x)
  82.  
  83. #ifdef __convex__
  84.  
  85. #define frexp(x,y)    __inline_frexp(x,y)
  86. #define ldexp(x,y)    __inline_ldexp(x,y)
  87.  
  88. #ifdef __convex_c2__
  89.  
  90. #define ceil(x)        __inline_ceil (x)
  91. #define cos(x)        __inline_cos (x)
  92. #define exp(x)        __inline_exp (x)
  93. #define floor(x)    __inline_floor (x)
  94. #define log(x)        __inline_log (x)
  95. #define log10(x)    __inline_log10 (x)
  96. #define modf(x,y)    __inline_modf ((x), (y))
  97. #define sin(x)        __inline_sin (x)
  98. #define sqrt(x)        __inline_sqrt (x)
  99.  
  100. #endif /* __convex_c2__ */
  101.  
  102. __inline__ static const double __inline_ceil (double x)
  103. {
  104.   double z;
  105.   __asm__ ("frint.d %1,%0" : "=d" (z) : "d" (x));
  106.   if (z < x) z += 1.0;
  107.   return z;
  108. }
  109.  
  110. __inline__ static const double __inline_cos (double x)
  111. {
  112.   double z;
  113.   __asm__ ("cos.d %0" : "=d" (z) : "0" (x));
  114.   return z;
  115. }
  116.  
  117. __inline__ static const double __inline_exp (double x)
  118. {
  119.   double z;
  120.   __asm__ ("exp.d %0" : "=d" (z) : "0" (x));
  121.   return z;
  122. }
  123.  
  124. __inline__ static const double __inline_floor (double x)
  125. {
  126.   double z;
  127.   __asm__ ("frint.d %1,%0" : "=d" (z) : "d" (x));
  128.   if (z > x) z -= 1.0;
  129.   return z;
  130. }
  131.  
  132. __inline__ static const double __inline_frexp (double x, int *np)
  133. {
  134.   union u {double d; unsigned long long ll;} u;
  135.   if ((u.d = x) == 0)
  136.     *np = 0;
  137.   else
  138.     {
  139.       *np = ((u.ll >> 52) & 03777) - 02000;
  140.       u.ll = (u.ll & 0x800fffffffffffffLL) | ((union u) {0.5}).ll;
  141.     }
  142.   return u.d;
  143. }
  144.  
  145. __inline__ static const double __inline_ldexp (double x, int n)
  146. {
  147.   extern int errno;
  148.   union {double d; long long ll; unsigned sexp : 12;} u;
  149.   if ((u.d = x) != 0)
  150.     {
  151.       int exp = n + (u.sexp & 03777);
  152.       if (exp <= 0)
  153.     u.ll = 0, errno = 34;
  154.       else if (exp > 03777)
  155.     u.ll |= 0x7fffffffffffffffLL, errno = 34;
  156.       else
  157.     u.ll += (long long) n << 52;
  158.     }
  159.   return u.d;
  160. }
  161.  
  162. __inline__ static const double __inline_log (double x)
  163. {
  164.   double z;
  165.   __asm__ ("ln.d %0" : "=d" (z) : "0" (x));
  166.   return z;
  167. }
  168.  
  169. __inline__ static const double __inline_log10 (double x)
  170. {
  171.   return M_LOG10E * __log (x);
  172. }
  173.  
  174. __inline__ static const double __inline_modf (double x, double *np)
  175. {
  176.   double intpart;
  177.   __asm__ ("frint.d %1,%0" : "=d" (intpart) : "d" (x));
  178.   *np = intpart;
  179.   return x - intpart;
  180. }
  181.  
  182. __inline__ static const double __inline_sin (double x)
  183. {
  184.   double z;
  185.   __asm__ ("sin.d %0" : "=d" (z) : "0" (x));
  186.   return z;
  187. }
  188.  
  189. __inline__ static const double __inline_sqrt (double x)
  190. {
  191.   double z;
  192.   __asm__ ("sqrt.d %0" : "=d" (z) : "0" (x));
  193.   return z;
  194. }
  195.  
  196. #endif /* __convex__ */
  197.  
  198.  
  199. #endif /* __HAVE_MATH_CONVEX__ */
  200.