os/ossrv/genericopenlibs/cstdlib/LMATH/E_SINH.C
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LMATH/E_SINH.C	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,79 @@
     1.4 +/* E_SINH.C
     1.5 + * 
     1.6 + * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
     1.7 + * All rights reserved.
     1.8 + */
     1.9 +
    1.10 +
    1.11 +/* @(#)e_sinh.c 5.1 93/09/24 */
    1.12 +/*
    1.13 + * ====================================================
    1.14 + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
    1.15 + *
    1.16 + * Developed at SunPro, a Sun Microsystems, Inc. business.
    1.17 + * Permission to use, copy, modify, and distribute this
    1.18 + * software is freely granted, provided that this notice 
    1.19 + * is preserved.
    1.20 + * ====================================================
    1.21 + */
    1.22 +
    1.23 +/* __ieee754_sinh(x)
    1.24 + * Method : 
    1.25 + * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
    1.26 + *	1. Replace x by |x| (sinh(-x) = -sinh(x)). 
    1.27 + *	2. 
    1.28 + *		                                    E + E/(E+1)
    1.29 + *	    0        <= x <= 22     :  sinh(x) := --------------, E=expm1(x)
    1.30 + *			       			        2
    1.31 + *
    1.32 + *	    22       <= x <= lnovft :  sinh(x) := exp(x)/2 
    1.33 + *	    lnovft   <= x <= ln2ovft:  sinh(x) := exp(x/2)/2 * exp(x/2)
    1.34 + *	    ln2ovft  <  x	    :  sinh(x) := x*shuge (overflow)
    1.35 + *
    1.36 + * Special cases:
    1.37 + *	sinh(x) is |x| if x is +INF, -INF, or NaN.
    1.38 + *	only sinh(0)=0 is exact for finite x.
    1.39 + */
    1.40 +
    1.41 +#include "FDLIBM.H"
    1.42 +
    1.43 +static const double one = 1.0, shuge = 1.0e307;
    1.44 +	
    1.45 +EXPORT_C double __ieee754_sinh(double x) __SOFTFP
    1.46 +{	
    1.47 +	double t,w,h;
    1.48 +	__int32_t ix,jx;
    1.49 +	__uint32_t lx;
    1.50 +
    1.51 +    /* High word of |x|. */
    1.52 +	GET_HIGH_WORD(jx,x);
    1.53 +	ix = jx&0x7fffffff;
    1.54 +
    1.55 +    /* x is INF or NaN */
    1.56 +	if(ix>=0x7ff00000) return x+x;	
    1.57 +
    1.58 +	h = 0.5;
    1.59 +	if (jx<0) h = -h;
    1.60 +    /* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
    1.61 +	if (ix < 0x40360000) {		/* |x|<22 */
    1.62 +	    if (ix<0x3e300000) 		/* |x|<2**-28 */
    1.63 +		if(shuge+x>one) return x;/* sinh(tiny) = tiny with inexact */
    1.64 +	    t = expm1(fabs(x));
    1.65 +	    if(ix<0x3ff00000) return h*(2.0*t-t*t/(t+one));
    1.66 +	    return h*(t+t/(t+one));
    1.67 +	}
    1.68 +
    1.69 +    /* |x| in [22, log(maxdouble)] return 0.5*exp(|x|) */
    1.70 +	if (ix < 0x40862E42)  return h*__ieee754_exp(fabs(x));
    1.71 +
    1.72 +    /* |x| in [log(maxdouble), overflowthresold] */
    1.73 +	GET_LOW_WORD(lx,x);
    1.74 +	if (ix<0x408633CE || ((ix==0x408633ce)&&(lx<=(__uint32_t)0x8fb9f87d))) {
    1.75 +	    w = __ieee754_exp(0.5*fabs(x));
    1.76 +	    t = h*w;
    1.77 +	    return t*w;
    1.78 +	}
    1.79 +
    1.80 +    /* |x| > overflowthresold, sinh(x) overflow */
    1.81 +	return x*shuge;
    1.82 +}