LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine cgeesx ( character  JOBVS,
character  SORT,
external  SELECT,
character  SENSE,
integer  N,
complex, dimension( lda, * )  A,
integer  LDA,
integer  SDIM,
complex, dimension( * )  W,
complex, dimension( ldvs, * )  VS,
integer  LDVS,
real  RCONDE,
real  RCONDV,
complex, dimension( * )  WORK,
integer  LWORK,
real, dimension( * )  RWORK,
logical, dimension( * )  BWORK,
integer  INFO 
)

CGEESX computes the eigenvalues, the Schur form, and, optionally, the matrix of Schur vectors for GE matrices

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

Purpose:
 CGEESX computes for an N-by-N complex nonsymmetric matrix A, the
 eigenvalues, the Schur form T, and, optionally, the matrix of Schur
 vectors Z.  This gives the Schur factorization A = Z*T*(Z**H).

 Optionally, it also orders the eigenvalues on the diagonal of the
 Schur form so that selected eigenvalues are at the top left;
 computes a reciprocal condition number for the average of the
 selected eigenvalues (RCONDE); and computes a reciprocal condition
 number for the right invariant subspace corresponding to the
 selected eigenvalues (RCONDV).  The leading columns of Z form an
 orthonormal basis for this invariant subspace.

 For further explanation of the reciprocal condition numbers RCONDE
 and RCONDV, see Section 4.10 of the LAPACK Users' Guide (where
 these quantities are called s and sep respectively).

 A complex matrix is in Schur form if it is upper triangular.
Parameters
[in]JOBVS
          JOBVS is CHARACTER*1
          = 'N': Schur vectors are not computed;
          = 'V': Schur vectors are computed.
[in]SORT
          SORT is CHARACTER*1
          Specifies whether or not to order the eigenvalues on the
          diagonal of the Schur form.
          = 'N': Eigenvalues are not ordered;
          = 'S': Eigenvalues are ordered (see SELECT).
[in]SELECT
          SELECT is a LOGICAL FUNCTION of one COMPLEX argument
          SELECT must be declared EXTERNAL in the calling subroutine.
          If SORT = 'S', SELECT is used to select eigenvalues to order
          to the top left of the Schur form.
          If SORT = 'N', SELECT is not referenced.
          An eigenvalue W(j) is selected if SELECT(W(j)) is true.
[in]SENSE
          SENSE is CHARACTER*1
          Determines which reciprocal condition numbers are computed.
          = 'N': None are computed;
          = 'E': Computed for average of selected eigenvalues only;
          = 'V': Computed for selected right invariant subspace only;
          = 'B': Computed for both.
          If SENSE = 'E', 'V' or 'B', SORT must equal 'S'.
[in]N
          N is INTEGER
          The order of the matrix A. N >= 0.
[in,out]A
          A is COMPLEX array, dimension (LDA, N)
          On entry, the N-by-N matrix A.
          On exit, A is overwritten by its Schur form T.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,N).
[out]SDIM
          SDIM is INTEGER
          If SORT = 'N', SDIM = 0.
          If SORT = 'S', SDIM = number of eigenvalues for which
                         SELECT is true.
[out]W
          W is COMPLEX array, dimension (N)
          W contains the computed eigenvalues, in the same order
          that they appear on the diagonal of the output Schur form T.
[out]VS
          VS is COMPLEX array, dimension (LDVS,N)
          If JOBVS = 'V', VS contains the unitary matrix Z of Schur
          vectors.
          If JOBVS = 'N', VS is not referenced.
[in]LDVS
          LDVS is INTEGER
          The leading dimension of the array VS.  LDVS >= 1, and if
          JOBVS = 'V', LDVS >= N.
[out]RCONDE
          RCONDE is REAL
          If SENSE = 'E' or 'B', RCONDE contains the reciprocal
          condition number for the average of the selected eigenvalues.
          Not referenced if SENSE = 'N' or 'V'.
[out]RCONDV
          RCONDV is REAL
          If SENSE = 'V' or 'B', RCONDV contains the reciprocal
          condition number for the selected right invariant subspace.
          Not referenced if SENSE = 'N' or 'E'.
