LAPACK  3.11.0
LAPACK: Linear Algebra PACKage
test_zcomplexmult.f
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
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 * .. Inf entries ..
67  ov = huge(0.0d0)
68  ainf = ov * 2
69  cinf(1) = dcmplx( ainf, 0.0d0 )
70  cinf(2) = dcmplx(-ainf, 0.0d0 )
71  cinf(3) = dcmplx( 0.0d0, ainf )
72  cinf(4) = dcmplx( 0.0d0,-ainf )
73  cinf(5) = dcmplx( ainf, ainf )
74 *
75 * .. NaN entries ..
76  anan = ainf / ainf
77  cnan(1) = dcmplx( anan, 0.0d0 )
78  cnan(2) = dcmplx( 0.0d0, anan )
79  cnan(3) = dcmplx( anan, anan )
80 
81 *
82 * .. Tests ..
83 *
84 * Test (a) Infs
85  do 10 i = 1, ninf
86  y = cinf(i)
87  r = czero * y
88  if( r .eq. r ) then
89  WRITE( *, fmt = 9998 ) 'ia',i, czero, y, r, 'NaN'
90  endif
91  r = cone * y
92  if( (r .ne. y) .and. (r .eq. r) ) then
93  WRITE( *, fmt = 9998 ) 'ib',i, cone, y, r,
94  $ 'the input and NaN'
95  endif
96  r = y * y
97  if( (i.eq.1) .or. (i.eq.2) ) then
98  if( (r .ne. cinf(1)) .and. (r .eq. r) ) then
99  WRITE( *, fmt = 9998 ) 'ic',i, y, y, r, 'Inf and NaN'
100  endif
101  else if( (i.eq.3) .or. (i.eq.4) ) then
102  if( (r .ne. cinf(2)) .and. (r .eq. r) ) then
103  WRITE( *, fmt = 9998 ) 'ic',i, y, y, r, '-Inf and NaN'
104  endif
105  else
106  if( r .eq. r ) then
107  WRITE( *, fmt = 9998 ) 'ic',i, y, y, r, 'NaN'
108  endif
109  endif
110  10 continue
111 *
112 * Test (b) NaNs
113  do 20 i = 1, nnan
114  y = cnan(i)
115  r = czero * y
116  if( r .eq. r ) then
117  WRITE( *, fmt = 9998 ) 'na',i, czero, y, r, 'NaN'
118  endif
119  r = cone * y
120  if( r .eq. r ) then
121  WRITE( *, fmt = 9998 ) 'nb',i, cone, y, r, 'NaN'
122  endif
123  r = y * y
124  if( r .eq. r ) then
125  WRITE( *, fmt = 9998 ) 'nc',i, y, y, r, 'NaN'
126  endif
127  20 continue
128 *
129 * .. Formats ..
130  9998 FORMAT( '[',a2,i1, '] (', (es24.16e3,sp,es24.16e3,"*I"), ') * (',
131  $ (es24.16e3,sp,es24.16e3,"*I"), ') = (',
132  $ (es24.16e3,sp,es24.16e3,"*I"), ') differs from ', a17 )
133 *
134 * End of zmul
135 *
136  END