LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
zchkgk.f
Go to the documentation of this file.
1 *> \brief \b ZCHKGK
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE ZCHKGK( NIN, NOUT )
12 *
13 * .. Scalar Arguments ..
14 * INTEGER NIN, NOUT
15 * ..
16 *
17 *
18 *> \par Purpose:
19 * =============
20 *>
21 *> \verbatim
22 *>
23 *> ZCHKGK tests ZGGBAK, a routine for backward balancing of
24 *> a matrix pair (A, B).
25 *> \endverbatim
26 *
27 * Arguments:
28 * ==========
29 *
30 *> \param[in] NIN
31 *> \verbatim
32 *> NIN is INTEGER
33 *> The logical unit number for input. NIN > 0.
34 *> \endverbatim
35 *>
36 *> \param[in] NOUT
37 *> \verbatim
38 *> NOUT is INTEGER
39 *> The logical unit number for output. NOUT > 0.
40 *> \endverbatim
41 *
42 * Authors:
43 * ========
44 *
45 *> \author Univ. of Tennessee
46 *> \author Univ. of California Berkeley
47 *> \author Univ. of Colorado Denver
48 *> \author NAG Ltd.
49 *
50 *> \date November 2011
51 *
52 *> \ingroup complex16_eig
53 *
54 * =====================================================================
55  SUBROUTINE zchkgk( NIN, NOUT )
56 *
57 * -- LAPACK test routine (version 3.4.0) --
58 * -- LAPACK is a software package provided by Univ. of Tennessee, --
59 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
60 * November 2011
61 *
62 * .. Scalar Arguments ..
63  INTEGER nin, nout
64 * ..
65 *
66 * =====================================================================
67 *
68 * .. Parameters ..
69  INTEGER lda, ldb, ldvl, ldvr
70  parameter( lda = 50, ldb = 50, ldvl = 50, ldvr = 50 )
71  INTEGER lde, ldf, ldwork, lrwork
72  parameter( lde = 50, ldf = 50, ldwork = 50,
73  $ lrwork = 6*50 )
74  DOUBLE PRECISION zero
75  parameter( zero = 0.0d+0 )
76  COMPLEX*16 czero, cone
77  parameter( czero = ( 0.0d+0, 0.0d+0 ),
78  $ cone = ( 1.0d+0, 0.0d+0 ) )
79 * ..
80 * .. Local Scalars ..
81  INTEGER i, ihi, ilo, info, j, knt, m, n, ninfo
82  DOUBLE PRECISION anorm, bnorm, eps, rmax, vmax
83  COMPLEX*16 cdum
84 * ..
85 * .. Local Arrays ..
86  INTEGER lmax( 4 )
87  DOUBLE PRECISION lscale( lda ), rscale( lda ), rwork( lrwork )
88  COMPLEX*16 a( lda, lda ), af( lda, lda ), b( ldb, ldb ),
89  $ bf( ldb, ldb ), e( lde, lde ), f( ldf, ldf ),
90  $ vl( ldvl, ldvl ), vlf( ldvl, ldvl ),
91  $ vr( ldvr, ldvr ), vrf( ldvr, ldvr ),
92  $ work( ldwork, ldwork )
93 * ..
94 * .. External Functions ..
95  DOUBLE PRECISION dlamch, zlange
96  EXTERNAL dlamch, zlange
97 * ..
98 * .. External Subroutines ..
99  EXTERNAL zgemm, zggbak, zggbal, zlacpy
100 * ..
101 * .. Intrinsic Functions ..
102  INTRINSIC abs, dble, dimag, max
103 * ..
104 * .. Statement Functions ..
105  DOUBLE PRECISION cabs1
106 * ..
107 * .. Statement Function definitions ..
108  cabs1( cdum ) = abs( dble( cdum ) ) + abs( dimag( cdum ) )
109 * ..
110 * .. Executable Statements ..
111 *
112  lmax( 1 ) = 0
113  lmax( 2 ) = 0
114  lmax( 3 ) = 0
115  lmax( 4 ) = 0
116  ninfo = 0
117  knt = 0
118  rmax = zero
119 *
120  eps = dlamch( 'Precision' )
121 *
122  10 continue
123  READ( nin, fmt = * )n, m
124  IF( n.EQ.0 )
125  $ go to 100
126 *
127  DO 20 i = 1, n
128  READ( nin, fmt = * )( a( i, j ), j = 1, n )
129  20 continue
130 *
131  DO 30 i = 1, n
132  READ( nin, fmt = * )( b( i, j ), j = 1, n )
133  30 continue
134 *
135  DO 40 i = 1, n
136  READ( nin, fmt = * )( vl( i, j ), j = 1, m )
137  40 continue
138 *
139  DO 50 i = 1, n
140  READ( nin, fmt = * )( vr( i, j ), j = 1, m )
141  50 continue
142 *
143  knt = knt + 1
144 *
145  anorm = zlange( 'M', n, n, a, lda, rwork )
146  bnorm = zlange( 'M', n, n, b, ldb, rwork )
147 *
148  CALL zlacpy( 'FULL', n, n, a, lda, af, lda )
149  CALL zlacpy( 'FULL', n, n, b, ldb, bf, ldb )
150 *
151  CALL zggbal( 'B', n, a, lda, b, ldb, ilo, ihi, lscale, rscale,
152  $ rwork, info )
153  IF( info.NE.0 ) THEN
154  ninfo = ninfo + 1
155  lmax( 1 ) = knt
156  END IF
157 *
158  CALL zlacpy( 'FULL', n, m, vl, ldvl, vlf, ldvl )
159  CALL zlacpy( 'FULL', n, m, vr, ldvr, vrf, ldvr )
160 *
161  CALL zggbak( 'B', 'L', n, ilo, ihi, lscale, rscale, m, vl, ldvl,
162  $ info )
163  IF( info.NE.0 ) THEN
164  ninfo = ninfo + 1
165  lmax( 2 ) = knt
166  END IF
167 *
168  CALL zggbak( 'B', 'R', n, ilo, ihi, lscale, rscale, m, vr, ldvr,
169  $ info )
170  IF( info.NE.0 ) THEN
171  ninfo = ninfo + 1
172  lmax( 3 ) = knt
173  END IF
174 *
175 * Test of ZGGBAK
176 *
177 * Check tilde(VL)'*A*tilde(VR) - VL'*tilde(A)*VR
178 * where tilde(A) denotes the transformed matrix.
179 *
180  CALL zgemm( 'N', 'N', n, m, n, cone, af, lda, vr, ldvr, czero,
181  $ work, ldwork )
182  CALL zgemm( 'C', 'N', m, m, n, cone, vl, ldvl, work, ldwork,
183  $ czero, e, lde )
184 *
185  CALL zgemm( 'N', 'N', n, m, n, cone, a, lda, vrf, ldvr, czero,
186  $ work, ldwork )
187  CALL zgemm( 'C', 'N', m, m, n, cone, vlf, ldvl, work, ldwork,
188  $ czero, f, ldf )
189 *
190  vmax = zero
191  DO 70 j = 1, m
192  DO 60 i = 1, m
193  vmax = max( vmax, cabs1( e( i, j )-f( i, j ) ) )
194  60 continue
195  70 continue
196  vmax = vmax / ( eps*max( anorm, bnorm ) )
197  IF( vmax.GT.rmax ) THEN
198  lmax( 4 ) = knt
199  rmax = vmax
200  END IF
201 *
202 * Check tilde(VL)'*B*tilde(VR) - VL'*tilde(B)*VR
203 *
204  CALL zgemm( 'N', 'N', n, m, n, cone, bf, ldb, vr, ldvr, czero,
205  $ work, ldwork )
206  CALL zgemm( 'C', 'N', m, m, n, cone, vl, ldvl, work, ldwork,
207  $ czero, e, lde )
208 *
209  CALL zgemm( 'n', 'n', n, m, n, cone, b, ldb, vrf, ldvr, czero,
210  $ work, ldwork )
211  CALL zgemm( 'C', 'N', m, m, n, cone, vlf, ldvl, work, ldwork,
212  $ czero, f, ldf )
213 *
214  vmax = zero
215  DO 90 j = 1, m
216  DO 80 i = 1, m
217  vmax = max( vmax, cabs1( e( i, j )-f( i, j ) ) )
218  80 continue
219  90 continue
220  vmax = vmax / ( eps*max( anorm, bnorm ) )
221  IF( vmax.GT.rmax ) THEN
222  lmax( 4 ) = knt
223  rmax = vmax
224  END IF
225 *
226  go to 10
227 *
228  100 continue
229 *
230  WRITE( nout, fmt = 9999 )
231  9999 format( 1x, '.. test output of ZGGBAK .. ' )
232 *
233  WRITE( nout, fmt = 9998 )rmax
234  9998 format( ' value of largest test error =', d12.3 )
235  WRITE( nout, fmt = 9997 )lmax( 1 )
236  9997 format( ' example number where ZGGBAL info is not 0 =', i4 )
237  WRITE( nout, fmt = 9996 )lmax( 2 )
238  9996 format( ' example number where ZGGBAK(L) info is not 0 =', i4 )
239  WRITE( nout, fmt = 9995 )lmax( 3 )
240  9995 format( ' example number where ZGGBAK(R) info is not 0 =', i4 )
241  WRITE( nout, fmt = 9994 )lmax( 4 )
242  9994 format( ' example number having largest error =', i4 )
243  WRITE( nout, fmt = 9992 )ninfo
244  9992 format( ' number of examples where info is not 0 =', i4 )
245  WRITE( nout, fmt = 9991 )knt
246  9991 format( ' total number of examples tested =', i4 )
247 *
248  return
249 *
250 * End of ZCHKGK
251 *
252  END