LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
test_zcomplexmult.f
Go to the documentation of this file.
1*> \brief zmul tests the robustness and precision of the double complex multiplication
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8* Authors:
9* ========
10*
11*> \author Weslley S. Pereira, University of Colorado Denver, U.S.
12*
13*> \verbatim
14*>
15*> Tests:
16*>
17*> (a) Inf inputs:
18*> (1) y = ( Inf + 0 * I)
19*> (2) y = (-Inf + 0 * I)
20*> (3) y = ( 0 + Inf * I)
21*> (4) y = ( 0 - Inf * I)
22*> (5) y = ( Inf + Inf * I)
23*> Tests:
24*> (a) 0 * y is NaN.
25*> (b) 1 * y is y is either y or NaN.
26*> (c) y * y is either Inf or NaN (cases 1 and 3),
27*> either -Inf or NaN (cases 2 and 4),
28*> NaN (case 5).
29*>
30*> (b) NaN inputs:
31*> (1) y = (NaN + 0 * I)
32*> (2) y = (0 + NaN * I)
33*> (3) y = (NaN + NaN * I)
34*> Tests:
35*> (a) 0 * y is NaN.
36*> (b) 1 * y is NaN.
37*> (c) y * y is NaN.
38*>
39*> \endverbatim
40*
41*> \ingroup auxOTHERauxiliary
42*
43* =====================================================================
44 program zmul
45*
46* -- LAPACK test routine --
47* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
48
49* ..
50* .. Constants ..
51 integer nnan, ninf
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 ) )
56* ..
57* .. Local Variables ..
58 integer i, nfailingtests, ntests
59 double precision ainf, anan, ov
60 double complex y, r, cinf( ninf ), cnan( nnan )
61*
62* .. Intrinsic Functions ..
63 intrinsic huge, dcmplx
64
65*
66* .. Initialize error counts ..
67 nfailingtests = 0
68 ntests = 0
69*
70* .. Inf entries ..
71 ov = huge(0.0d0)
72 ainf = ov * 2
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 )
78*
79* .. NaN entries ..
80 anan = ainf / ainf
81 cnan(1) = dcmplx( anan, 0.0d0 )
82 cnan(2) = dcmplx( 0.0d0, anan )
83 cnan(3) = dcmplx( anan, anan )
84
85*
86* .. Tests ..
87*
88* Test (a) Infs
89 do 10 i = 1, ninf
90 ntests = ntests + 3
91 y = cinf(i)
92 r = czero * y
93 if( r .eq. r ) then
94 nfailingtests = nfailingtests + 1
95 WRITE( *, fmt = 9998 ) 'ia',i, czero, y, r, 'NaN'
96 endif
97 r = cone * y
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'
102 endif
103 r = y * y
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'
108 endif
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'
113 endif
114 else
115 if( r .eq. r ) then
116 nfailingtests = nfailingtests + 1
117 WRITE( *, fmt = 9998 ) 'ic',i, y, y, r, 'NaN'
118 endif
119 endif
120 10 continue
121*
122* Test (b) NaNs
123 do 20 i = 1, nnan
124 ntests = ntests + 3
125 y = cnan(i)
126 r = czero * y
127 if( r .eq. r ) then
128 nfailingtests = nfailingtests + 1
129 WRITE( *, fmt = 9998 ) 'na',i, czero, y, r, 'NaN'
130 endif
131 r = cone * y
132 if( r .eq. r ) then
133 nfailingtests = nfailingtests + 1
134 WRITE( *, fmt = 9998 ) 'nb',i, cone, y, r, 'NaN'
135 endif
136 r = y * y
137 if( r .eq. r ) then
138 nfailingtests = nfailingtests + 1
139 WRITE( *, fmt = 9998 ) 'nc',i, y, y, r, 'NaN'
140 endif
141 20 continue
142*
143 if( nfailingtests .gt. 0 ) then
144 print *, "# ", ntests-nfailingtests, " tests out of ", ntests,
145 $ " pass for complex multiplication,", nfailingtests," fail."
146 else
147 print *, "# All tests pass for complex multiplication."
148 endif
149*
150* .. Formats ..
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 )
154*
155* End of zmul
156*
157 END
program zmul
zmul tests the robustness and precision of the double complex multiplication