LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ cgges3()

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

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

Download CGGES3 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
!>
!> CGGES3 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
!> CGGEV instead, which is faster.)
!>
!> 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 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 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 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 array, dimension (N)
!> 
[out]BETA
!>          BETA is COMPLEX 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 CGGES3. 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 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 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 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. LWORK >= MAX(1,2*N).
!>          For good performance, LWORK must generally be larger.
!>
!>          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 REAL 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 CLAQZ0
!>                =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 CTGSEN.
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 265 of file cgges3.f.

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