+++ /dev/null
-/* @(#)e_cosh.c 5.1 93/09/24 */\r
-/*\r
- * ====================================================\r
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\r
- *\r
- * Developed at SunPro, a Sun Microsystems, Inc. business.\r
- * Permission to use, copy, modify, and distribute this\r
- * software is freely granted, provided that this notice\r
- * is preserved.\r
- * ====================================================\r
- */\r
-#include <LibConfig.h>\r
-#include <sys/EfiCdefs.h>\r
-#if defined(LIBM_SCCS) && !defined(lint)\r
-__RCSID("$NetBSD: e_cosh.c,v 1.11 2002/05/26 22:01:49 wiz Exp $");\r
-#endif\r
-\r
-#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */\r
- // C4756: overflow in constant arithmetic\r
- #pragma warning ( disable : 4756 )\r
-#endif\r
-\r
-/* __ieee754_cosh(x)\r
- * Method :\r
- * mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2\r
- * 1. Replace x by |x| (cosh(x) = cosh(-x)).\r
- * 2.\r
- * [ exp(x) - 1 ]^2\r
- * 0 <= x <= ln2/2 : cosh(x) := 1 + -------------------\r
- * 2*exp(x)\r
- *\r
- * exp(x) + 1/exp(x)\r
- * ln2/2 <= x <= 22 : cosh(x) := -------------------\r
- * 2\r
- * 22 <= x <= lnovft : cosh(x) := exp(x)/2\r
- * lnovft <= x <= ln2ovft: cosh(x) := exp(x/2)/2 * exp(x/2)\r
- * ln2ovft < x : cosh(x) := huge*huge (overflow)\r
- *\r
- * Special cases:\r
- * cosh(x) is |x| if x is +INF, -INF, or NaN.\r
- * only cosh(0)=1 is exact for finite x.\r
- */\r
-\r
-#include "math.h"\r
-#include "math_private.h"\r
-\r
-static const double one = 1.0, half=0.5, huge = 1.0e300;\r
-\r
-double\r
-__ieee754_cosh(double x)\r
-{\r
- double t,w;\r
- int32_t ix;\r
- u_int32_t lx;\r
-\r
- /* High word of |x|. */\r
- GET_HIGH_WORD(ix,x);\r
- ix &= 0x7fffffff;\r
-\r
- /* x is INF or NaN */\r
- if(ix>=0x7ff00000) return x*x;\r
-\r
- /* |x| in [0,0.5*ln2], return 1+expm1(|x|)^2/(2*exp(|x|)) */\r
- if(ix<0x3fd62e43) {\r
- t = expm1(fabs(x));\r
- w = one+t;\r
- if (ix<0x3c800000) return w; /* cosh(tiny) = 1 */\r
- return one+(t*t)/(w+w);\r
- }\r
-\r
- /* |x| in [0.5*ln2,22], return (exp(|x|)+1/exp(|x|)/2; */\r
- if (ix < 0x40360000) {\r
- t = __ieee754_exp(fabs(x));\r
- return half*t+half/t;\r
- }\r
-\r
- /* |x| in [22, log(maxdouble)] return half*exp(|x|) */\r
- if (ix < 0x40862E42) return half*__ieee754_exp(fabs(x));\r
-\r
- /* |x| in [log(maxdouble), overflowthresold] */\r
- GET_LOW_WORD(lx,x);\r
- if (ix<0x408633CE ||\r
- ((ix==0x408633ce)&&(lx<=(u_int32_t)0x8fb9f87d))) {\r
- w = __ieee754_exp(half*fabs(x));\r
- t = half*w;\r
- return t*w;\r
- }\r
-\r
- /* |x| > overflowthresold, cosh(x) overflow */\r
- return huge*huge;\r
-}\r