~ubuntu-branches/ubuntu/precise/eglibc/precise

« back to all changes in this revision

Viewing changes to sysdeps/ieee754/dbl-64/e_sinh.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-10-04 17:48:26 UTC
  • mfrom: (216.1.23 oneiric)
  • Revision ID: package-import@ubuntu.com-20111004174826-2cyb9ewn3ucymlsx
Tags: 2.13-20ubuntu5
libc6-dev: Don't break the current {gnat,gcj}-4.4-base versons. LP: #853688.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *
6
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
7
7
 * Permission to use, copy, modify, and distribute this
8
 
 * software is freely granted, provided that this notice
 
8
 * software is freely granted, provided that this notice 
9
9
 * is preserved.
10
10
 * ====================================================
11
11
 */
15
15
#endif
16
16
 
17
17
/* __ieee754_sinh(x)
18
 
 * Method :
 
18
 * Method : 
19
19
 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
20
 
 *      1. Replace x by |x| (sinh(-x) = -sinh(x)).
21
 
 *      2.
22
 
 *                                                  E + E/(E+1)
 
20
 *      1. Replace x by |x| (sinh(-x) = -sinh(x)). 
 
21
 *      2. 
 
22
 *                                                  E + E/(E+1)
23
23
 *          0        <= x <= 22     :  sinh(x) := --------------, E=expm1(x)
24
 
 *                                                      2
 
24
 *                                                      2
25
25
 *
26
 
 *          22       <= x <= lnovft :  sinh(x) := exp(x)/2
 
26
 *          22       <= x <= lnovft :  sinh(x) := exp(x)/2 
27
27
 *          lnovft   <= x <= ln2ovft:  sinh(x) := exp(x/2)/2 * exp(x/2)
28
28
 *          ln2ovft  <  x           :  sinh(x) := x*shuge (overflow)
29
29
 *
35
35
#include "math.h"
36
36
#include "math_private.h"
37
37
 
 
38
#ifdef __STDC__
38
39
static const double one = 1.0, shuge = 1.0e307;
 
40
#else
 
41
static double one = 1.0, shuge = 1.0e307;
 
42
#endif
39
43
 
40
 
double
41
 
__ieee754_sinh(double x)
42
 
{
 
44
#ifdef __STDC__
 
45
        double __ieee754_sinh(double x)
 
46
#else
 
47
        double __ieee754_sinh(x)
 
48
        double x;
 
49
#endif
 
50
{       
43
51
        double t,w,h;
44
52
        int32_t ix,jx;
45
53
        u_int32_t lx;
49
57
        ix = jx&0x7fffffff;
50
58
 
51
59
    /* x is INF or NaN */
52
 
        if(__builtin_expect(ix>=0x7ff00000, 0)) return x+x;
 
60
        if(ix>=0x7ff00000) return x+x;  
53
61
 
54
62
        h = 0.5;
55
63
        if (jx<0) h = -h;
56
64
    /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
57
65
        if (ix < 0x40360000) {          /* |x|<22 */
58
 
            if (__builtin_expect(ix<0x3e300000, 0))     /* |x|<2**-28 */
59
 
                if(shuge+x>one)
60
 
                    return x;/* sinh(tiny) = tiny with inexact */
 
66
            if (ix<0x3e300000)          /* |x|<2**-28 */
 
67
                if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
61
68
            t = __expm1(fabs(x));
62
69
            if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
63
70
            return h*(t+t/(t+one));
77
84
    /* |x| > overflowthresold, sinh(x) overflow */
78
85
        return x*shuge;
79
86
}
80
 
strong_alias (__ieee754_sinh, __sinh_finite)