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.

70 lines
1.5 KiB

  1. /* _LSinh 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 long double p[] = { /* courtesy Dr. Tim Prince */
  8. 0.0000000000000028486835L,
  9. 0.0000000000007646464279L,
  10. 0.0000000001605905091647L,
  11. 0.0000000250521083436962L,
  12. 0.0000027557319224130455L,
  13. 0.0001984126984126956009L,
  14. 0.0083333333333333336073L,
  15. 0.1666666666666666666564L,
  16. 1.0000000000000000000001L};
  17. _CRTIMP2 long double __cdecl _LSinh(long double x, long double y)
  18. { /* compute y*sinh(x), |y| <= 1 */
  19. switch (_LDtest(&x))
  20. { /* test for special codes */
  21. case NAN:
  22. errno = EDOM;
  23. return (x);
  24. case INF:
  25. if (y == 0)
  26. return (0);
  27. errno = ERANGE;
  28. return (LSIGN(x) ? -_LInf._L : _LInf._L);
  29. case 0:
  30. return (0);
  31. default: /* finite */
  32. { /* compute sinh(finite) */
  33. short neg;
  34. if (x < 0)
  35. x = -x, neg = 1;
  36. else
  37. neg = 0;
  38. if (x < _LRteps._L)
  39. x *= y; /* x tiny */
  40. else if (x < 1)
  41. {
  42. long double w = x * x;
  43. x += x * w * _LPoly(w, p, NP - 1);
  44. x *= y;
  45. }
  46. else if (x < _LXbig)
  47. { /* worth adding in exp(-x) */
  48. _LExp(&x, 1, -1);
  49. x = y * (x - 0.25 / x);
  50. }
  51. else if (0 <= _LExp(&x, y, -1))
  52. errno = ERANGE; /* x large */
  53. return (neg ? -x : x);
  54. }
  55. }
  56. }
  57. _STD_END
  58. /*
  59. * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
  60. * Consult your license regarding permissions and restrictions.
  61. */
  62. /*
  63. 941029 pjp: added _STD machinery
  64. */