Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.4 KiB

  1. /* _Sinh function */
  2. #include "xmath.h"
  3. _STD_BEGIN
  4. /* coefficients */
  5. #define NP (sizeof (p) / sizeof (p[0]) - 1)
  6. static const double p[] = { /* courtesy Dr. Tim Prince */
  7. 0.0000000001632881,
  8. 0.0000000250483893,
  9. 0.0000027557344615,
  10. 0.0001984126975233,
  11. 0.0083333333334816,
  12. 0.1666666666666574,
  13. 1.0000000000000001};
  14. _CRTIMP2 double __cdecl _Sinh(double x, double y)
  15. { /* compute y*sinh(x), |y| <= 1 */
  16. short neg;
  17. switch (_Dtest(&x))
  18. { /* test for special codes */
  19. case _NANCODE:
  20. return (x);
  21. case _INFCODE:
  22. return (y != 0.0 ? x : DSIGN(x) ? -y : y);
  23. case 0:
  24. return (x * y);
  25. default: /* finite */
  26. if (y == 0.0)
  27. return (x < 0.0 ? -y : y);
  28. if (x < 0.0)
  29. x = -x, neg = 1;
  30. else
  31. neg = 0;
  32. if (x < _Rteps._Double)
  33. x *= y; /* x tiny */
  34. else if (x < 1.0)
  35. {
  36. double w = x * x;
  37. x += x * w * _Poly(w, p, NP - 1);
  38. x *= y;
  39. }
  40. else if (x < _Xbig)
  41. { /* worth adding in exp(-x) */
  42. _Exp(&x, 1.0, -1);
  43. x = y * (x - 0.25 / x);
  44. }
  45. else
  46. switch (_Exp(&x, y, -1))
  47. { /* report over/underflow */
  48. case 0:
  49. _Feraise(_FE_UNDERFLOW);
  50. break;
  51. case _INFCODE:
  52. _Feraise(_FE_OVERFLOW);
  53. }
  54. return (neg ? -x : x);
  55. }
  56. }
  57. _STD_END
  58. /*
  59. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  60. * Consult your license regarding permissions and restrictions.
  61. V3.10:0009 */