LAPACK 3.11.0
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.

          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 266 of file cgges3.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 REAL RWORK( * )
281 COMPLEX 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 REAL ZERO, ONE
294 parameter( zero = 0.0e0, one = 1.0e0 )
295 COMPLEX CZERO, CONE
296 parameter( czero = ( 0.0e0, 0.0e0 ),
297 $ cone = ( 1.0e0, 0.0e0 ) )
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 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, clacpy,
314 $ xerbla
315* ..
316* .. External Functions ..
317 LOGICAL LSAME
318 REAL CLANGE, SLAMCH
319 EXTERNAL lsame, clange, slamch
320* ..
321* .. Intrinsic Functions ..
322 INTRINSIC max, sqrt
323* ..
324* .. Executable Statements ..
325*
326* Decode the input arguments
327*
328 IF( lsame( jobvsl, 'N' ) ) THEN
329 ijobvl = 1
330 ilvsl = .false.
331 ELSE IF( lsame( jobvsl, 'V' ) ) THEN
332 ijobvl = 2
333 ilvsl = .true.
334 ELSE
335 ijobvl = -1
336 ilvsl = .false.
337 END IF
338*
339 IF( lsame( jobvsr, 'N' ) ) THEN
340 ijobvr = 1
341 ilvsr = .false.
342 ELSE IF( lsame( jobvsr, 'V' ) ) THEN
343 ijobvr = 2
344 ilvsr = .true.
345 ELSE
346 ijobvr = -1
347 ilvsr = .false.
348 END IF
349*
350 wantst = lsame( sort, 'S' )
351*
352* Test the input arguments
353*
354 info = 0
355 lquery = ( lwork.EQ.-1 )
356 IF( ijobvl.LE.0 ) THEN
357 info = -1
358 ELSE IF( ijobvr.LE.0 ) THEN
359 info = -2
360 ELSE IF( ( .NOT.wantst ) .AND. ( .NOT.lsame( sort, 'N' ) ) ) THEN
361 info = -3
362 ELSE IF( n.LT.0 ) THEN
363 info = -5
364 ELSE IF( lda.LT.max( 1, n ) ) THEN
365 info = -7
366 ELSE IF( ldb.LT.max( 1, n ) ) THEN
367 info = -9
368 ELSE IF( ldvsl.LT.1 .OR. ( ilvsl .AND. ldvsl.LT.n ) ) THEN
369 info = -14
370 ELSE IF( ldvsr.LT.1 .OR. ( ilvsr .AND. ldvsr.LT.n ) ) THEN
371 info = -16
372 ELSE IF( lwork.LT.max( 1, 2*n ) .AND. .NOT.lquery ) THEN
373 info = -18
374 END IF
375*
376* Compute workspace
377*
378 IF( info.EQ.0 ) THEN
379 CALL cgeqrf( n, n, b, ldb, work, work, -1, ierr )
380 lwkopt = max( 1, n + int( work( 1 ) ) )
381 CALL cunmqr( 'L', 'C', n, n, n, b, ldb, work, a, lda, work,
382 $ -1, ierr )
383 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
384 IF( ilvsl ) THEN
385 CALL cungqr( n, n, n, vsl, ldvsl, work, work, -1,
386 $ ierr )
387 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
388 END IF
389 CALL cgghd3( jobvsl, jobvsr, n, 1, n, a, lda, b, ldb, vsl,
390 $ ldvsl, vsr, ldvsr, work, -1, ierr )
391 lwkopt = max( lwkopt, n + int( work( 1 ) ) )
392 CALL claqz0( 'S', jobvsl, jobvsr, n, 1, n, a, lda, b, ldb,
393 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work, -1,
394 $ rwork, 0, ierr )
395 lwkopt = max( lwkopt, int( work( 1 ) ) )
396 IF( wantst ) THEN
397 CALL ctgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb,
398 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, sdim,
399 $ pvsl, pvsr, dif, work, -1, idum, 1, ierr )
400 lwkopt = max( lwkopt, int( work( 1 ) ) )
401 END IF
402 work( 1 ) = cmplx( lwkopt )
403 END IF
404
405*
406 IF( info.NE.0 ) THEN
407 CALL xerbla( 'CGGES3 ', -info )
408 RETURN
409 ELSE IF( lquery ) THEN
410 RETURN
411 END IF
412*
413* Quick return if possible
414*
415 IF( n.EQ.0 ) THEN
416 sdim = 0
417 RETURN
418 END IF
419*
420* Get machine constants
421*
422 eps = slamch( 'P' )
423 smlnum = slamch( 'S' )
424 bignum = one / smlnum
425 CALL slabad( smlnum, bignum )
426 smlnum = sqrt( smlnum ) / eps
427 bignum = one / smlnum
428*
429* Scale A if max element outside range [SMLNUM,BIGNUM]
430*
431 anrm = clange( 'M', n, n, a, lda, rwork )
432 ilascl = .false.
433 IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
434 anrmto = smlnum
435 ilascl = .true.
436 ELSE IF( anrm.GT.bignum ) THEN
437 anrmto = bignum
438 ilascl = .true.
439 END IF
440*
441 IF( ilascl )
442 $ CALL clascl( 'G', 0, 0, anrm, anrmto, n, n, a, lda, ierr )
443*
444* Scale B if max element outside range [SMLNUM,BIGNUM]
445*
446 bnrm = clange( 'M', n, n, b, ldb, rwork )
447 ilbscl = .false.
448 IF( bnrm.GT.zero .AND. bnrm.LT.smlnum ) THEN
449 bnrmto = smlnum
450 ilbscl = .true.
451 ELSE IF( bnrm.GT.bignum ) THEN
452 bnrmto = bignum
453 ilbscl = .true.
454 END IF
455*
456 IF( ilbscl )
457 $ CALL clascl( 'G', 0, 0, bnrm, bnrmto, n, n, b, ldb, ierr )
458*
459* Permute the matrix to make it more nearly triangular
460*
461 ileft = 1
462 iright = n + 1
463 irwrk = iright + n
464 CALL cggbal( 'P', n, a, lda, b, ldb, ilo, ihi, rwork( ileft ),
465 $ rwork( iright ), rwork( irwrk ), ierr )
466*
467* Reduce B to triangular form (QR decomposition of B)
468*
469 irows = ihi + 1 - ilo
470 icols = n + 1 - ilo
471 itau = 1
472 iwrk = itau + irows
473 CALL cgeqrf( irows, icols, b( ilo, ilo ), ldb, work( itau ),
474 $ work( iwrk ), lwork+1-iwrk, ierr )
475*
476* Apply the orthogonal transformation to matrix A
477*
478 CALL cunmqr( 'L', 'C', irows, icols, irows, b( ilo, ilo ), ldb,
479 $ work( itau ), a( ilo, ilo ), lda, work( iwrk ),
480 $ lwork+1-iwrk, ierr )
481*
482* Initialize VSL
483*
484 IF( ilvsl ) THEN
485 CALL claset( 'Full', n, n, czero, cone, vsl, ldvsl )
486 IF( irows.GT.1 ) THEN
487 CALL clacpy( 'L', irows-1, irows-1, b( ilo+1, ilo ), ldb,
488 $ vsl( ilo+1, ilo ), ldvsl )
489 END IF
490 CALL cungqr( irows, irows, irows, vsl( ilo, ilo ), ldvsl,
491 $ work( itau ), work( iwrk ), lwork+1-iwrk, ierr )
492 END IF
493*
494* Initialize VSR
495*
496 IF( ilvsr )
497 $ CALL claset( 'Full', n, n, czero, cone, vsr, ldvsr )
498*
499* Reduce to generalized Hessenberg form
500*
501 CALL cgghd3( jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb, vsl,
502 $ ldvsl, vsr, ldvsr, work( iwrk ), lwork+1-iwrk, ierr )
503*
504 sdim = 0
505*
506* Perform QZ algorithm, computing Schur vectors if desired
507*
508 iwrk = itau
509 CALL claqz0( 'S', jobvsl, jobvsr, n, ilo, ihi, a, lda, b, ldb,
510 $ alpha, beta, vsl, ldvsl, vsr, ldvsr, work( iwrk ),
511 $ lwork+1-iwrk, rwork( irwrk ), 0, ierr )
512 IF( ierr.NE.0 ) THEN
513 IF( ierr.GT.0 .AND. ierr.LE.n ) THEN
514 info = ierr
515 ELSE IF( ierr.GT.n .AND. ierr.LE.2*n ) THEN
516 info = ierr - n
517 ELSE
518 info = n + 1
519 END IF
520 GO TO 30
521 END IF
522*
523* Sort eigenvalues ALPHA/BETA if desired
524*
525 IF( wantst ) THEN
526*
527* Undo scaling on eigenvalues before selecting
528*
529 IF( ilascl )
530 $ CALL clascl( 'G', 0, 0, anrm, anrmto, n, 1, alpha, n, ierr )
531 IF( ilbscl )
532 $ CALL clascl( 'G', 0, 0, bnrm, bnrmto, n, 1, beta, n, ierr )
533*
534* Select eigenvalues
535*
536 DO 10 i = 1, n
537 bwork( i ) = selctg( alpha( i ), beta( i ) )
538 10 CONTINUE
539*
540 CALL ctgsen( 0, ilvsl, ilvsr, bwork, n, a, lda, b, ldb, alpha,
541 $ beta, vsl, ldvsl, vsr, ldvsr, sdim, pvsl, pvsr,
542 $ dif, work( iwrk ), lwork-iwrk+1, idum, 1, ierr )
543 IF( ierr.EQ.1 )
544 $ info = n + 3
545*
546 END IF
547*
548* Apply back-permutation to VSL and VSR
549*
550 IF( ilvsl )
551 $ CALL cggbak( 'P', 'L', n, ilo, ihi, rwork( ileft ),
552 $ rwork( iright ), n, vsl, ldvsl, ierr )
553 IF( ilvsr )
554 $ CALL cggbak( 'P', 'R', n, ilo, ihi, rwork( ileft ),
555 $ rwork( iright ), n, vsr, ldvsr, ierr )
556*
557* Undo scaling
558*
559 IF( ilascl ) THEN
560 CALL clascl( 'U', 0, 0, anrmto, anrm, n, n, a, lda, ierr )
561 CALL clascl( 'G', 0, 0, anrmto, anrm, n, 1, alpha, n, ierr )
562 END IF
563*
564 IF( ilbscl ) THEN
565 CALL clascl( 'U', 0, 0, bnrmto, bnrm, n, n, b, ldb, ierr )
566 CALL clascl( 'G', 0, 0, bnrmto, bnrm, n, 1, beta, n, ierr )
567 END IF
568*
569 IF( wantst ) THEN
570*
571* Check if reordering is correct
572*
573 lastsl = .true.
574 sdim = 0
575 DO 20 i = 1, n
576 cursl = selctg( alpha( i ), beta( i ) )
577 IF( cursl )
578 $ sdim = sdim + 1
579 IF( cursl .AND. .NOT.lastsl )
580 $ info = n + 2
581 lastsl = cursl
582 20 CONTINUE
583*
584 END IF
585*
586 30 CONTINUE
587*
588 work( 1 ) = cmplx( lwkopt )
589*
590 RETURN
591*
592* End of CGGES3
593*
subroutine slabad(SMALL, LARGE)
SLABAD
Definition: slabad.f:74
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
subroutine cggbal(JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE, WORK, INFO)
CGGBAL
Definition: cggbal.f:177
subroutine cggbak(JOB, SIDE, N, ILO, IHI, LSCALE, RSCALE, M, V, LDV, INFO)
CGGBAK
Definition: cggbak.f:148
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:115
subroutine cgeqrf(M, N, A, LDA, TAU, WORK, LWORK, INFO)
CGEQRF
Definition: cgeqrf.f:146
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:284
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:106
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:143
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:103
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:433
subroutine cgghd3(COMPQ, COMPZ, N, ILO, IHI, A, LDA, B, LDB, Q, LDQ, Z, LDZ, WORK, LWORK, INFO)
CGGHD3
Definition: cgghd3.f:231
subroutine cunmqr(SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
CUNMQR
Definition: cunmqr.f:168
subroutine cungqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
CUNGQR
Definition: cungqr.f:128
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:68
Here is the call graph for this function:
Here is the caller graph for this function: