Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
 
2
/*
3
 * ====================================================
4
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
7
 * Permission to use, copy, modify, and distribute this
8
 * software is freely granted, provided that this notice
9
 * is preserved.
10
 * ====================================================
11
 */
12
13
 
14
15
 
16
        <>, <>---hyperbolic cosine
17
18
 
19
        #include 
20
        double cosh(double <[x]>);
21
        float coshf(float <[x]>)
22
23
 
24
        #include 
25
        double cosh(<[x]>)
26
        double <[x]>;
27
28
 
29
        float <[x]>;
30
31
 
32
33
 
34
	<)>> is defined as
35
	@ifnottex
36
	. (exp(x) + exp(-x))/2
37
	@end ifnottex
38
	@tex
39
	$${(e^x + e^{-x})} \over 2$$
40
	@end tex
41
42
 
43
44
 
45
46
 
47
	The computed value is returned.  When the correct value would create
48
	an overflow,  <> returns the value <> with the
49
	appropriate sign, and the global value <> is set to <>.
50
51
 
52
	function <>.
53
54
 
55
	<> is ANSI.
56
	<> is an extension.
57
58
 
59
	cosh ansi pure
60
	coshf - pure
61
*/
62
63
 
64
 * wrapper cosh(x)
65
 */
66
67
 
68
#include 
69
70
 
71
72
 
73
	double cosh(double x)		/* wrapper cosh */
74
#else
75
	double cosh(x)			/* wrapper cosh */
76
	double x;
77
#endif
78
{
79
#ifdef _IEEE_LIBM
80
	return __ieee754_cosh(x);
81
#else
82
	double z;
83
	struct exception exc;
84
	z = __ieee754_cosh(x);
85
	if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
86
	if(fabs(x)>7.10475860073943863426e+02) {
87
	    /* cosh(finite) overflow */
88
#ifndef HUGE_VAL
89
#define HUGE_VAL inf
90
	    double inf = 0.0;
91
92
 
93
#endif
94
	    exc.type = OVERFLOW;
95
	    exc.name = "cosh";
96
	    exc.err = 0;
97
	    exc.arg1 = exc.arg2 = x;
98
	    if (_LIB_VERSION == _SVID_)
99
	       exc.retval = HUGE;
100
	    else
101
	       exc.retval = HUGE_VAL;
102
	    if (_LIB_VERSION == _POSIX_)
103
	       errno = ERANGE;
104
	    else if (!matherr(&exc)) {
105
	       errno = ERANGE;
106
	    }
107
	    if (exc.err != 0)
108
	       errno = exc.err;
109
	    return exc.retval;
110
	} else
111
	    return z;
112
#endif
113
}
114
115
 
116