LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
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
subroutine zlacpy(UPLO, M, N, A, LDA, B, LDB)
ZLACPY copies all or part of one two-dimensional array to another.
Definition: zlacpy.f:105
subroutine zchkgk(NIN, NOUT)
ZCHKGK
Definition: zchkgk.f:56
subroutine zgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
ZGEMM
Definition: zgemm.f:189
subroutine zggbak(JOB, SIDE, N, ILO, IHI, LSCALE, RSCALE, M, V, LDV, INFO)
ZGGBAK
Definition: zggbak.f:150
subroutine zggbal(JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE, WORK, INFO)
ZGGBAL
Definition: zggbal.f:179