# ?gees

Computes the eigenvalues and Schur factorization of a general matrix, and orders the factorization so that selected eigenvalues are at the top left of the Schur form.

## Syntax

FORTRAN 77:

call sgees(jobvs, sort, select, n, a, lda, sdim, wr, wi, vs, ldvs, work, lwork, bwork, info)

call dgees(jobvs, sort, select, n, a, lda, sdim, wr, wi, vs, ldvs, work, lwork, bwork, info)

call cgees(jobvs, sort, select, n, a, lda, sdim, w, vs, ldvs, work, lwork, rwork, bwork, info)

call zgees(jobvs, sort, select, n, a, lda, sdim, w, vs, ldvs, work, lwork, rwork, bwork, info)

Fortran 95:

call gees(a, wr, wi [,vs] [,select] [,sdim] [,info])

call gees(a, w [,vs] [,select] [,sdim] [,info])

## Description

This routine computes for an n-by-n real/complex nonsymmetric matrix A, the eigenvalues, the real Schur form T, and, optionally, the matrix of Schur vectors Z. This gives the Schur factorization `A = Z*T*ZH`.

Optionally, it also orders the eigenvalues on the diagonal of the real-Schur/Schur form so that selected eigenvalues are at the top left. The leading columns of Z then form an orthonormal basis for the invariant subspace corresponding to the selected eigenvalues.

A real matrix is in real-Schur form if it is upper quasi-triangular with 1-by-1 and 2-by-2 blocks. 2-by-2 blocks will be standardized in the form

where `b*c < 0`. The eigenvalues of such a block are

A complex matrix is in Schur form if it is upper triangular.

## Input Parameters

jobvs

  CHARACTER*1. Must be 'N' or 'V'.

  If `jobvs = 'N'`, then Schur vectors are not computed.

  If `jobvs = 'V'`, then Schur vectors are computed.

sort

  CHARACTER*1. Must be 'N' or 'S'. Specifies whether or not to order the eigenvalues on the diagonal of the Schur form.

  If `sort = 'N'`, then eigenvalues are not ordered.

  If `sort = 'S'`, eigenvalues are ordered (see select).

select

  LOGICAL FUNCTION of two REAL arguments for real flavors.

  LOGICAL FUNCTION of one COMPLEX argument for complex flavors.

  select must be declared EXTERNAL in the calling subroutine.

  If `sort = 'S'`, select is used to select eigenvalues to sort to the top left of the Schur form.

  If `sort = 'N'`, select is not referenced.

  For real flavors:

  An eigenvalue wr(j)`+sqrt(-1)*`wi(j) is selected if select(wr(j), wi(j)) is true; that is, if either one of a complex conjugate pair of eigenvalues is selected, then both complex eigenvalues are selected.

  Note that a selected complex eigenvalue may no longer satisfy select(wr(j), wi(j))= .TRUE. after ordering, since ordering may change the value of complex eigenvalues (especially if the eigenvalue is ill-conditioned); in this case info may be set to n+2 (see info below).

  For complex flavors:

  An eigenvalue w(j) is selected if select(w(j)) is true.

n

  INTEGER. The order of the matrix A (`n ≥ 0`).

a, work

  REAL for sgees

  DOUBLE PRECISION for dgees

  COMPLEX for cgees

  DOUBLE COMPLEX for zgees.

  Arrays:

  a(lda,*) is an array containing the n-by-n matrix A.

  The second dimension of a must be at least max(1, n).

  work is a workspace array, its dimension `max(1, lwork)`.
lda

  INTEGER. The first dimension of the array a. Must be at least max(1, n).

ldvs

  INTEGER. The leading dimension of the output array vs. Constraints:

  `ldvs ≥ 1`;

  `ldvs ≥ max(1, n)` if `jobvs = 'V'`.

lwork

  INTEGER.

  The dimension of the array work.

  Constraint:

  `lwork ≥ max(1, 3n)` for real flavors;

  `lwork ≥ max(1, 2n)` for complex flavors.

  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.

rwork

  REAL for cgees

  DOUBLE PRECISION for zgees

  Workspace array, DIMENSION at least max(1, n). Used in complex flavors only.

bwork

  LOGICAL. Workspace array, DIMENSION at least max(1, n). Not referenced if `sort = 'N'`.

## Output Parameters

a

  On exit, this array is overwritten by the real-Schur/Schur form T.

sdim

  INTEGER.

  If `sort = 'N'`, `sdim= 0`.

  If `sort = 'S'`, sdim is equal to the number of eigenvalues (after sorting) for which select is true.

  Note that for real flavors complex conjugate pairs for which select is true for either eigenvalue count as 2.

wr, wi

  REAL for sgees

  DOUBLE PRECISION for dgees

  Arrays, DIMENSION at least max (1, n) each. Contain the real and imaginary parts, respectively, of the computed eigenvalues, in the same order that they appear on the diagonal of the output real-Schur form T. Complex conjugate pairs of eigenvalues appear consecutively with the eigenvalue having positive imaginary part first.

w

  COMPLEX for cgees

  DOUBLE COMPLEX for zgees.

  Array, DIMENSION at least max(1, n). Contains the computed eigenvalues. The eigenvalues are stored in the same order as they appear on the diagonal of the output Schur form T.

vs

  REAL for sgees

  DOUBLE PRECISION for dgees

  COMPLEX for cgees

  DOUBLE COMPLEX for zgees.

  Array vs(ldvs,*);the second dimension of vs must be at least max(1, n).

  If `jobvs = 'V'`, vs contains the orthogonal/unitary matrix Z of Schur vectors.

  If `jobvs = 'N'`, vs is not referenced.

work(1)

  On exit, if `info = 0`, then work(1) returns the required minimal size of lwork.

info

  INTEGER.

  If `info = 0`, the execution is successful.

  If `info = -i`, the ith parameter had an illegal value.

  If `info = i`, and

  `i ≤ n`:

  the QR algorithm failed to compute all the eigenvalues; elements 1:ilo-1 and i+1:n of wr and wi (for real flavors) or w (for complex flavors) contain those eigenvalues which have converged; if `jobvs = 'V'`, vs contains the matrix which reduces A to its partially converged Schur form;

  `i = n+1`:

  the eigenvalues could not be reordered because some eigenvalues were too close to separate (the problem is very ill-conditioned);

  i = n+2:

  after reordering, round-off 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.

## Fortran 95 Interface Notes

Routines in Fortran 95 interface have fewer arguments in the calling sequence than their FORTRAN 77 counterparts. For general conventions applied to skip redundant or restorable arguments, see Fortran 95 Interface Conventions.

Specific details for the routine gees interface are the following:

a

  Holds the matrix A of size (n, n).

wr

  Holds the vector of length (n). Used in real flavors only.

wi

  Holds the vector of length (n). Used in real flavors only.

w

  Holds the vector of length (n). Used in complex flavors only.

vs

  Holds the matrix VS of size (n, n).

jobvs

  Restored based on the presence of the argument vs as follows:

  `jobvs = 'V'`, if vs is present,

  `jobvs = 'N'`, if vs is omitted.

sort

  Restored based on the presence of the argument select as follows:

  `sort = 'S'`, if select is present,

  `sort = 'N'`, if select is omitted.

## Application Notes

If you are in doubt how much workspace to supply, use a generous value of lwork for the first run or set `lwork = -1`.

If you choose the first option and set any of admissible lwork sizes, which is no less than the minimal value described, the routine completes the task, though probably not so fast as with a recommended workspace, and provides the recommended workspace in the first element of the corresponding array work on exit. Use this value (`work(1)`) for subsequent runs.

If you set `lwork = -1`, the routine returns immediately and provides the recommended workspace in the first element of the corresponding array (work). This operation is called a workspace query.

Note that if you set lwork to less than the minimal required value and not -1, the routine returns immediately with an error exit and does not provide any information on the recommended workspace.

Parent topic: Nonsymmetric Eigenproblems