os/ossrv/genericopenlibs/cstdlib/LMATH/E_SINH.C
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/* E_SINH.C
sl@0
     2
 * 
sl@0
     3
 * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     4
 * All rights reserved.
sl@0
     5
 */
sl@0
     6
sl@0
     7
sl@0
     8
/* @(#)e_sinh.c 5.1 93/09/24 */
sl@0
     9
/*
sl@0
    10
 * ====================================================
sl@0
    11
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
sl@0
    12
 *
sl@0
    13
 * Developed at SunPro, a Sun Microsystems, Inc. business.
sl@0
    14
 * Permission to use, copy, modify, and distribute this
sl@0
    15
 * software is freely granted, provided that this notice 
sl@0
    16
 * is preserved.
sl@0
    17
 * ====================================================
sl@0
    18
 */
sl@0
    19
sl@0
    20
/* __ieee754_sinh(x)
sl@0
    21
 * Method : 
sl@0
    22
 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
sl@0
    23
 *	1. Replace x by |x| (sinh(-x) = -sinh(x)). 
sl@0
    24
 *	2. 
sl@0
    25
 *		                                    E + E/(E+1)
sl@0
    26
 *	    0        <= x <= 22     :  sinh(x) := --------------, E=expm1(x)
sl@0
    27
 *			       			        2
sl@0
    28
 *
sl@0
    29
 *	    22       <= x <= lnovft :  sinh(x) := exp(x)/2 
sl@0
    30
 *	    lnovft   <= x <= ln2ovft:  sinh(x) := exp(x/2)/2 * exp(x/2)
sl@0
    31
 *	    ln2ovft  <  x	    :  sinh(x) := x*shuge (overflow)
sl@0
    32
 *
sl@0
    33
 * Special cases:
sl@0
    34
 *	sinh(x) is |x| if x is +INF, -INF, or NaN.
sl@0
    35
 *	only sinh(0)=0 is exact for finite x.
sl@0
    36
 */
sl@0
    37
sl@0
    38
#include "FDLIBM.H"
sl@0
    39
sl@0
    40
static const double one = 1.0, shuge = 1.0e307;
sl@0
    41
	
sl@0
    42
EXPORT_C double __ieee754_sinh(double x) __SOFTFP
sl@0
    43
{	
sl@0
    44
	double t,w,h;
sl@0
    45
	__int32_t ix,jx;
sl@0
    46
	__uint32_t lx;
sl@0
    47
sl@0
    48
    /* High word of |x|. */
sl@0
    49
	GET_HIGH_WORD(jx,x);
sl@0
    50
	ix = jx&0x7fffffff;
sl@0
    51
sl@0
    52
    /* x is INF or NaN */
sl@0
    53
	if(ix>=0x7ff00000) return x+x;	
sl@0
    54
sl@0
    55
	h = 0.5;
sl@0
    56
	if (jx<0) h = -h;
sl@0
    57
    /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
sl@0
    58
	if (ix < 0x40360000) {		/* |x|<22 */
sl@0
    59
	    if (ix<0x3e300000) 		/* |x|<2**-28 */
sl@0
    60
		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
sl@0
    61
	    t = expm1(fabs(x));
sl@0
    62
	    if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
sl@0
    63
	    return h*(t+t/(t+one));
sl@0
    64
	}
sl@0
    65
sl@0
    66
    /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
sl@0
    67
	if (ix < 0x40862E42)  return h*__ieee754_exp(fabs(x));
sl@0
    68
sl@0
    69
    /* |x| in [log(maxdouble), overflowthresold] */
sl@0
    70
	GET_LOW_WORD(lx,x);
sl@0
    71
	if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(__uint32_t)0x8fb9f87d))) {
sl@0
    72
	    w = __ieee754_exp(0.5*fabs(x));
sl@0
    73
	    t = h*w;
sl@0
    74
	    return t*w;
sl@0
    75
	}
sl@0
    76
sl@0
    77
    /* |x| > overflowthresold, sinh(x) overflow */
sl@0
    78
	return x*shuge;
sl@0
    79
}