master
  1/**
  2 * This file has no copyright assigned and is placed in the Public Domain.
  3 * This file is part of the mingw-w64 runtime package.
  4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  5 */
  6#include "cephes_mconf.h"
  7#include <errno.h>
  8
  9#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
 10#include <math.h>
 11
 12long double sinhl(long double x)
 13{
 14  return sinh(x);
 15}
 16#else
 17
 18#ifdef UNK
 19static uLD P[] = {
 20  { { 1.7550769032975377032681E-6L } },
 21  { { 4.1680702175874268714539E-4L } },
 22  { { 3.0993532520425419002409E-2L } },
 23  { { 9.9999999999999999998002E-1L } }
 24};
 25static long double Q[] = {
 26  { { 1.7453965448620151484660E-8L } },
 27  { { -5.9116673682651952419571E-6L } },
 28  { { 1.0599252315677389339530E-3L } },
 29  { { -1.1403880487744749056675E-1L } },
 30  { { 6.0000000000000000000200E0L } }
 31};
 32#endif
 33
 34#ifdef IBMPC
 35static const uLD P[] = {
 36  { { 0xec6a,0xd942,0xfbb3,0xeb8f,0x3feb, 0, 0, 0 } },
 37  { { 0x365e,0xb30a,0xe437,0xda86,0x3ff3, 0, 0, 0 } },
 38  { { 0x8890,0x01f6,0x2612,0xfde6,0x3ff9, 0, 0, 0 } },
 39  { { 0x0000,0x0000,0x0000,0x8000,0x3fff, 0, 0, 0 } }
 40};
 41static const uLD Q[] = {
 42  { { 0x4edd,0x4c21,0xad09,0x95ed,0x3fe5, 0, 0, 0 } },
 43  { { 0x4376,0x9b70,0xd605,0xc65c,0xbfed, 0, 0, 0 } },
 44  { { 0xc8ad,0x5d21,0x3069,0x8aed,0x3ff5, 0, 0, 0 } },
 45  { { 0x9c32,0x6374,0x2d4b,0xe98d,0xbffb, 0, 0, 0 } },
 46  { { 0x0000,0x0000,0x0000,0xc000,0x4001, 0, 0, 0 } }
 47};
 48#endif
 49
 50#ifdef MIEEE
 51static uLD P[] = {
 52  { { 0x3feb0000,0xeb8ffbb3,0xd942ec6a, 0 } },
 53  { { 0x3ff30000,0xda86e437,0xb30a365e, 0 } },
 54  { { 0x3ff90000,0xfde62612,0x01f68890, 0 } },
 55  { { 0x3fff0000,0x80000000,0x00000000, 0 } }
 56};
 57static uLD Q[] = {
 58  { { 0x3fe50000,0x95edad09,0x4c214edd, 0 } },
 59  { { 0xbfed0000,0xc65cd605,0x9b704376, 0 } },
 60  { { 0x3ff50000,0x8aed3069,0x5d21c8ad, 0 } },
 61  { { 0xbffb0000,0xe98d2d4b,0x63749c32, 0 } },
 62  { { 0x40010000,0xc0000000,0x00000000, 0 } }
 63};
 64#endif
 65
 66long double sinhl(long double x)
 67{
 68  long double a;
 69  int x_class = fpclassify (x);
 70
 71  if (x_class == FP_NAN)
 72    {
 73      errno = EDOM;
 74      return x;
 75    }
 76  if (x_class == FP_ZERO)
 77    return x;
 78  if (x_class == FP_INFINITE ||
 79      (fabsl (x) > (MAXLOGL + LOGE2L)))
 80  {
 81    errno = ERANGE;
 82#ifdef INFINITIES
 83    return (signbit (x) ? -INFINITYL : INFINITYL);
 84#else
 85    return (signbit (x) ? -MAXNUML : MAXNUML);
 86#endif
 87  }
 88  a = fabsl (x);
 89  if (a > 1.0L)
 90  {
 91    if (a >= (MAXLOGL - LOGE2L))
 92    {
 93      a = expl(0.5L*a);
 94      a = (0.5L * a) * a;
 95      if (x < 0.0L)
 96	a = -a;
 97      return (a);
 98    }
 99    a = expl(a);
100    a = 0.5L*a - (0.5L/a);
101    if (x < 0.0L)
102      a = -a;
103    return (a);
104  }
105
106  a *= a;
107  return (x + x * a * (polevll(a,P,3)/polevll(a,Q,4)));
108}
109#endif