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