OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libquadmath/] [math/] [sinhq.c] - Blame information for rev 742

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 740 jeremybenn
/* e_sinhl.c -- __float128 version of e_sinh.c.
2
 * Conversion to __float128 by Ulrich Drepper,
3
 * Cygnus Support, drepper@cygnus.com.
4
 */
5
 
6
/*
7
 * ====================================================
8
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9
 *
10
 * Developed at SunPro, a Sun Microsystems, Inc. business.
11
 * Permission to use, copy, modify, and distribute this
12
 * software is freely granted, provided that this notice
13
 * is preserved.
14
 * ====================================================
15
 */
16
 
17
/* Changes for 128-bit __float128 are
18
   Copyright (C) 2001 Stephen L. Moshier <moshier@na-net.ornl.gov>
19
   and are incorporated herein by permission of the author.  The author
20
   reserves the right to distribute this material elsewhere under different
21
   copying permissions.  These modifications are distributed here under
22
   the following terms:
23
 
24
    This library is free software; you can redistribute it and/or
25
    modify it under the terms of the GNU Lesser General Public
26
    License as published by the Free Software Foundation; either
27
    version 2.1 of the License, or (at your option) any later version.
28
 
29
    This library is distributed in the hope that it will be useful,
30
    but WITHOUT ANY WARRANTY; without even the implied warranty of
31
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
32
    Lesser General Public License for more details.
33
 
34
    You should have received a copy of the GNU Lesser General Public
35
    License along with this library; if not, write to the Free Software
36
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA */
37
 
38
/* __ieee754_sinhl(x)
39
 * Method :
40
 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
41
 *      1. Replace x by |x| (sinhl(-x) = -sinhl(x)).
42
 *      2.
43
 *                                                   E + E/(E+1)
44
 *          0        <= x <= 25     :  sinhl(x) := --------------, E=expm1l(x)
45
 *                                                       2
46
 *
47
 *          25       <= x <= lnovft :  sinhl(x) := expl(x)/2
48
 *          lnovft   <= x <= ln2ovft:  sinhl(x) := expl(x/2)/2 * expl(x/2)
49
 *          ln2ovft  <  x           :  sinhl(x) := x*shuge (overflow)
50
 *
51
 * Special cases:
52
 *      sinhl(x) is |x| if x is +INF, -INF, or NaN.
53
 *      only sinhl(0)=0 is exact for finite x.
54
 */
55
 
56
#include "quadmath-imp.h"
57
 
58
static const __float128 one = 1.0, shuge = 1.0e4931Q,
59
  ovf_thresh = 1.1357216553474703894801348310092223067821E4Q;
60
 
61
__float128
62
sinhq (__float128 x)
63
{
64
  __float128 t, w, h;
65
  uint32_t jx, ix;
66
  ieee854_float128 u;
67
 
68
  /* Words of |x|. */
69
  u.value = x;
70
  jx = u.words32.w0;
71
  ix = jx & 0x7fffffff;
72
 
73
  /* x is INF or NaN */
74
  if (ix >= 0x7fff0000)
75
    return x + x;
76
 
77
  h = 0.5Q;
78
  if (jx & 0x80000000)
79
    h = -h;
80
 
81
  /* Absolute value of x.  */
82
  u.words32.w0 = ix;
83
 
84
  /* |x| in [0,40], return sign(x)*0.5*(E+E/(E+1))) */
85
  if (ix <= 0x40044000)
86
    {
87
      if (ix < 0x3fc60000) /* |x| < 2^-57 */
88
        if (shuge + x > one)
89
          return x;             /* sinh(tiny) = tiny with inexact */
90
      t = expm1q (u.value);
91
      if (ix < 0x3fff0000)
92
        return h * (2.0Q * t - t * t / (t + one));
93
      return h * (t + t / (t + one));
94
    }
95
 
96
  /* |x| in [40, log(maxdouble)] return 0.5*exp(|x|) */
97
  if (ix <= 0x400c62e3) /* 11356.375 */
98
    return h * expq (u.value);
99
 
100
  /* |x| in [log(maxdouble), overflowthreshold]
101
     Overflow threshold is log(2 * maxdouble).  */
102
  if (u.value <= ovf_thresh)
103
    {
104
      w = expq (0.5Q * u.value);
105
      t = h * w;
106
      return t * w;
107
    }
108
 
109
  /* |x| > overflowthreshold, sinhl(x) overflow */
110
  return x * shuge;
111
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.