1 |
694 |
jeremybenn |
! { dg-do run }
|
2 |
|
|
!
|
3 |
|
|
! PR fortran/33197
|
4 |
|
|
!
|
5 |
|
|
! Complex inverse trigonometric functions
|
6 |
|
|
! and complex inverse hyperbolic functions
|
7 |
|
|
!
|
8 |
|
|
! Run-time evaluation check
|
9 |
|
|
!
|
10 |
|
|
module test
|
11 |
|
|
implicit none
|
12 |
|
|
real(4), parameter :: eps4 = epsilon(0.0_4)*4.0_4
|
13 |
|
|
real(8), parameter :: eps8 = epsilon(0.0_8)*2.0_8
|
14 |
|
|
interface check
|
15 |
|
|
procedure check4, check8
|
16 |
|
|
end interface check
|
17 |
|
|
contains
|
18 |
|
|
SUBROUTINE check4(z, zref)
|
19 |
|
|
complex(4), intent(in) :: z, zref
|
20 |
|
|
if ( abs (real(z)-real(zref)) > eps4 &
|
21 |
|
|
.or.abs (aimag(z)-aimag(zref)) > eps4) then
|
22 |
|
|
print '(a,/,2((2g0," + I ",g0),/))', "check4:"," z=",z,'zref=',zref
|
23 |
|
|
print '(a,g0," + I*",g0," eps=",g0)', 'Diff: ', &
|
24 |
|
|
real(z)-real(zref), &
|
25 |
|
|
aimag(z)-aimag(zref), eps4
|
26 |
|
|
call abort()
|
27 |
|
|
end if
|
28 |
|
|
END SUBROUTINE check4
|
29 |
|
|
SUBROUTINE check8(z, zref)
|
30 |
|
|
complex(8), intent(in) :: z, zref
|
31 |
|
|
if ( abs (real(z)-real(zref)) > eps8 &
|
32 |
|
|
.or.abs (aimag(z)-aimag(zref)) > eps8) then
|
33 |
|
|
print '(a,/,2((2g0," + I ",g0),/))', "check8:"," z=",z,'zref=',zref
|
34 |
|
|
print '(a,g0," + I*",g0," eps=",g0)', 'Diff: ', &
|
35 |
|
|
real(z)-real(zref), &
|
36 |
|
|
aimag(z)-aimag(zref), eps8
|
37 |
|
|
call abort()
|
38 |
|
|
end if
|
39 |
|
|
END SUBROUTINE check8
|
40 |
|
|
end module test
|
41 |
|
|
|
42 |
|
|
PROGRAM ArcTrigHyp
|
43 |
|
|
use test
|
44 |
|
|
IMPLICIT NONE
|
45 |
|
|
complex(4), volatile :: z4
|
46 |
|
|
complex(8), volatile :: z8
|
47 |
|
|
|
48 |
|
|
!!!!! ZERO !!!!!!
|
49 |
|
|
|
50 |
|
|
! z = 0
|
51 |
|
|
z4 = cmplx(0.0_4, 0.0_4, kind=4)
|
52 |
|
|
z8 = cmplx(0.0_8, 0.0_8, kind=8)
|
53 |
|
|
|
54 |
|
|
! Exact: 0
|
55 |
|
|
call check(asin(z4), cmplx(0.0_4, 0.0_4, kind=4))
|
56 |
|
|
call check(asin(z8), cmplx(0.0_8, 0.0_8, kind=8))
|
57 |
|
|
! Exact: Pi/2 = 1.5707963267948966192313216916397514
|
58 |
|
|
call check(acos(z4), cmplx(1.57079632679489661920_4, 0.0_4, kind=4))
|
59 |
|
|
call check(acos(z8), cmplx(1.57079632679489661920_8, 0.0_8, kind=8))
|
60 |
|
|
! Exact: 0
|
61 |
|
|
call check(atan(z4), cmplx(0.0_4, 0.0_4, kind=4))
|
62 |
|
|
call check(atan(z8), cmplx(0.0_8, 0.0_8, kind=8))
|
63 |
|
|
! Exact: 0
|
64 |
|
|
call check(asinh(z4), cmplx(0.0_4, 0.0_4, kind=4))
|
65 |
|
|
call check(asinh(z8), cmplx(0.0_8, 0.0_8, kind=8))
|
66 |
|
|
! Exact: I*Pi/2 = I*1.5707963267948966192313216916397514
|
67 |
|
|
call check(acosh(z4), cmplx(0.0_4, 1.57079632679489661920_4, kind=4))
|
68 |
|
|
call check(acosh(z8), cmplx(0.0_8, 1.57079632679489661920_8, kind=8))
|
69 |
|
|
! Exact: 0
|
70 |
|
|
call check(atanh(z4), cmplx(0.0_4, 0.0_4, kind=4))
|
71 |
|
|
call check(atanh(z8), cmplx(0.0_8, 0.0_8, kind=8))
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
!!!!! POSITIVE NUMBERS !!!!!!
|
75 |
|
|
|
76 |
|
|
! z = tanh(1.0)
|
77 |
|
|
z4 = cmplx(0.76159415595576488811945828260479359_4, 0.0_4, kind=4)
|
78 |
|
|
z8 = cmplx(0.76159415595576488811945828260479359_8, 0.0_8, kind=8)
|
79 |
|
|
|
80 |
|
|
! Numerically: 0.86576948323965862428960184619184444
|
81 |
|
|
call check(asin(z4), cmplx(0.86576948323965862428960184619184444_4, 0.0_4, kind=4))
|
82 |
|
|
call check(asin(z8), cmplx(0.86576948323965862428960184619184444_8, 0.0_8, kind=8))
|
83 |
|
|
! Numerically: 0.70502684355523799494171984544790700
|
84 |
|
|
call check(acos(z4), cmplx(0.70502684355523799494171984544790700_4, 0.0_4, kind=4))
|
85 |
|
|
call check(acos(z8), cmplx(0.70502684355523799494171984544790700_8, 0.0_8, kind=8))
|
86 |
|
|
! Numerically: 0.65088016802300754993807813168285564
|
87 |
|
|
call check(atan(z4), cmplx(0.65088016802300754993807813168285564_4, 0.0_4, kind=4))
|
88 |
|
|
call check(atan(z8), cmplx(0.65088016802300754993807813168285564_8, 0.0_8, kind=8))
|
89 |
|
|
! Numerically: 0.70239670712987482778422106260749699
|
90 |
|
|
call check(asinh(z4), cmplx(0.70239670712987482778422106260749699_4, 0.0_4, kind=4))
|
91 |
|
|
call check(asinh(z8), cmplx(0.70239670712987482778422106260749699_8, 0.0_8, kind=8))
|
92 |
|
|
! Numerically: 0.70502684355523799494171984544790700*I
|
93 |
|
|
call check(acosh(z4), cmplx(0.0_4, 0.70502684355523799494171984544790700_4, kind=4))
|
94 |
|
|
call check(acosh(z8), cmplx(0.0_8, 0.70502684355523799494171984544790700_8, kind=8))
|
95 |
|
|
! Exact: 1
|
96 |
|
|
call check(atanh(z4), cmplx(1.0_4, 0.0_4, kind=4))
|
97 |
|
|
call check(atanh(z8), cmplx(1.0_8, 0.0_8, kind=8))
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
! z = I*tanh(1.0)
|
101 |
|
|
z4 = cmplx(0.0_4, 0.76159415595576488811945828260479359_4, kind=4)
|
102 |
|
|
z8 = cmplx(0.0_8, 0.76159415595576488811945828260479359_8, kind=8)
|
103 |
|
|
|
104 |
|
|
! Numerically: I*0.70239670712987482778422106260749699
|
105 |
|
|
call check(asin(z4), cmplx(0.0_4, 0.70239670712987482778422106260749699_4, kind=4))
|
106 |
|
|
call check(asin(z8), cmplx(0.0_8, 0.70239670712987482778422106260749699_8, kind=8))
|
107 |
|
|
! Numerically: 1.5707963267948966192313216916397514 - I*0.7023967071298748277842210626074970
|
108 |
|
|
call check(acos(z4), cmplx(1.5707963267948966192313216916397514_4, -0.7023967071298748277842210626074970_4, kind=4))
|
109 |
|
|
call check(acos(z8), cmplx(1.5707963267948966192313216916397514_8, -0.7023967071298748277842210626074970_8, kind=8))
|
110 |
|
|
! Exact: I*1
|
111 |
|
|
call check(atan(z4), cmplx(0.0_4, 1.0_4, kind=4))
|
112 |
|
|
call check(atan(z8), cmplx(0.0_8, 1.0_8, kind=8))
|
113 |
|
|
! Numerically: I*0.86576948323965862428960184619184444
|
114 |
|
|
call check(asinh(z4), cmplx(0.0_4, 0.86576948323965862428960184619184444_4, kind=4))
|
115 |
|
|
call check(asinh(z8), cmplx(0.0_8, 0.86576948323965862428960184619184444_8, kind=8))
|
116 |
|
|
! Numerically: 0.7023967071298748277842210626074970 + I*1.5707963267948966192313216916397514
|
117 |
|
|
call check(acosh(z4), cmplx(0.7023967071298748277842210626074970_4, 1.5707963267948966192313216916397514_4, kind=4))
|
118 |
|
|
call check(acosh(z8), cmplx(0.7023967071298748277842210626074970_8, 1.5707963267948966192313216916397514_8, kind=8))
|
119 |
|
|
! Numerically: I*0.65088016802300754993807813168285564
|
120 |
|
|
call check(atanh(z4), cmplx(0.0_4, 0.65088016802300754993807813168285564_4, kind=4))
|
121 |
|
|
call check(atanh(z8), cmplx(0.0_8, 0.65088016802300754993807813168285564_8, kind=8))
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
! z = (1+I)*tanh(1.0)
|
125 |
|
|
z4 = cmplx(0.76159415595576488811945828260479359_4, 0.76159415595576488811945828260479359_4, kind=4)
|
126 |
|
|
z8 = cmplx(0.76159415595576488811945828260479359_8, 0.76159415595576488811945828260479359_8, kind=8)
|
127 |
|
|
|
128 |
|
|
! Numerically: 0.59507386031622633330574869409179139 + I*0.82342412550090412964986631390412834
|
129 |
|
|
call check(asin(z4), cmplx(0.59507386031622633330574869409179139_4, 0.82342412550090412964986631390412834_4, kind=4))
|
130 |
|
|
call check(asin(z8), cmplx(0.59507386031622633330574869409179139_8, 0.82342412550090412964986631390412834_8, kind=8))
|
131 |
|
|
! Numerically: 0.97572246647867028592557299754796005 - I*0.82342412550090412964986631390412834
|
132 |
|
|
call check(acos(z4), cmplx(0.97572246647867028592557299754796005_4, -0.82342412550090412964986631390412834_4, kind=4))
|
133 |
|
|
call check(acos(z8), cmplx(0.97572246647867028592557299754796005_8, -0.82342412550090412964986631390412834_8, kind=8))
|
134 |
|
|
! Numerically: 0.83774433133636226305479129936568267 + I*0.43874835208710654149508159123595167
|
135 |
|
|
call check(atan(z4), cmplx(0.83774433133636226305479129936568267_4, 0.43874835208710654149508159123595167_4, kind=4))
|
136 |
|
|
call check(atan(z8), cmplx(0.83774433133636226305479129936568267_8, 0.43874835208710654149508159123595167_8, kind=8))
|
137 |
|
|
! Numerically: 0.82342412550090412964986631390412834 + I*0.59507386031622633330574869409179139
|
138 |
|
|
call check(asinh(z4), cmplx(0.82342412550090412964986631390412834_4, 0.59507386031622633330574869409179139_4, kind=4))
|
139 |
|
|
call check(asinh(z8), cmplx(0.82342412550090412964986631390412834_8, 0.59507386031622633330574869409179139_8, kind=8))
|
140 |
|
|
! Numerically: 0.82342412550090412964986631390412834 + I*0.97572246647867028592557299754796005
|
141 |
|
|
call check(acosh(z4), cmplx(0.82342412550090412964986631390412834_4, 0.97572246647867028592557299754796005_4, kind=4))
|
142 |
|
|
call check(acosh(z8), cmplx(0.82342412550090412964986631390412834_8, 0.97572246647867028592557299754796005_8, kind=8))
|
143 |
|
|
! Numerically: 0.43874835208710654149508159123595167 + I*0.83774433133636226305479129936568267
|
144 |
|
|
call check(atanh(z4), cmplx(0.43874835208710654149508159123595167_4, 0.83774433133636226305479129936568267_4, kind=4))
|
145 |
|
|
call check(atanh(z8), cmplx(0.43874835208710654149508159123595167_8, 0.83774433133636226305479129936568267_8, kind=8))
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
! z = 1+I
|
149 |
|
|
z4 = cmplx(1.0_4, 1.0_4, kind=4)
|
150 |
|
|
z8 = cmplx(1.0_8, 1.0_8, kind=8)
|
151 |
|
|
|
152 |
|
|
! Numerically: 0.66623943249251525510400489597779272 + I*1.06127506190503565203301891621357349
|
153 |
|
|
call check(asin(z4), cmplx(0.66623943249251525510400489597779272_4, 1.06127506190503565203301891621357349_4, kind=4))
|
154 |
|
|
call check(asin(z8), cmplx(0.66623943249251525510400489597779272_8, 1.06127506190503565203301891621357349_8, kind=8))
|
155 |
|
|
! Numerically: 0.90455689430238136412731679566195872 - I*1.06127506190503565203301891621357349
|
156 |
|
|
call check(acos(z4), cmplx(0.90455689430238136412731679566195872_4, -1.06127506190503565203301891621357349_4, kind=4))
|
157 |
|
|
call check(acos(z8), cmplx(0.90455689430238136412731679566195872_8, -1.06127506190503565203301891621357349_8, kind=8))
|
158 |
|
|
! Numerically: 1.01722196789785136772278896155048292 + I*0.40235947810852509365018983330654691
|
159 |
|
|
call check(atan(z4), cmplx(1.01722196789785136772278896155048292_4, 0.40235947810852509365018983330654691_4, kind=4))
|
160 |
|
|
call check(atan(z8), cmplx(1.01722196789785136772278896155048292_8, 0.40235947810852509365018983330654691_8, kind=8))
|
161 |
|
|
! Numerically: 1.06127506190503565203301891621357349 + I*0.66623943249251525510400489597779272
|
162 |
|
|
call check(asinh(z4), cmplx(1.06127506190503565203301891621357349_4, 0.66623943249251525510400489597779272_4, kind=4))
|
163 |
|
|
call check(asinh(z8), cmplx(1.06127506190503565203301891621357349_8, 0.66623943249251525510400489597779272_8, kind=8))
|
164 |
|
|
! Numerically: 1.06127506190503565203301891621357349 + I*0.90455689430238136412731679566195872
|
165 |
|
|
call check(acosh(z4), cmplx(1.06127506190503565203301891621357349_4, 0.90455689430238136412731679566195872_4, kind=4))
|
166 |
|
|
call check(acosh(z8), cmplx(1.06127506190503565203301891621357349_8, 0.90455689430238136412731679566195872_8, kind=8))
|
167 |
|
|
! Numerically: 0.40235947810852509365018983330654691 + I*1.01722196789785136772278896155048292
|
168 |
|
|
call check(atanh(z4), cmplx(0.40235947810852509365018983330654691_4, 1.01722196789785136772278896155048292_4, kind=4))
|
169 |
|
|
call check(atanh(z8), cmplx(0.40235947810852509365018983330654691_8, 1.01722196789785136772278896155048292_8, kind=8))
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
! z = (1+I)*1.1
|
173 |
|
|
z4 = cmplx(1.1_4, 1.1_4, kind=4)
|
174 |
|
|
z8 = cmplx(1.1_8, 1.1_8, kind=8)
|
175 |
|
|
|
176 |
|
|
! Numerically: 0.68549840630267734494444454677951503 + I*1.15012680127435581678415521738176733
|
177 |
|
|
call check(asin(z4), cmplx(0.68549840630267734494444454677951503_4, 1.15012680127435581678415521738176733_4, kind=4))
|
178 |
|
|
call check(asin(z8), cmplx(0.68549840630267734494444454677951503_8, 1.15012680127435581678415521738176733_8, kind=8))
|
179 |
|
|
! Numerically: 0.8852979204922192742868771448602364 - I*1.1501268012743558167841552173817673
|
180 |
|
|
call check(acos(z4), cmplx(0.8852979204922192742868771448602364_4, -1.1501268012743558167841552173817673_4, kind=4))
|
181 |
|
|
call check(acos(z8), cmplx(0.8852979204922192742868771448602364_8, -1.1501268012743558167841552173817673_8, kind=8))
|
182 |
|
|
! Numerically: 1.07198475450905931839240655913126728 + I*0.38187020129010862908881230531688930
|
183 |
|
|
call check(atan(z4), cmplx(1.07198475450905931839240655913126728_4, 0.38187020129010862908881230531688930_4, kind=4))
|
184 |
|
|
call check(atan(z8), cmplx(1.07198475450905931839240655913126728_8, 0.38187020129010862908881230531688930_8, kind=8))
|
185 |
|
|
! Numerically: 1.15012680127435581678415521738176733 + I*0.68549840630267734494444454677951503
|
186 |
|
|
call check(asinh(z4), cmplx(1.15012680127435581678415521738176733_4, 0.68549840630267734494444454677951503_4, kind=4))
|
187 |
|
|
call check(asinh(z8), cmplx(1.15012680127435581678415521738176733_8, 0.68549840630267734494444454677951503_8, kind=8))
|
188 |
|
|
! Numerically: 1.1501268012743558167841552173817673 + I*0.8852979204922192742868771448602364
|
189 |
|
|
call check(acosh(z4), cmplx(1.1501268012743558167841552173817673_4, 0.8852979204922192742868771448602364_4, kind=4))
|
190 |
|
|
call check(acosh(z8), cmplx(1.1501268012743558167841552173817673_8, 0.8852979204922192742868771448602364_8, kind=8))
|
191 |
|
|
! Numerically: 0.38187020129010862908881230531688930 + I*1.07198475450905931839240655913126728
|
192 |
|
|
call check(atanh(z4), cmplx(0.38187020129010862908881230531688930_4, 1.07198475450905931839240655913126728_4, kind=4))
|
193 |
|
|
call check(atanh(z8), cmplx(0.38187020129010862908881230531688930_8, 1.07198475450905931839240655913126728_8, kind=8))
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
!!!!! Negative NUMBERS !!!!!!
|
197 |
|
|
! z = -(1+I)*1.1
|
198 |
|
|
z4 = cmplx(-1.1_4, -1.1_4, kind=4)
|
199 |
|
|
z8 = cmplx(-1.1_8, -1.1_8, kind=8)
|
200 |
|
|
|
201 |
|
|
! Numerically: -0.68549840630267734494444454677951503 - I*1.15012680127435581678415521738176733
|
202 |
|
|
call check(asin(z4), cmplx(-0.68549840630267734494444454677951503_4, -1.15012680127435581678415521738176733_4, kind=4))
|
203 |
|
|
call check(asin(z8), cmplx(-0.68549840630267734494444454677951503_8, -1.15012680127435581678415521738176733_8, kind=8))
|
204 |
|
|
! Numerically: 2.2562947330975739641757662384192665 + I*1.1501268012743558167841552173817673
|
205 |
|
|
call check(acos(z4), cmplx(2.2562947330975739641757662384192665_4, 1.1501268012743558167841552173817673_4, kind=4))
|
206 |
|
|
call check(acos(z8), cmplx(2.2562947330975739641757662384192665_8, 1.1501268012743558167841552173817673_8, kind=8))
|
207 |
|
|
! Numerically: -1.07198475450905931839240655913126728 - I*0.38187020129010862908881230531688930
|
208 |
|
|
call check(atan(z4), cmplx(-1.07198475450905931839240655913126728_4, -0.38187020129010862908881230531688930_4, kind=4))
|
209 |
|
|
call check(atan(z8), cmplx(-1.07198475450905931839240655913126728_8, -0.38187020129010862908881230531688930_8, kind=8))
|
210 |
|
|
! Numerically: -1.15012680127435581678415521738176733 - I*0.68549840630267734494444454677951503
|
211 |
|
|
call check(asinh(z4), cmplx(-1.15012680127435581678415521738176733_4, -0.68549840630267734494444454677951503_4, kind=4))
|
212 |
|
|
call check(asinh(z8), cmplx(-1.15012680127435581678415521738176733_8, -0.68549840630267734494444454677951503_8, kind=8))
|
213 |
|
|
! Numerically: 1.1501268012743558167841552173817673 - I*2.2562947330975739641757662384192665
|
214 |
|
|
call check(acosh(z4), cmplx(1.1501268012743558167841552173817673_4, -2.2562947330975739641757662384192665_4, kind=4))
|
215 |
|
|
call check(acosh(z8), cmplx(1.1501268012743558167841552173817673_8, -2.2562947330975739641757662384192665_8, kind=8))
|
216 |
|
|
! Numerically: 0.38187020129010862908881230531688930 + I*1.07198475450905931839240655913126728
|
217 |
|
|
call check(atanh(z4), cmplx(-0.38187020129010862908881230531688930_4, -1.07198475450905931839240655913126728_4, kind=4))
|
218 |
|
|
call check(atanh(z8), cmplx(-0.38187020129010862908881230531688930_8, -1.07198475450905931839240655913126728_8, kind=8))
|
219 |
|
|
END PROGRAM ArcTrigHyp
|
220 |
|
|
|
221 |
|
|
! { dg-final { cleanup-modules "test" } }
|