LAPACK  3.4.2 LAPACK: Linear Algebra PACKage
zgegs.f
Go to the documentation of this file.
1 *> \brief <b> ZGEEVX computes the eigenvalues and, optionally, the left and/or right eigenvectors for GE matrices</b>
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 *> \htmlonly
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zgegs.f">
11 *> [TGZ]</a>
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zgegs.f">
13 *> [ZIP]</a>
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zgegs.f">
15 *> [TXT]</a>
16 *> \endhtmlonly
17 *
18 * Definition:
19 * ===========
20 *
21 * SUBROUTINE ZGEGS( JOBVSL, JOBVSR, N, A, LDA, B, LDB, ALPHA, BETA,
22 * VSL, LDVSL, VSR, LDVSR, WORK, LWORK, RWORK,
23 * INFO )
24 *
25 * .. Scalar Arguments ..
26 * CHARACTER JOBVSL, JOBVSR
27 * INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N
28 * ..
29 * .. Array Arguments ..
30 * DOUBLE PRECISION RWORK( * )
31 * COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),
32 * \$ BETA( * ), VSL( LDVSL, * ), VSR( LDVSR, * ),
33 * \$ WORK( * )
34 * ..
35 *
36 *
37 *> \par Purpose:
38 * =============
39 *>
40 *> \verbatim
41 *>
42 *> This routine is deprecated and has been replaced by routine ZGGES.
43 *>
44 *> ZGEGS computes the eigenvalues, Schur form, and, optionally, the
45 *> left and or/right Schur vectors of a complex matrix pair (A,B).
46 *> Given two square matrices A and B, the generalized Schur
47 *> factorization has the form
48 *>
49 *> A = Q*S*Z**H, B = Q*T*Z**H
50 *>
51 *> where Q and Z are unitary matrices and S and T are upper triangular.
52 *> The columns of Q are the left Schur vectors
53 *> and the columns of Z are the right Schur vectors.
54 *>
55 *> If only the eigenvalues of (A,B) are needed, the driver routine
56 *> ZGEGV should be used instead. See ZGEGV for a description of the
57 *> eigenvalues of the generalized nonsymmetric eigenvalue problem
58 *> (GNEP).
59 *> \endverbatim
60 *
61 * Arguments:
62 * ==========
63 *
64 *> \param[in] JOBVSL
65 *> \verbatim
66 *> JOBVSL is CHARACTER*1
67 *> = 'N': do not compute the left Schur vectors;
68 *> = 'V': compute the left Schur vectors (returned in VSL).
69 *> \endverbatim
70 *>
71 *> \param[in] JOBVSR
72 *> \verbatim
73 *> JOBVSR is CHARACTER*1
74 *> = 'N': do not compute the right Schur vectors;
75 *> = 'V': compute the right Schur vectors (returned in VSR).
76 *> \endverbatim
77 *>
78 *> \param[in] N
79 *> \verbatim
80 *> N is INTEGER
81 *> The order of the matrices A, B, VSL, and VSR. N >= 0.
82 *> \endverbatim
83 *>
84 *> \param[in,out] A
85 *> \verbatim
86 *> A is COMPLEX*16 array, dimension (LDA, N)
87 *> On entry, the matrix A.
88 *> On exit, the upper triangular matrix S from the generalized
89 *> Schur factorization.
90 *> \endverbatim
91 *>
92 *> \param[in] LDA
93 *> \verbatim
94 *> LDA is INTEGER
95 *> The leading dimension of A. LDA >= max(1,N).
96 *> \endverbatim
97 *>
98 *> \param[in,out] B
99 *> \verbatim
100 *> B is COMPLEX*16 array, dimension (LDB, N)
101 *> On entry, the matrix B.
102 *> On exit, the upper triangular matrix T from the generalized
103 *> Schur factorization.
104 *> \endverbatim
105 *>
106 *> \param[in] LDB
107 *> \verbatim
108 *> LDB is INTEGER
109 *> The leading dimension of B. LDB >= max(1,N).
110 *> \endverbatim
111 *>
112 *> \param[out] ALPHA
113 *> \verbatim
114 *> ALPHA is COMPLEX*16 array, dimension (N)
115 *> The complex scalars alpha that define the eigenvalues of
116 *> GNEP. ALPHA(j) = S(j,j), the diagonal element of the Schur
117 *> form of A.
118 *> \endverbatim
119 *>
120 *> \param[out] BETA
121 *> \verbatim
122 *> BETA is COMPLEX*16 array, dimension (N)
123 *> The non-negative real scalars beta that define the
124 *> eigenvalues of GNEP. BETA(j) = T(j,j), the diagonal element
125 *> of the triangular factor T.
126 *>
127 *> Together, the quantities alpha = ALPHA(j) and beta = BETA(j)
128 *> represent the j-th eigenvalue of the matrix pair (A,B), in
129 *> one of the forms lambda = alpha/beta or mu = beta/alpha.
130 *> Since either lambda or mu may overflow, they should not,
131 *> in general, be computed.
132 *> \endverbatim
133 *>
134 *> \param[out] VSL
135 *> \verbatim
136 *> VSL is COMPLEX*16 array, dimension (LDVSL,N)
137 *> If JOBVSL = 'V', the matrix of left Schur vectors Q.
138 *> Not referenced if JOBVSL = 'N'.
139 *> \endverbatim
140 *>
141 *> \param[in] LDVSL
142 *> \verbatim
143 *> LDVSL is INTEGER
144 *> The leading dimension of the matrix VSL. LDVSL >= 1, and
145 *> if JOBVSL = 'V', LDVSL >= N.
146 *> \endverbatim
147 *>
148 *> \param[out] VSR
149 *> \verbatim
150 *> VSR is COMPLEX*16 array, dimension (LDVSR,N)
151 *> If JOBVSR = 'V', the matrix of right Schur vectors Z.
152 *> Not referenced if JOBVSR = 'N'.
153 *> \endverbatim
154 *>
155 *> \param[in] LDVSR
156 *> \verbatim
157 *> LDVSR is INTEGER
158 *> The leading dimension of the matrix VSR. LDVSR >= 1, and
159 *> if JOBVSR = 'V', LDVSR >= N.
160 *> \endverbatim
161 *>
162 *> \param[out] WORK
163 *> \verbatim
164 *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
165 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
166 *> \endverbatim
167 *>
168 *> \param[in] LWORK
169 *> \verbatim
170 *> LWORK is INTEGER
171 *> The dimension of the array WORK. LWORK >= max(1,2*N).
172 *> For good performance, LWORK must generally be larger.
173 *> To compute the optimal value of LWORK, call ILAENV to get
174 *> blocksizes (for ZGEQRF, ZUNMQR, and CUNGQR.) Then compute:
175 *> NB -- MAX of the blocksizes for ZGEQRF, ZUNMQR, and CUNGQR;
176 *> the optimal LWORK is N*(NB+1).
177 *>
178 *> If LWORK = -1, then a workspace query is assumed; the routine
179 *> only calculates the optimal size of the WORK array, returns
180 *> this value as the first entry of the WORK array, and no error
181 *> message related to LWORK is issued by XERBLA.
182 *> \endverbatim
183 *>
184 *> \param[out] RWORK
185 *> \verbatim
186 *> RWORK is DOUBLE PRECISION array, dimension (3*N)
187 *> \endverbatim
188 *>
189 *> \param[out] INFO
190 *> \verbatim
191 *> INFO is INTEGER
192 *> = 0: successful exit
193 *> < 0: if INFO = -i, the i-th argument had an illegal value.
194 *> =1,...,N:
195 *> The QZ iteration failed. (A,B) are not in Schur
196 *> form, but ALPHA(j) and BETA(j) should be correct for
197 *> j=INFO+1,...,N.
198 *> > N: errors that usually indicate LAPACK problems:
199 *> =N+1: error return from ZGGBAL
200 *> =N+2: error return from ZGEQRF
201 *> =N+3: error return from ZUNMQR
202 *> =N+4: error return from ZUNGQR
203 *> =N+5: error return from ZGGHRD
204 *> =N+6: error return from ZHGEQZ (other than failed
205 *> iteration)
206 *> =N+7: error return from ZGGBAK (computing VSL)
207 *> =N+8: error return from ZGGBAK (computing VSR)
208 *> =N+9: error return from ZLASCL (various places)
209 *> \endverbatim
210 *
211 * Authors:
212 * ========
213 *
214 *> \author Univ. of Tennessee
215 *> \author Univ. of California Berkeley
216 *> \author Univ. of Colorado Denver
217 *> \author NAG Ltd.
218 *
219 *> \date November 2011
220 *
221 *> \ingroup complex16GEeigen
222 *
223 * =====================================================================
224  SUBROUTINE zgegs( JOBVSL, JOBVSR, N, A, LDA, B, LDB, ALPHA, BETA,
225  \$ vsl, ldvsl, vsr, ldvsr, work, lwork, rwork,
226  \$ info )
227 *
228 * -- LAPACK driver routine (version 3.4.0) --
229 * -- LAPACK is a software package provided by Univ. of Tennessee, --
230 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
231 * November 2011
232 *
233 * .. Scalar Arguments ..
234  CHARACTER jobvsl, jobvsr
235  INTEGER info, lda, ldb, ldvsl, ldvsr, lwork, n
236 * ..
237 * .. Array Arguments ..
238  DOUBLE PRECISION rwork( * )
239  COMPLEX*16 a( lda, * ), alpha( * ), b( ldb, * ),
240  \$ beta( * ), vsl( ldvsl, * ), vsr( ldvsr, * ),
241  \$ work( * )
242 * ..
243 *
244 * =====================================================================
245 *
246 * .. Parameters ..
247  DOUBLE PRECISION zero, one
248  parameter( zero = 0.0d0, one = 1.0d0 )
249  COMPLEX*16 czero, cone
250  parameter( czero = ( 0.0d0, 0.0d0 ),
251  \$ cone = ( 1.0d0, 0.0d0 ) )
252 * ..
253 * .. Local Scalars ..
254  LOGICAL ilascl, ilbscl, ilvsl, ilvsr, lquery
255  INTEGER icols, ihi, iinfo, ijobvl, ijobvr, ileft, ilo,
256  \$ iright, irows, irwork, itau, iwork, lopt,
257  \$ lwkmin, lwkopt, nb, nb1, nb2, nb3
258  DOUBLE PRECISION anrm, anrmto, bignum, bnrm, bnrmto, eps,
259  \$ safmin, smlnum
260 * ..
261 * .. External Subroutines ..
262  EXTERNAL xerbla, zgeqrf, zggbak, zggbal, zgghrd, zhgeqz,
264 * ..
265 * .. External Functions ..
266  LOGICAL lsame
267  INTEGER ilaenv
268  DOUBLE PRECISION dlamch, zlange
269  EXTERNAL lsame, ilaenv, dlamch, zlange
270 * ..
271 * .. Intrinsic Functions ..
272  INTRINSIC int, max
273 * ..
274 * .. Executable Statements ..
275 *
276 * Decode the input arguments
277 *
278  IF( lsame( jobvsl, 'N' ) ) THEN
279  ijobvl = 1
280  ilvsl = .false.
281  ELSE IF( lsame( jobvsl, 'V' ) ) THEN
282  ijobvl = 2
283  ilvsl = .true.
284  ELSE
285  ijobvl = -1
286  ilvsl = .false.
287  END IF
288 *
289  IF( lsame( jobvsr, 'N' ) ) THEN
290  ijobvr = 1
291  ilvsr = .false.
292  ELSE IF( lsame( jobvsr, 'V' ) ) THEN
293  ijobvr = 2
294  ilvsr = .true.
295  ELSE
296  ijobvr = -1
297  ilvsr = .false.
298  END IF
299 *
300 * Test the input arguments
301 *
302  lwkmin = max( 2*n, 1 )
303  lwkopt = lwkmin
304  work( 1 ) = lwkopt
305  lquery = ( lwork.EQ.-1 )
306  info = 0
307  IF( ijobvl.LE.0 ) THEN
308  info = -1
309  ELSE IF( ijobvr.LE.0 ) THEN
310  info = -2
311  ELSE IF( n.LT.0 ) THEN
312  info = -3
313  ELSE IF( lda.LT.max( 1, n ) ) THEN
314  info = -5
315  ELSE IF( ldb.LT.max( 1, n ) ) THEN
316  info = -7
317  ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) ) THEN
318  info = -11
319  ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) ) THEN
320  info = -13
321  ELSE IF( lwork.LT.lwkmin .AND. .NOT.lquery ) THEN
322  info = -15
323  END IF
324 *
325  IF( info.EQ.0 ) THEN
326  nb1 = ilaenv( 1, 'ZGEQRF', ' ', n, n, -1, -1 )
327  nb2 = ilaenv( 1, 'ZUNMQR', ' ', n, n, n, -1 )
328  nb3 = ilaenv( 1, 'ZUNGQR', ' ', n, n, n, -1 )
329  nb = max( nb1, nb2, nb3 )
330  lopt = n*( nb+1 )
331  work( 1 ) = lopt
332  END IF
333 *
334  IF( info.NE.0 ) THEN
335  CALL xerbla( 'ZGEGS ', -info )
336  return
337  ELSE IF( lquery ) THEN
338  return
339  END IF
340 *
341 * Quick return if possible
342 *
343  IF( n.EQ.0 )
344  \$ return
345 *
346 * Get machine constants
347 *
348  eps = dlamch( 'E' )*dlamch( 'B' )
349  safmin = dlamch( 'S' )
350  smlnum = n*safmin / eps
351  bignum = one / smlnum
352 *
353 * Scale A if max element outside range [SMLNUM,BIGNUM]
354 *
355  anrm = zlange( 'M', n, n, a, lda, rwork )
356  ilascl = .false.
357  IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
358  anrmto = smlnum
359  ilascl = .true.
360  ELSE IF( anrm.GT.bignum ) THEN
361  anrmto = bignum
362  ilascl = .true.
363  END IF
364 *
365  IF( ilascl ) THEN
366  CALL zlascl( 'G', -1, -1, anrm, anrmto, n, n, a, lda, iinfo )
367  IF( iinfo.NE.0 ) THEN
368  info = n + 9
369  return
370  END IF
371  END IF
372 *
373 * Scale B if max element outside range [SMLNUM,BIGNUM]
374 *
375  bnrm = zlange( 'M', n, n, b, ldb, rwork )
376  ilbscl = .false.
377  IF( bnrm.GT.zero .AND. bnrm.LT.smlnum ) THEN
378  bnrmto = smlnum
379  ilbscl = .true.
380  ELSE IF( bnrm.GT.bignum ) THEN
381  bnrmto = bignum
382  ilbscl = .true.
383  END IF
384 *
385  IF( ilbscl ) THEN
386  CALL zlascl( 'G', -1, -1, bnrm, bnrmto, n, n, b, ldb, iinfo )
387  IF( iinfo.NE.0 ) THEN
388  info = n + 9
389  return
390  END IF
391  END IF
392 *
393 * Permute the matrix to make it more nearly triangular
394 *
395  ileft = 1
396  iright = n + 1
397  irwork = iright + n
398  iwork = 1
399  CALL zggbal( 'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
400  \$ rwork( iright ), rwork( irwork ), iinfo )
401  IF( iinfo.NE.0 ) THEN
402  info = n + 1
403  go to 10
404  END IF
405 *
406 * Reduce B to triangular form, and initialize VSL and/or VSR
407 *
408  irows = ihi + 1 - ilo
409  icols = n + 1 - ilo
410  itau = iwork
411  iwork = itau + irows
412  CALL zgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
413  \$ work( iwork ), lwork+1-iwork, iinfo )
414  IF( iinfo.GE.0 )
415  \$ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
416  IF( iinfo.NE.0 ) THEN
417  info = n + 2
418  go to 10
419  END IF
420 *
421  CALL zunmqr( 'L', 'C', irows, icols, irows, b( ilo, ilo ), ldb,
422  \$ work( itau ), a( ilo, ilo ), lda, work( iwork ),
423  \$ lwork+1-iwork, iinfo )
424  IF( iinfo.GE.0 )
425  \$ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
426  IF( iinfo.NE.0 ) THEN
427  info = n + 3
428  go to 10
429  END IF
430 *
431  IF( ilvsl ) THEN
432  CALL zlaset( 'Full', n, n, czero, cone, vsl, ldvsl )
433  CALL zlacpy( 'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
434  \$ vsl( ilo+1, ilo ), ldvsl )
435  CALL zungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
436  \$ work( itau ), work( iwork ), lwork+1-iwork,
437  \$ iinfo )
438  IF( iinfo.GE.0 )
439  \$ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
440  IF( iinfo.NE.0 ) THEN
441  info = n + 4
442  go to 10
443  END IF
444  END IF
445 *
446  IF( ilvsr )
447  \$ CALL zlaset( 'Full', n, n, czero, cone, vsr, ldvsr )
448 *
449 * Reduce to generalized Hessenberg form
450 *
451  CALL zgghrd( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
452  \$ ldvsl, vsr, ldvsr, iinfo )
453  IF( iinfo.NE.0 ) THEN
454  info = n + 5
455  go to 10
456  END IF
457 *
458 * Perform QZ algorithm, computing Schur vectors if desired
459 *
460  iwork = itau
461  CALL zhgeqz( 'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
462  \$ alpha, beta, vsl, ldvsl, vsr, ldvsr, work( iwork ),
463  \$ lwork+1-iwork, rwork( irwork ), iinfo )
464  IF( iinfo.GE.0 )
465  \$ lwkopt = max( lwkopt, int( work( iwork ) )+iwork-1 )
466  IF( iinfo.NE.0 ) THEN
467  IF( iinfo.GT.0 .AND. iinfo.LE.n ) THEN
468  info = iinfo
469  ELSE IF( iinfo.GT.n .AND. iinfo.LE.2*n ) THEN
470  info = iinfo - n
471  ELSE
472  info = n + 6
473  END IF
474  go to 10
475  END IF
476 *
477 * Apply permutation to VSL and VSR
478 *
479  IF( ilvsl ) THEN
480  CALL zggbak( 'P', 'L', n, ilo, ihi, rwork( ileft ),
481  \$ rwork( iright ), n, vsl, ldvsl, iinfo )
482  IF( iinfo.NE.0 ) THEN
483  info = n + 7
484  go to 10
485  END IF
486  END IF
487  IF( ilvsr ) THEN
488  CALL zggbak( 'P', 'R', n, ilo, ihi, rwork( ileft ),
489  \$ rwork( iright ), n, vsr, ldvsr, iinfo )
490  IF( iinfo.NE.0 ) THEN
491  info = n + 8
492  go to 10
493  END IF
494  END IF
495 *
496 * Undo scaling
497 *
498  IF( ilascl ) THEN
499  CALL zlascl( 'U', -1, -1, anrmto, anrm, n, n, a, lda, iinfo )
500  IF( iinfo.NE.0 ) THEN
501  info = n + 9
502  return
503  END IF
504  CALL zlascl( 'G', -1, -1, anrmto, anrm, n, 1, alpha, n, iinfo )
505  IF( iinfo.NE.0 ) THEN
506  info = n + 9
507  return
508  END IF
509  END IF
510 *
511  IF( ilbscl ) THEN
512  CALL zlascl( 'U', -1, -1, bnrmto, bnrm, n, n, b, ldb, iinfo )
513  IF( iinfo.NE.0 ) THEN
514  info = n + 9
515  return
516  END IF
517  CALL zlascl( 'G', -1, -1, bnrmto, bnrm, n, 1, beta, n, iinfo )
518  IF( iinfo.NE.0 ) THEN
519  info = n + 9
520  return
521  END IF
522  END IF
523 *
524  10 continue
525  work( 1 ) = lwkopt
526 *
527  return
528 *
529 * End of ZGEGS
530 *
531  END