Source code of Windows XP (NT5)
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.

68 lines
1.3 KiB

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