52 parameter( nnan = 3, ninf = 5 )
53 double complex czero, cone
54 parameter( czero = dcmplx( 0.0d0, 0.0d0 ),
55 $ cone = dcmplx( 1.0d0, 0.0d0 ) )
58 integer i, nfailingtests, ntests
59 double precision ainf, anan, ov
60 double complex y, r, cinf( ninf ), cnan( nnan )
63 intrinsic huge, dcmplx
73 cinf(1) = dcmplx( ainf, 0.0d0 )
74 cinf(2) = dcmplx(-ainf, 0.0d0 )
75 cinf(3) = dcmplx( 0.0d0, ainf )
76 cinf(4) = dcmplx( 0.0d0,-ainf )
77 cinf(5) = dcmplx( ainf, ainf )
81 cnan(1) = dcmplx( anan, 0.0d0 )
82 cnan(2) = dcmplx( 0.0d0, anan )
83 cnan(3) = dcmplx( anan, anan )
94 nfailingtests = nfailingtests + 1
95 WRITE( *, fmt = 9998 )
'ia',i, czero, y, r,
'NaN'
98 if( (r .ne. y) .and. (r .eq. r) )
then
99 nfailingtests = nfailingtests + 1
100 WRITE( *, fmt = 9998 )
'ib',i, cone, y, r,
101 $
'the input and NaN'
104 if( (i.eq.1) .or. (i.eq.2) )
then
105 if( (r .ne. cinf(1)) .and. (r .eq. r) )
then
106 nfailingtests = nfailingtests + 1
107 WRITE( *, fmt = 9998 )
'ic',i, y, y, r,
'Inf and NaN'
109 else if( (i.eq.3) .or. (i.eq.4) )
then
110 if( (r .ne. cinf(2)) .and. (r .eq. r) )
then
111 nfailingtests = nfailingtests + 1
112 WRITE( *, fmt = 9998 )
'ic',i, y, y, r,
'-Inf and NaN'
116 nfailingtests = nfailingtests + 1
117 WRITE( *, fmt = 9998 )
'ic',i, y, y, r,
'NaN'
128 nfailingtests = nfailingtests + 1
129 WRITE( *, fmt = 9998 )
'na',i, czero, y, r,
'NaN'
133 nfailingtests = nfailingtests + 1
134 WRITE( *, fmt = 9998 )
'nb',i, cone, y, r,
'NaN'
138 nfailingtests = nfailingtests + 1
139 WRITE( *, fmt = 9998 )
'nc',i, y, y, r,
'NaN'
143 if( nfailingtests .gt. 0 )
then
144 print *,
"# ", ntests-nfailingtests,
" tests out of ", ntests,
145 $
" pass for complex multiplication,", nfailingtests,
" fail."
147 print *,
"# All tests pass for complex multiplication."
151 9998
FORMAT(
'[',a2,i1,
'] (', (es24.16e3,sp,es24.16e3,
"*I"),
') * (',
152 $ (es24.16e3,sp,es24.16e3,
"*I"),
') = (',
153 $ (es24.16e3,sp,es24.16e3,
"*I"),
') differs from ', a17 )
program zmul
zmul tests the robustness and precision of the double complex multiplication