LAPACK 3.12.0 LAPACK: Linear Algebra PACKage
Searching...
No Matches

## ◆ zgges3()

 subroutine zgges3 ( character jobvsl, character jobvsr, character sort, external selctg, integer n, complex*16, dimension( lda, * ) a, integer lda, complex*16, dimension( ldb, * ) b, integer ldb, integer sdim, complex*16, dimension( * ) alpha, complex*16, dimension( * ) beta, complex*16, dimension( ldvsl, * ) vsl, integer ldvsl, complex*16, dimension( ldvsr, * ) vsr, integer ldvsr, complex*16, dimension( * ) work, integer lwork, double precision, dimension( * ) rwork, logical, dimension( * ) bwork, integer info )

ZGGES3 computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE matrices (blocked algorithm)

Purpose:
``` ZGGES3 computes for a pair of N-by-N complex nonsymmetric matrices
(A,B), the generalized eigenvalues, the generalized complex Schur
form (S, T), and optionally left and/or right Schur vectors (VSL
and VSR). This gives the generalized Schur factorization

(A,B) = ( (VSL)*S*(VSR)**H, (VSL)*T*(VSR)**H )

where (VSR)**H is the conjugate-transpose of VSR.

Optionally, it also orders the eigenvalues so that a selected cluster
of eigenvalues appears in the leading diagonal blocks of the upper
triangular matrix S and the upper triangular matrix T. The leading
columns of VSL and VSR then form an unitary basis for the
corresponding left and right eigenspaces (deflating subspaces).

(If only the generalized eigenvalues are needed, use the driver

A generalized eigenvalue for a pair of matrices (A,B) is a scalar w
or a ratio alpha/beta = w, such that  A - w*B is singular.  It is
usually represented as the pair (alpha,beta), as there is a
reasonable interpretation for beta=0, and even for both being zero.

A pair of matrices (S,T) is in generalized complex Schur form if S
and T are upper triangular and, in addition, the diagonal elements
of T are non-negative real numbers.```
Parameters
 [in] JOBVSL ``` JOBVSL is CHARACTER*1 = 'N': do not compute the left Schur vectors; = 'V': compute the left Schur vectors.``` [in] JOBVSR ``` JOBVSR is CHARACTER*1 = 'N': do not compute the right Schur vectors; = 'V': compute the right Schur vectors.``` [in] SORT ``` SORT is CHARACTER*1 Specifies whether or not to order the eigenvalues on the diagonal of the generalized Schur form. = 'N': Eigenvalues are not ordered; = 'S': Eigenvalues are ordered (see SELCTG).``` [in] SELCTG ``` SELCTG is a LOGICAL FUNCTION of two COMPLEX*16 arguments SELCTG must be declared EXTERNAL in the calling subroutine. If SORT = 'N', SELCTG is not referenced. If SORT = 'S', SELCTG is used to select eigenvalues to sort to the top left of the Schur form. An eigenvalue ALPHA(j)/BETA(j) is selected if SELCTG(ALPHA(j),BETA(j)) is true. Note that a selected complex eigenvalue may no longer satisfy SELCTG(ALPHA(j),BETA(j)) = .TRUE. after ordering, since ordering may change the value of complex eigenvalues (especially if the eigenvalue is ill-conditioned), in this case INFO is set to N+2 (See INFO below).``` [in] N ``` N is INTEGER The order of the matrices A, B, VSL, and VSR. N >= 0.``` [in,out] A ``` A is COMPLEX*16 array, dimension (LDA, N) On entry, the first of the pair of matrices. On exit, A has been overwritten by its generalized Schur form S.``` [in] LDA ``` LDA is INTEGER The leading dimension of A. LDA >= max(1,N).``` [in,out] B ``` B is COMPLEX*16 array, dimension (LDB, N) On entry, the second of the pair of matrices. On exit, B has been overwritten by its generalized Schur form T.``` [in] LDB ``` LDB is INTEGER The leading dimension of B. LDB >= max(1,N).``` [out] SDIM ``` SDIM is INTEGER If SORT = 'N', SDIM = 0. If SORT = 'S', SDIM = number of eigenvalues (after sorting) for which SELCTG is true.``` [out] ALPHA ` ALPHA is COMPLEX*16 array, dimension (N)` [out] BETA ``` BETA is COMPLEX*16 array, dimension (N) On exit, ALPHA(j)/BETA(j), j=1,...,N, will be the generalized eigenvalues. ALPHA(j), j=1,...,N and BETA(j), j=1,...,N are the diagonals of the complex Schur form (A,B) output by ZGGES3. The BETA(j) will be non-negative real. Note: the quotients ALPHA(j)/BETA(j) may easily over- or underflow, and BETA(j) may even be zero. Thus, the user should avoid naively computing the ratio alpha/beta. However, ALPHA will be always less than and usually comparable with norm(A) in magnitude, and BETA always less than and usually comparable with norm(B).``` [out] VSL ``` VSL is COMPLEX*16 array, dimension (LDVSL,N) If JOBVSL = 'V', VSL will contain the left Schur vectors. Not referenced if JOBVSL = 'N'.``` [in] LDVSL ``` LDVSL is INTEGER The leading dimension of the matrix VSL. LDVSL >= 1, and if JOBVSL = 'V', LDVSL >= N.``` [out] VSR ``` VSR is COMPLEX*16 array, dimension (LDVSR,N) If JOBVSR = 'V', VSR will contain the right Schur vectors. Not referenced if JOBVSR = 'N'.``` [in] LDVSR ``` LDVSR is INTEGER The leading dimension of the matrix VSR. LDVSR >= 1, and if JOBVSR = 'V', LDVSR >= N.``` [out] WORK ``` WORK is COMPLEX*16 array, dimension (MAX(1,LWORK)) On exit, if INFO = 0, WORK(1) returns the optimal LWORK.``` [in] LWORK ``` LWORK is INTEGER The dimension of the array WORK. If LWORK = -1, then a workspace query is assumed; the routine only calculates the optimal size of the WORK array, returns this value as the first entry of the WORK array, and no error message related to LWORK is issued by XERBLA.``` [out] RWORK ` RWORK is DOUBLE PRECISION array, dimension (8*N)` [out] BWORK ``` BWORK is LOGICAL array, dimension (N) Not referenced if SORT = 'N'.``` [out] INFO ``` INFO is INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value. =1,...,N: The QZ iteration failed. (A,B) are not in Schur form, but ALPHA(j) and BETA(j) should be correct for j=INFO+1,...,N. > N: =N+1: other than QZ iteration failed in ZLAQZ0 =N+2: after reordering, roundoff changed values of some complex eigenvalues so that leading eigenvalues in the Generalized Schur form no longer satisfy SELCTG=.TRUE. This could also be caused due to scaling. =N+3: reordering failed in ZTGSEN.```