[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).
          Also, if SENSE = 'E' or 'V' or 'B', LWORK >= 2*SDIM*(N-SDIM),
          where SDIM is the number of selected eigenvalues computed by
          this routine.  Note that 2*SDIM*(N-SDIM) <= N*N/2. Note also
          that an error is only returned if LWORK < max(1,2*N), but if
          SENSE = 'E' or 'V' or 'B' this may not be large enough.
          For good performance, LWORK must generally be larger.

          If LWORK = -1, then a workspace query is assumed; the routine
          only calculates upper bound on the optimal size of the
          array WORK, 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 (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.
          > 0: if INFO = i, and i is
             <= N: the QR algorithm failed to compute all the
                   eigenvalues; elements 1:ILO-1 and i+1:N of W
                   contain those eigenvalues which have converged; if
                   JOBVS = 'V', VS contains the transformation which
                   reduces A to its partially converged Schur form.
             = N+1: the eigenvalues could not be reordered because some
                   eigenvalues were too close to separate (the problem
                   is very ill-conditioned);
             = N+2: after reordering, roundoff changed values of some
                   complex eigenvalues so that leading eigenvalues in
                   the Schur form no longer satisfy SELECT=.TRUE.  This
                   could also be caused by underflow due to scaling.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
June 2016

Definition at line 241 of file cgeesx.f.

241 *
242 * -- LAPACK driver routine (version 3.6.1) --
243 * -- LAPACK is a software package provided by Univ. of Tennessee, --
244 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
245 * June 2016
246 *
247 * .. Scalar Arguments ..
248  CHARACTER jobvs, sense, sort
249  INTEGER info, lda, ldvs, lwork, n, sdim
250  REAL rconde, rcondv
251 * ..
252 * .. Array Arguments ..
253  LOGICAL bwork( * )
254  REAL rwork( * )
255  COMPLEX a( lda, * ), vs( ldvs, * ), w( * ), work( * )
256 * ..
257 * .. Function Arguments ..
258  LOGICAL select
259  EXTERNAL SELECT
260 * ..
261 *
262 * =====================================================================
263 *
264 * .. Parameters ..
265  REAL zero, one
266  parameter ( zero = 0.0e0, one = 1.0e0 )
267 * ..
268 * .. Local Scalars ..
269  LOGICAL lquery, scalea, wantsb, wantse, wantsn, wantst,
270  $ wantsv, wantvs
271  INTEGER hswork, i, ibal, icond, ierr, ieval, ihi, ilo,
272  $ itau, iwrk, lwrk, maxwrk, minwrk
273  REAL anrm, bignum, cscale, eps, smlnum
274 * ..
275 * .. Local Arrays ..
276  REAL dum( 1 )
277 * ..
278 * .. External Subroutines ..
279  EXTERNAL ccopy, cgebak, cgebal, cgehrd, chseqr, clacpy,
281 * ..
282 * .. External Functions ..
283  LOGICAL lsame
284  INTEGER ilaenv
285  REAL clange, slamch
286  EXTERNAL lsame, ilaenv, clange, slamch
287 * ..
288 * .. Intrinsic Functions ..
289  INTRINSIC max, sqrt
290 * ..
291 * .. Executable Statements ..
292 *
293 * Test the input arguments
294 *
295  info = 0
296  wantvs = lsame( jobvs, 'V' )
297  wantst = lsame( sort, 'S' )
298  wantsn = lsame( sense, 'N' )
299  wantse = lsame( sense, 'E' )
300  wantsv = lsame( sense, 'V' )
301  wantsb = lsame( sense, 'B' )
302  lquery = ( lwork.EQ.-1 )
303 *
304  IF( ( .NOT.wantvs ) .AND. ( .NOT.lsame( jobvs, 'N' ) ) ) THEN
305  info = -1
306  ELSE IF( ( .NOT.wantst ) .AND. ( .NOT.lsame( sort, 'N' ) ) ) THEN
307  info = -2
308  ELSE IF( .NOT.( wantsn .OR. wantse .OR. wantsv .OR. wantsb ) .OR.
309  $ ( .NOT.wantst .AND. .NOT.wantsn ) ) THEN
310  info = -4
311  ELSE IF( n.LT.0 ) THEN
312  info = -5
313  ELSE IF( lda.LT.max( 1, n ) ) THEN
314  info = -7
315  ELSE IF( ldvs.LT.1 .OR. ( wantvs .AND. ldvs.LT.n ) ) THEN
316  info = -11
317  END IF
318 *
319 * Compute workspace
320 * (Note: Comments in the code beginning "Workspace:" describe the
321 * minimal amount of real workspace needed at that point in the
322 * code, as well as the preferred amount for good performance.
323 * CWorkspace refers to complex workspace, and RWorkspace to real
324 * workspace. NB refers to the optimal block size for the
325 * immediately following subroutine, as returned by ILAENV.
326 * HSWORK refers to the workspace preferred by CHSEQR, as
327 * calculated below. HSWORK is computed assuming ILO=1 and IHI=N,
328 * the worst case.
329 * If SENSE = 'E', 'V' or 'B', then the amount of workspace needed
330 * depends on SDIM, which is computed by the routine CTRSEN later
331 * in the code.)
332 *
333  IF( info.EQ.0 ) THEN
334  IF( n.EQ.0 ) THEN
335  minwrk = 1
336  lwrk = 1
337  ELSE
338  maxwrk = n + n*ilaenv( 1, 'CGEHRD', ' ', n, 1, n, 0 )
339  minwrk = 2*n
340 *
341  CALL chseqr( 'S', jobvs, n, 1, n, a, lda, w, vs, ldvs,
342  $ work, -1, ieval )
343  hswork = work( 1 )
344 *
345  IF( .NOT.wantvs ) THEN
346  maxwrk = max( maxwrk, hswork )
347  ELSE
348  maxwrk = max( maxwrk, n + ( n - 1 )*ilaenv( 1, 'CUNGHR',
349  $ ' ', n, 1, n, -1 ) )
350  maxwrk = max( maxwrk, hswork )
351  END IF
352  lwrk = maxwrk
353  IF( .NOT.wantsn )
354  $ lwrk = max( lwrk, ( n*n )/2 )
355  END IF
356  work( 1 ) = lwrk
357 *
358  IF( lwork.LT.minwrk .AND. .NOT.lquery ) THEN
359  info = -15
360  END IF
361  END IF
362 *
363  IF( info.NE.0 ) THEN
364  CALL xerbla( 'CGEESX', -info )
365  RETURN
366  ELSE IF( lquery ) THEN
367  RETURN
368  END IF
369 *
370 * Quick return if possible
371 *
372  IF( n.EQ.0 ) THEN
373  sdim = 0
374  RETURN
375  END IF
376 *
377 * Get machine constants
378 *
379  eps = slamch( 'P' )
380  smlnum = slamch( 'S' )
381  bignum = one / smlnum
382  CALL slabad( smlnum, bignum )
383  smlnum = sqrt( smlnum ) / eps
384  bignum = one / smlnum
385 *
386 * Scale A if max element outside range [SMLNUM,BIGNUM]
387 *
388  anrm = clange( 'M', n, n, a, lda, dum )
389  scalea = .false.
390  IF( anrm.GT.zero .AND. anrm.LT.smlnum ) THEN
391  scalea = .true.
392  cscale = smlnum
393  ELSE IF( anrm.GT.bignum ) THEN
394  scalea = .true.
395  cscale = bignum
396  END IF
397  IF( scalea )
398  $ CALL clascl( 'G', 0, 0, anrm, cscale, n, n, a, lda, ierr )
399 *
400 *
401 * Permute the matrix to make it more nearly triangular
402 * (CWorkspace: none)
403 * (RWorkspace: need N)
404 *
405  ibal = 1
406  CALL cgebal( 'P', n, a, lda, ilo, ihi, rwork( ibal ), ierr )
407 *
408 * Reduce to upper Hessenberg form
409 * (CWorkspace: need 2*N, prefer N+N*NB)
410 * (RWorkspace: none)
411 *
412  itau = 1
413  iwrk = n + itau
414  CALL cgehrd( n, ilo, ihi, a, lda, work( itau ), work( iwrk ),
415  $ lwork-iwrk+1, ierr )
416 *
417  IF( wantvs ) THEN
418 *
419 * Copy Householder vectors to VS
420 *
421  CALL clacpy( 'L', n, n, a, lda, vs, ldvs )
422 *
423 * Generate unitary matrix in VS
424 * (CWorkspace: need 2*N-1, prefer N+(N-1)*NB)
425 * (RWorkspace: none)
426 *
427  CALL cunghr( n, ilo, ihi, vs, ldvs, work( itau ), work( iwrk ),
428  $ lwork-iwrk+1, ierr )
429  END IF
430 *
431  sdim = 0
432 *
433 * Perform QR iteration, accumulating Schur vectors in VS if desired
434 * (CWorkspace: need 1, prefer HSWORK (see comments) )
435 * (RWorkspace: none)
436 *
437  iwrk = itau
438  CALL chseqr( 'S', jobvs, n, ilo, ihi, a, lda, w, vs, ldvs,
439  $ work( iwrk ), lwork-iwrk+1, ieval )
440  IF( ieval.GT.0 )
441  $ info = ieval
442 *
443 * Sort eigenvalues if desired
444 *
445  IF( wantst .AND. info.EQ.0 ) THEN
446  IF( scalea )
447  $ CALL clascl( 'G', 0, 0, cscale, anrm, n, 1, w, n, ierr )
448  DO 10 i = 1, n
449  bwork( i ) = SELECT( w( i ) )
450  10 CONTINUE
451 *
452 * Reorder eigenvalues, transform Schur vectors, and compute
453 * reciprocal condition numbers
454 * (CWorkspace: if SENSE is not 'N', need 2*SDIM*(N-SDIM)
455 * otherwise, need none )
456 * (RWorkspace: none)
457 *
458  CALL ctrsen( sense, jobvs, bwork, n, a, lda, vs, ldvs, w, sdim,
459  $ rconde, rcondv, work( iwrk ), lwork-iwrk+1,
460  $ icond )
461  IF( .NOT.wantsn )
462  $ maxwrk = max( maxwrk, 2*sdim*( n-sdim ) )
463  IF( icond.EQ.-14 ) THEN
464 *
465 * Not enough complex workspace
466 *
467  info = -15
468  END IF
469  END IF
470 *
471  IF( wantvs ) THEN
472 *
473 * Undo balancing
474 * (CWorkspace: none)
475 * (RWorkspace: need N)
476 *
477  CALL cgebak( 'P', 'R', n, ilo, ihi, rwork( ibal ), n, vs, ldvs,
478  $ ierr )
479  END IF
480 *
481  IF( scalea ) THEN
482 *
483 * Undo scaling for the Schur form of A
484 *
485  CALL clascl( 'U', 0, 0, cscale, anrm, n, n, a, lda, ierr )
486  CALL ccopy( n, a, lda+1, w, 1 )
487  IF( ( wantsv .OR. wantsb ) .AND. info.EQ.0 ) THEN
488  dum( 1 ) = rcondv
489  CALL slascl( 'G', 0, 0, cscale, anrm, 1, 1, dum, 1, ierr )
490  rcondv = dum( 1 )
491  END IF
492  END IF
493 *
494  work( 1 ) = maxwrk
495  RETURN
496 *
497 * End of CGEESX
498 *
subroutine cunghr(N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO)
CUNGHR
Definition: cunghr.f:128
subroutine cgebak(JOB, SIDE, N, ILO, IHI, SCALE, M, V, LDV, INFO)
CGEBAK
Definition: cgebak.f:133
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:145
subroutine slascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition: slascl.f:145
subroutine slabad(SMALL, LARGE)
SLABAD
Definition: slabad.f:76
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:117
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
subroutine ctrsen(JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M, S, SEP, WORK, LWORK, INFO)
CTRSEN
Definition: ctrsen.f:266
subroutine chseqr(JOB, COMPZ, N, ILO, IHI, H, LDH, W, Z, LDZ, WORK, LWORK, INFO)
CHSEQR
Definition: chseqr.f:301
subroutine cgebal(JOB, N, A, LDA, ILO, IHI, SCALE, INFO)
CGEBAL
Definition: cgebal.f:163
subroutine clacpy(UPLO, M, N, A, LDA, B, LDB)
CLACPY copies all or part of one two-dimensional array to another.
Definition: clacpy.f:105
integer function ilaenv(ISPEC, NAME, OPTS, N1, N2, N3, N4)
Definition: tstiee.f:83
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
Definition: ccopy.f:52
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69
subroutine cgehrd(N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO)
CGEHRD
Definition: cgehrd.f:169
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55

Here is the call graph for this function:

Here is the caller graph for this function: