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.

87 lines
2.2 KiB

  1. /* _LSinh function */
  2. #include "xmath.h"
  3. _STD_BEGIN
  4. /* coefficients */
  5. #define NP (sizeof (p) / sizeof (p[0]) - 1)
  6. #if _DLONG <= 1 /* assume IEEE 754 10 byte */
  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. #else /* assume IEEE 754 16 byte */
  18. static const long double p[] = { /* courtesy Dr. Tim Prince */
  19. 0.00000000000000000000000006506911776L,
  20. 0.00000000000000000000003867997525529L,
  21. 0.00000000000000000001957294395545097L,
  22. 0.00000000000000000822063524350084984L,
  23. 0.00000000000000281145725434779709982L,
  24. 0.00000000000076471637318198050919003L,
  25. 0.00000000016059043836821614638343470L,
  26. 0.00000002505210838544171877496283537L,
  27. 0.00000275573192239858906525574505191L,
  28. 0.00019841269841269841269841269726379L,
  29. 0.00833333333333333333333333333338555L,
  30. 0.16666666666666666666666666666666573L,
  31. 1.0L};
  32. #endif
  33. _CRTIMP2 long double __cdecl _LSinh(long double x, long double y)
  34. { /* compute y*sinh(x), |y| <= 1 */
  35. short neg;
  36. switch (_LDtest(&x))
  37. { /* test for special codes */
  38. case _NANCODE:
  39. return (x);
  40. case _INFCODE:
  41. return (y != 0.0L ? x : LSIGN(x) ? -y : y);
  42. case 0:
  43. return (x * y);
  44. default: /* finite */
  45. if (y == 0.0L)
  46. return (x < 0.0L ? -y : y);
  47. if (x < 0.0L)
  48. x = -x, neg = 1;
  49. else
  50. neg = 0;
  51. if (x < _LRteps._Long_double)
  52. x *= y; /* x tiny */
  53. else if (x < 1.0L)
  54. {
  55. long double w = x * x;
  56. x += x * w * _LPoly(w, p, NP - 1);
  57. x *= y;
  58. }
  59. else if (x < _LXbig)
  60. { /* worth adding in exp(-x) */
  61. _LExp(&x, 1.0L, -1);
  62. x = y * (x - 0.25L / x);
  63. }
  64. else
  65. switch (_LExp(&x, y, -1))
  66. { /* report over/underflow */
  67. case 0:
  68. _Feraise(_FE_UNDERFLOW);
  69. break;
  70. case _INFCODE:
  71. _Feraise(_FE_OVERFLOW);
  72. }
  73. return (neg ? -x : x);
  74. }
  75. }
  76. _STD_END
  77. /*
  78. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  79. * Consult your license regarding permissions and restrictions.
  80. V3.10:0009 */