1 | |
---|
2 | /* @(#)w_atanh.c 5.1 93/09/24 */ |
---|
3 | /* |
---|
4 | * ==================================================== |
---|
5 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
---|
6 | * |
---|
7 | * Developed at SunPro, a Sun Microsystems, Inc. business. |
---|
8 | * Permission to use, copy, modify, and distribute this |
---|
9 | * software is freely granted, provided that this notice |
---|
10 | * is preserved. |
---|
11 | * ==================================================== |
---|
12 | */ |
---|
13 | |
---|
14 | /* |
---|
15 | FUNCTION |
---|
16 | <<atanh>>, <<atanhf>>---inverse hyperbolic tangent |
---|
17 | |
---|
18 | INDEX |
---|
19 | atanh |
---|
20 | INDEX |
---|
21 | atanhf |
---|
22 | |
---|
23 | SYNOPSIS |
---|
24 | #include <math.h> |
---|
25 | double atanh(double <[x]>); |
---|
26 | float atanhf(float <[x]>); |
---|
27 | |
---|
28 | DESCRIPTION |
---|
29 | <<atanh>> calculates the inverse hyperbolic tangent of <[x]>. |
---|
30 | |
---|
31 | <<atanhf>> is identical, other than taking and returning |
---|
32 | <<float>> values. |
---|
33 | |
---|
34 | RETURNS |
---|
35 | <<atanh>> and <<atanhf>> return the calculated value. |
---|
36 | |
---|
37 | If |
---|
38 | @ifnottex |
---|
39 | |<[x]>| |
---|
40 | @end ifnottex |
---|
41 | @tex |
---|
42 | $|x|$ |
---|
43 | @end tex |
---|
44 | is greater than 1, the global <<errno>> is set to <<EDOM>> and |
---|
45 | the result is a NaN. A <<DOMAIN error>> is reported. |
---|
46 | |
---|
47 | If |
---|
48 | @ifnottex |
---|
49 | |<[x]>| |
---|
50 | @end ifnottex |
---|
51 | @tex |
---|
52 | $|x|$ |
---|
53 | @end tex |
---|
54 | is 1, the global <<errno>> is set to <<EDOM>>; and the result is |
---|
55 | infinity with the same sign as <<x>>. A <<SING error>> is reported. |
---|
56 | |
---|
57 | You can modify the error handling for these routines using |
---|
58 | <<matherr>>. |
---|
59 | |
---|
60 | PORTABILITY |
---|
61 | Neither <<atanh>> nor <<atanhf>> are ANSI C. |
---|
62 | |
---|
63 | QUICKREF |
---|
64 | atanh - pure |
---|
65 | atanhf - pure |
---|
66 | |
---|
67 | |
---|
68 | */ |
---|
69 | |
---|
70 | /* |
---|
71 | * wrapper atanh(x) |
---|
72 | */ |
---|
73 | |
---|
74 | #include "fdlibm.h" |
---|
75 | #include <errno.h> |
---|
76 | |
---|
77 | #ifndef _DOUBLE_IS_32BITS |
---|
78 | |
---|
79 | #ifdef __STDC__ |
---|
80 | double atanh(double x) /* wrapper atanh */ |
---|
81 | #else |
---|
82 | double atanh(x) /* wrapper atanh */ |
---|
83 | double x; |
---|
84 | #endif |
---|
85 | { |
---|
86 | #ifdef _IEEE_LIBM |
---|
87 | return __ieee754_atanh(x); |
---|
88 | #else |
---|
89 | double z,y; |
---|
90 | struct exception exc; |
---|
91 | z = __ieee754_atanh(x); |
---|
92 | if(_LIB_VERSION == _IEEE_ || isnan(x)) return z; |
---|
93 | y = fabs(x); |
---|
94 | if(y>=1.0) { |
---|
95 | if(y>1.0) { |
---|
96 | /* atanh(|x|>1) */ |
---|
97 | exc.type = DOMAIN; |
---|
98 | exc.name = "atanh"; |
---|
99 | exc.err = 0; |
---|
100 | exc.arg1 = exc.arg2 = x; |
---|
101 | exc.retval = 0.0/0.0; |
---|
102 | if (_LIB_VERSION == _POSIX_) |
---|
103 | errno = EDOM; |
---|
104 | else if (!matherr(&exc)) { |
---|
105 | errno = EDOM; |
---|
106 | } |
---|
107 | } else { |
---|
108 | /* atanh(|x|=1) */ |
---|
109 | exc.type = SING; |
---|
110 | exc.name = "atanh"; |
---|
111 | exc.err = 0; |
---|
112 | exc.arg1 = exc.arg2 = x; |
---|
113 | exc.retval = x/0.0; /* sign(x)*inf */ |
---|
114 | if (_LIB_VERSION == _POSIX_) |
---|
115 | errno = EDOM; |
---|
116 | else if (!matherr(&exc)) { |
---|
117 | errno = EDOM; |
---|
118 | } |
---|
119 | } |
---|
120 | if (exc.err != 0) |
---|
121 | errno = exc.err; |
---|
122 | return exc.retval; |
---|
123 | } else |
---|
124 | return z; |
---|
125 | #endif |
---|
126 | } |
---|
127 | |
---|
128 | #endif /* defined(_DOUBLE_IS_32BITS) */ |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | |
---|