Definition at line 266 of file zgges3.f.

269*
270* -- LAPACK driver routine --
271* -- LAPACK is a software package provided by Univ. of Tennessee, --
272* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
273*
274* .. Scalar Arguments ..
275 CHARACTER JOBVSL, JOBVSR, SORT
276 INTEGER INFO, LDA, LDB, LDVSL, LDVSR, LWORK, N, SDIM
277* ..
278* .. Array Arguments ..
279 LOGICAL BWORK( * )
280 DOUBLE PRECISION RWORK( * )
281 COMPLEX*16 A( LDA, * ), ALPHA( * ), B( LDB, * ),
282 \$ BETA( * ), VSL( LDVSL, * ), VSR( LDVSR, * ),
283 \$ WORK( * )
284* ..
285* .. Function Arguments ..
286 LOGICAL SELCTG
287 EXTERNAL selctg
288* ..
289*
290* =====================================================================
291*
292* .. Parameters ..
293 DOUBLE PRECISION ZERO, ONE
294 parameter( zero = 0.0d0, one = 1.0d0 )
295 COMPLEX*16 CZERO, CONE
296 parameter( czero = ( 0.0d0, 0.0d0 ),
297 \$ cone = ( 1.0d0, 0.0d0 ) )
298* ..
299* .. Local Scalars ..
300 LOGICAL CURSL, ILASCL, ILBSCL, ILVSL, ILVSR, LASTSL,
301 \$ LQUERY, WANTST
302 INTEGER I, ICOLS, IERR, IHI, IJOBVL, IJOBVR, ILEFT,
303 \$ ILO, IRIGHT, IROWS, IRWRK, ITAU, IWRK, LWKOPT
304 DOUBLE PRECISION ANRM, ANRMTO, BIGNUM, BNRM, BNRMTO, EPS, PVSL,
305 \$ PVSR, SMLNUM
306* ..
307* .. Local Arrays ..
308 INTEGER IDUM( 1 )
309 DOUBLE PRECISION DIF( 2 )
310* ..
311* .. External Subroutines ..
312 EXTERNAL xerbla, zgeqrf, zggbak, zggbal, zgghd3, zlaqz0,
314* ..
315* .. External Functions ..
316 LOGICAL LSAME
317 DOUBLE PRECISION DLAMCH, ZLANGE
318 EXTERNAL lsame, dlamch, zlange
319* ..
320* .. Intrinsic Functions ..
321 INTRINSIC max, sqrt
322* ..
323* .. Executable Statements ..
324*
325* Decode the input arguments
326*
327 IF( lsame( jobvsl, 'N' ) ) THEN
328 ijobvl = 1
329 ilvsl = .false.
330 ELSE IF( lsame( jobvsl, 'V' ) ) THEN
331 ijobvl = 2
332 ilvsl = .true.
333 ELSE
334 ijobvl = -1
335 ilvsl = .false.
336 END IF
337*
338 IF( lsame( jobvsr, 'N' ) ) THEN
339 ijobvr = 1
340 ilvsr = .false.
341 ELSE IF( lsame( jobvsr, 'V' ) ) THEN
342 ijobvr = 2
343 ilvsr = .true.
344 ELSE
345 ijobvr = -1
346 ilvsr = .false.
347 END IF
348*
349 wantst = lsame( sort, 'S' )
350*
351* Test the input arguments
352*
353 info = 0
354 lquery = ( lwork.EQ.-1 )
355 IF( ijobvl.LE.0 ) THEN
356 info = -1
357 ELSE IF( ijobvr.LE.0 ) THEN
358 info = -2
359 ELSE IF( ( .NOT.wantst ) .AND. ( .NOT.lsame( sort, 'N' ) ) ) THEN
360 info = -3
361 ELSE IF( n.LT.0 ) THEN
362 info = -5
363 ELSE IF( lda.LT.max( 1, n ) ) THEN
364 info = -7
365 ELSE IF( ldb.LT.max( 1, n ) ) THEN
366 info = -9
367 ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) ) THEN
368 info = -14
369 ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) ) THEN
370 info = -16
371 ELSE IF( lwork.LT.max( 1, 2*n ) .AND. .NOT.lquery ) THEN
372 info = -18
373 END IF
374*
375* Compute workspace
376*
377 IF( info.EQ.0 ) THEN
378 CALL zgeqrf( n, n, b, ldb, work, work, -1, ierr )
379 lwkopt = max( 1, n + int( work( 1 ) ) )
380 CALL zunmqr( 'L', 'C', n, n, n, b, ldb, work, a, lda, work,
381 \$ -1, ierr )
382 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
383 IF( ilvsl ) THEN
384 CALL zungqr( n, n, n, vsl, ldvsl, work, work, -1, ierr )
385 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
386 END IF
387 CALL zgghd3( jobvsl, jobvsr, n, 1, n, a, lda, b, ldb, vsl,
388 \$ ldvsl, vsr, ldvsr, work, -1, ierr )
389 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
390 CALL zlaqz0( 'S', jobvsl, jobvsr, n, 1, n, a, lda, b, ldb,
391 \$ alpha, beta, vsl, ldvsl, vsr, ldvsr, work, -1,
392 \$ rwork, 0, ierr )
393 lwkopt = max( lwkopt, int( work( 1 ) ) )
394 IF( wantst ) THEN
395 CALL ztgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb,
396 \$ alpha, beta, vsl, ldvsl, vsr, ldvsr, sdim,
397 \$ pvsl, pvsr, dif, work, -1, idum, 1, ierr )
398 lwkopt = max( lwkopt, int( work( 1 ) ) )
399 END IF
400 work( 1 ) = dcmplx( lwkopt )
401 END IF
402*
403 IF( info.NE.0 ) THEN
404 CALL xerbla( 'ZGGES3 ', -info )
405 RETURN
406 ELSE IF( lquery ) THEN
407 RETURN
408 END IF
409*
410* Quick return if possible
411*
412 IF( n.EQ.0 ) THEN
413 sdim = 0
414 RETURN
415 END IF
416*
417* Get machine constants
418*
419 eps = dlamch( 'P' )
420 smlnum = dlamch( 'S' )
421 bignum = one / smlnum
422 smlnum = sqrt( smlnum ) / eps
423 bignum = one / smlnum
424*
425* Scale A if max element outside range [SMLNUM,BIGNUM]
426*
427 anrm = zlange( 'M', n, n, a, lda, rwork )
428 ilascl = .false.
429 IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
430 anrmto = smlnum
431 ilascl = .true.
432 ELSE IF( anrm.GT.bignum ) THEN
433 anrmto = bignum
434 ilascl = .true.
435 END IF
436*
437 IF( ilascl )
438 \$ CALL zlascl( 'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
439*
440* Scale B if max element outside range [SMLNUM,BIGNUM]
441*
442 bnrm = zlange( 'M', n, n, b, ldb, rwork )
443 ilbscl = .false.
444 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum ) THEN
445 bnrmto = smlnum
446 ilbscl = .true.
447 ELSE IF( bnrm.GT.bignum ) THEN
448 bnrmto = bignum
449 ilbscl = .true.
450 END IF
451*
452 IF( ilbscl )
453 \$ CALL zlascl( 'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
454*
455* Permute the matrix to make it more nearly triangular
456*
457 ileft = 1
458 iright = n + 1
459 irwrk = iright + n
460 CALL zggbal( 'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
461 \$ rwork( iright ), rwork( irwrk ), ierr )
462*
463* Reduce B to triangular form (QR decomposition of B)
464*
465 irows = ihi + 1 - ilo
466 icols = n + 1 - ilo
467 itau = 1
468 iwrk = itau + irows
469 CALL zgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
470 \$ work( iwrk ), lwork+1-iwrk, ierr )
471*
472* Apply the orthogonal transformation to matrix A
473*
474 CALL zunmqr( 'L', 'C', irows, icols, irows, b( ilo, ilo ), ldb,
475 \$ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
476 \$ lwork+1-iwrk, ierr )
477*
478* Initialize VSL
479*
480 IF( ilvsl ) THEN
481 CALL zlaset( 'Full', n, n, czero, cone, vsl, ldvsl )
482 IF( irows.GT.1 ) THEN
483 CALL zlacpy( 'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
484 \$ vsl( ilo+1, ilo ), ldvsl )
485 END IF
486 CALL zungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
487 \$ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
488 END IF
489*
490* Initialize VSR
491*
492 IF( ilvsr )
493 \$ CALL zlaset( 'Full', n, n, czero, cone, vsr, ldvsr )
494*
495* Reduce to generalized Hessenberg form
496*
497 CALL zgghd3( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
498 \$ ldvsl, vsr, ldvsr, work( iwrk ), lwork+1-iwrk, ierr )
499*
500 sdim = 0
501*
502* Perform QZ algorithm, computing Schur vectors if desired
503*
504 iwrk = itau
505 CALL zlaqz0( 'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
506 \$ alpha, beta, vsl, ldvsl, vsr, ldvsr, work( iwrk ),
507 \$ lwork+1-iwrk, rwork( irwrk ), 0, ierr )
508 IF( ierr.NE.0 ) THEN
509 IF( ierr.GT.0 .AND. ierr.LE.n ) THEN
510 info = ierr
511 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n ) THEN
512 info = ierr - n
513 ELSE
514 info = n + 1
515 END IF
516 GO TO 30
517 END IF
518*
519* Sort eigenvalues ALPHA/BETA if desired
520*
521 IF( wantst ) THEN
522*
523* Undo scaling on eigenvalues before selecting
524*
525 IF( ilascl )
526 \$ CALL zlascl( 'G', 0, 0, anrm, anrmto, n, 1, alpha, n, ierr )
527 IF( ilbscl )
528 \$ CALL zlascl( 'G', 0, 0, bnrm, bnrmto, n, 1, beta, n, ierr )
529*
530* Select eigenvalues
531*
532 DO 10 i = 1, n
533 bwork( i ) = selctg( alpha( i ), beta( i ) )
534 10 CONTINUE
535*
536 CALL ztgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb, alpha,
537 \$ beta, vsl, ldvsl, vsr, ldvsr, sdim, pvsl, pvsr,
538 \$ dif, work( iwrk ), lwork-iwrk+1, idum, 1, ierr )
539 IF( ierr.EQ.1 )
540 \$ info = n + 3
541*
542 END IF
543*
544* Apply back-permutation to VSL and VSR
545*
546 IF( ilvsl )
547 \$ CALL zggbak( 'P', 'L', n, ilo, ihi, rwork( ileft ),
548 \$ rwork( iright ), n, vsl, ldvsl, ierr )
549 IF( ilvsr )
550 \$ CALL zggbak( 'P', 'R', n, ilo, ihi, rwork( ileft ),
551 \$ rwork( iright ), n, vsr, ldvsr, ierr )
552*
553* Undo scaling
554*
555 IF( ilascl ) THEN
556 CALL zlascl( 'U', 0, 0, anrmto, anrm, n, n, a, lda, ierr )
557 CALL zlascl( 'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
558 END IF
559*
560 IF( ilbscl ) THEN
561 CALL zlascl( 'U', 0, 0, bnrmto, bnrm, n, n, b, ldb, ierr )
562 CALL zlascl( 'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
563 END IF
564*
565 IF( wantst ) THEN
566*
567* Check if reordering is correct
568*
569 lastsl = .true.
570 sdim = 0
571 DO 20 i = 1, n
572 cursl = selctg( alpha( i ), beta( i ) )
573 IF( cursl )
574 \$ sdim = sdim + 1
575 IF( cursl .AND. .NOT.lastsl )
576 \$ info = n + 2
577 lastsl = cursl
578 20 CONTINUE
579*
580 END IF
581*
582 30 CONTINUE
583*
584 work( 1 ) = dcmplx( lwkopt )
585*
586 RETURN
587*
588* End of ZGGES3
589*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zgeqrf(m, n, a, lda, tau, work, lwork, info)
ZGEQRF
Definition zgeqrf.f:146
subroutine zggbak(job, side, n, ilo, ihi, lscale, rscale, m, v, ldv, info)
ZGGBAK
Definition zggbak.f:148
subroutine zggbal(job, n, a, lda, b, ldb, ilo, ihi, lscale, rscale, work, info)
ZGGBAL
Definition zggbal.f:177
subroutine zgghd3(compq, compz, n, ilo, ihi, a, lda, b, ldb, q, ldq, z, ldz, work, lwork, info)
ZGGHD3
Definition zgghd3.f:227
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
Definition zlacpy.f:103
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
double precision function zlange(norm, m, n, a, lda, work)
ZLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition zlange.f:115
recursive subroutine zlaqz0(wants, wantq, wantz, n, ilo, ihi, a, lda, b, ldb, alpha, beta, q, ldq, z, ldz, work, lwork, rwork, rec, info)
ZLAQZ0
Definition zlaqz0.f:284
subroutine zlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition zlascl.f:143
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition zlaset.f:106
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine ztgsen(ijob, wantq, wantz, select, n, a, lda, b, ldb, alpha, beta, q, ldq, z, ldz, m, pl, pr, dif, work, lwork, iwork, liwork, info)
ZTGSEN
Definition ztgsen.f:433
subroutine zungqr(m, n, k, a, lda, tau, work, lwork, info)
ZUNGQR
Definition zungqr.f:128
subroutine zunmqr(side, trans, m, n, k, a, lda, tau, c, ldc, work, lwork, info)
ZUNMQR
Definition zunmqr.f:167
Here is the call graph for this function:
Here is the caller graph for this function: