# ?geevx

Computes the eigenvalues and left and right eigenvectors of a general matrix, with preliminary matrix balancing, and computes reciprocal condition numbers for the eigenvalues and right eigenvectors.

## Syntax

FORTRAN 77:

call sgeevx(balanc, jobvl, jobvr, sense, n, a, lda, wr, wi, vl, ldvl, vr, ldvr, ilo, ihi, scale, abnrm, rconde, rcondv, work, lwork, iwork, info)

call dgeevx(balanc, jobvl, jobvr, sense, n, a, lda, wr, wi, vl, ldvl, vr, ldvr, ilo, ihi, scale, abnrm, rconde, rcondv, work, lwork, iwork, info)

call cgeevx(balanc, jobvl, jobvr, sense, n, a, lda, w, vl, ldvl, vr, ldvr, ilo, ihi, scale, abnrm, rconde, rcondv, work, lwork, rwork, info)

call zgeevx(balanc, jobvl, jobvr, sense, n, a, lda, w, vl, ldvl, vr, ldvr, ilo, ihi, scale, abnrm, rconde, rcondv, work, lwork, rwork, info)

Fortran 95:

call geevx(a, wr, wi [,vl] [,vr] [,balanc] [,ilo] [,ihi] [,scale] [,abnrm] [, rconde] [,rcondv] [,info])

call geevx(a, w [,vl] [,vr] [,balanc] [,ilo] [,ihi] [,scale] [,abnrm] [,rconde] [, rcondv] [,info])

## Description

This routine computes for an n-by-n real/complex nonsymmetric matrix A, the eigenvalues and, optionally, the left and/or right eigenvectors.

Optionally also, it computes a balancing transformation to improve the conditioning of the eigenvalues and eigenvectors (ilo, ihi, scale, and abnrm), reciprocal condition numbers for the eigenvalues (rconde), and reciprocal condition numbers for the right eigenvectors (rcondv).

The right eigenvector `v(j)` of A satisfies

`A*v(j) = λ(j)*v(j)`

where `λ(j)` is its eigenvalue.

The left eigenvector `u(j)` of A satisfies

`u(j)H*A = λ(j)*u(j)H`

where `u(j)H` denotes the conjugate transpose of `u(j)`. The computed eigenvectors are normalized to have Euclidean norm equal to 1 and largest component real.

Balancing a matrix means permuting the rows and columns to make it more nearly upper triangular, and applying a diagonal similarity transformation D*A*inv(D), where D is a diagonal matrix, to make its rows and columns closer in norm and the condition numbers of its eigenvalues and eigenvectors smaller. The computed reciprocal condition numbers correspond to the balanced matrix. Permuting rows and columns will not change the condition numbers in exact arithmetic) but diagonal scaling will. For further explanation of balancing, see [LUG], Section 4.10.

## Input Parameters

balanc

  CHARACTER*1. Must be 'N', 'P', 'S', or 'B'. Indicates how the input matrix should be diagonally scaled and/or permuted to improve the conditioning of its eigenvalues.

  If `balanc = 'N'`, do not diagonally scale or permute;

  If `balanc = 'P'`, perform permutations to make the matrix more nearly upper triangular. Do not diagonally scale;

  If `balanc = 'S'`, diagonally scale the matrix, i.e. replace A by D*A*`inv(D)`, where D is a diagonal matrix chosen to make the rows and columns of A more equal in norm. Do not permute;

  If `balanc = 'B'`, both diagonally scale and permute A.

  Computed reciprocal condition numbers will be for the matrix after balancing and/or permuting. Permuting does not change condition numbers (in exact arithmetic), but balancing does.

jobvl

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

  If `jobvl = 'N'`, left eigenvectors of A are not computed;

  If `jobvl = 'V'`, left eigenvectors of A are computed.

  If `sense = 'E'` or 'B', then jobvl must be 'V'.

jobvr

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

  If `jobvr = 'N'`, right eigenvectors of A are not computed;

  If `jobvr = 'V'`, right eigenvectors of A are computed.

  If `sense = 'E'` or 'B', then jobvr must be 'V'.

sense

  CHARACTER*1. Must be 'N', 'E', 'V', or 'B'. Determines which reciprocal condition number are computed.

  If `sense = 'N'`, none are computed;

  If `sense = 'E'`, computed for eigenvalues only;

  If `sense = 'V'`, computed for right eigenvectors only;

  If `sense = 'B'`, computed for eigenvalues and right eigenvectors.

  If sense is 'E' or 'B', both left and right eigenvectors must also be computed (`jobvl = 'V'` and `jobvr = 'V'`).

n

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

a, work

  REAL for sgeevx

  DOUBLE PRECISION for dgeevx

  COMPLEX for cgeevx

  DOUBLE COMPLEX for zgeevx.

  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).

ldvl, ldvr

  INTEGER. The leading dimensions of the output arrays vl and vr, respectively.

  Constraints:

  `ldvl ≥ 1`; `ldvr ≥ 1`.

  If `jobvl = 'V'`, `ldvl ≥ max`(1, n);

  If `jobvr = 'V'`, `ldvr ≥ max`(1, n).

lwork

  INTEGER.

  The dimension of the array work.

  For real flavors:

  If `sense = 'N'` or 'E', `lwork ≥ max(1, 2n)`, and if `jobvl = 'V'` or `jobvr = 'V'`, `lwork ≥ 3n`;

  If `sense = 'V'` or 'B', `lwork ≥ n*(n+6)`.

  For good performance, lwork must generally be larger.

  For complex flavors:

  If `sense = 'N'`or 'E', `lwork ≥ max`(1, 2n);

  If `sense = 'V'` or 'B', `lwork ≥ n2+2n`. 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.

rwork

  REAL for cgeevx

  DOUBLE PRECISION for zgeevx

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

iwork

  INTEGER.

  Workspace array, DIMENSION at least max(1, 2n-2). Used in real flavors only. Not referenced if `sense = 'N'` or 'E'.

## Output Parameters

a

  On exit, this array is overwritten.

  If `jobvl = 'V'` or `jobvr = 'V'`, it contains the real-Schur/Schur form of the balanced version of the input matrix A.

wr, wi

  REAL for sgeevx

  DOUBLE PRECISION for dgeevx

  Arrays, DIMENSION at least max (1, n) each. Contain the real and imaginary parts, respectively, of the computed eigenvalues. Complex conjugate pairs of eigenvalues appear consecutively with the eigenvalue having positive imaginary part first.

w

  COMPLEX for cgeevx

  DOUBLE COMPLEX for zgeevx.

  Array, DIMENSION at least max(1, n). Contains the computed eigenvalues.

vl, vr

  REAL for sgeevx

  DOUBLE PRECISION for dgeevx

  COMPLEX for cgeevx

  DOUBLE COMPLEX for zgeevx.

  Arrays:

  vl(ldvl,*); the second dimension of vl must be at least max(1, n).

  If `jobvl = 'V'`, the left eigenvectors u(j) are stored one after another in the columns of vl, in the same order as their eigenvalues.

  If `jobvl = 'N'`, vl is not referenced.

  For real flavors:

  If the j-th eigenvalue is real, then `u(j) = vl(:,j)`, the j-th column of vl.

  If the j-th and (j+1)-st eigenvalues form a complex conjugate pair, then `u(j) = vl(:,j) + i*vl(:,j+1)` and `(j+1) = vl(:,j) - i*vl(:,j+1)`, where `i = sqrt(-1)`.

  For complex flavors:

  `u(j) = vl(:,j)`, the j-th column of vl.

  vr(ldvr,*); the second dimension of vr must be at least max(1, n).

  If `jobvr = 'V'`, the right eigenvectors v(j) are stored one after another in the columns of vr, in the same order as their eigenvalues.

  If `jobvr = 'N'`, vr is not referenced.

  For real flavors:

  If the j-th eigenvalue is real, then `v(j) = vr(:,j)`, the j-th column of vr.

  If the j-th and (j+1)-st eigenvalues form a complex conjugate pair, then `v(j) = vr(:,j) + i*vr(:,j+1)` and `v(j+1) = vr(:,j) - i*vr(:,j+1)`, where `i = sqrt(-1)` .

  For complex flavors:

  `v(j) = vr(:,j)`, the j-th column of vr.

ilo, ihi

  INTEGER. ilo and ihi are integer values determined when A was balanced.

  The balanced `A(i,j) = 0` if `i > j` and `j = 1,..., ilo-1` or `i = ihi+1,..., n`.

  If `balanc = 'N'` or 'S', `ilo = 1` and `ihi = n`.

scale

  REAL for single-precision flavors

  DOUBLE PRECISION for double-precision flavors.

  Array, DIMENSION at least max(1, n). Details of the permutations and scaling factors applied when balancing A.

  If P(j) is the index of the row and column interchanged with row and column j, and D(j) is the scaling factor applied to row and column j, then

  `scale(j) = P(j)`, for `j = 1,...,ilo-1`

  `= D(j)`, for `j = ilo,...,ihi`

  `= P(j)` for `j = ihi+1,..., n`.

  The order in which the interchanges are made is n to ihi+1, then 1 to ilo-1.

abnrm

  REAL for single-precision flavors

  DOUBLE PRECISION for double-precision flavors.

  The one-norm of the balanced matrix (the maximum of the sum of absolute values of elements of any column).

rconde, rcondv

  REAL for single precision flavors DOUBLE PRECISION for double precision flavors.

  Arrays, DIMENSION at least max(1, n) each.

  rconde(j) is the reciprocal condition number of the j-th eigenvalue.

  rcondv(j) is the reciprocal condition number of the j-th right eigenvector.

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`, the QR algorithm failed to compute all the eigenvalues, and no eigenvectors or condition numbers have been computed; elements 1:ilo-1 and i+1:n of wr and wi (for real flavors) or w (for complex flavors) contain eigenvalues which have converged.

## 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 geevx 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.

vl

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

vr

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

scale

  Holds the vector of length (n).

rconde

  Holds the vector of length (n).

rcondv

  Holds the vector of length (n).

balanc

  Must be 'N', 'B', 'P' or 'S'. The default value is 'N'.

jobvl

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

  `jobvl = 'V'`, if vl is present,

  `jobvl = 'N'`, if vl is omitted.

jobvr

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

  `jobvr = 'V'`, if vr is present,

  `jobvr = 'N'`, if vr is omitted.

sense

  Restored based on the presence of arguments rconde and rcondv as follows:

  `sense = 'B'`, if both rconde and rcondv are present,

  `sense = 'E'`, if rconde is present and rcondv omitted,

  `sense = 'V'`, if rconde is omitted and rcondv present,

  `sense = 'N'`, if both rconde and rcondv are 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