Routines (alphabetical) > Routines: L > LA_EIGENPROBLEM

# LA_EIGENPROBLEM

The LA_EIGENPROBLEM function uses the QR algorithm to compute all eigenvalues λ and eigenvectors v ≠ 0 of an n-by-n real nonsymmetric or complex non-Hermitian array A, for the eigenproblem Av = λv. The routine can also compute the left eigenvectors u ≠ 0, which satisfy uHA = λuH.

LA_EIGENPROBLEM may also be used for the generalized eigenproblem:

Av = λBv and uHA = λuHB

where A and B are square arrays, v are the right eigenvectors, and u are the left eigenvectors.

LA_EIGENPROBLEM is based on the following LAPACK routines:

Output Type | Standard LAPACK Routine | Generalized LAPACK Routine
Float | sgeevx | sggevx
Double | dgeevx | dggevx
Complex | cgeevx | cggevx
Double complex | zgeevx | zggevx

## Examples

Find the eigenvalues and eigenvectors for an array using the following program:

PRO ExLA_EIGENPROBLEM

; Create a random array:

n = 4

seed = 12321

array = RANDOMN(seed, n, n)

; Compute all eigenvalues and eigenvectors:

eigenvalues = LA_EIGENPROBLEM(array, $

EIGENVECTORS = eigenvectors)

PRINT, 'LA_EIGENPROBLEM Eigenvalues:'

PRINT, eigenvalues

; Check the results using the eigenvalue equation:

maxErr = 0d

FOR i = 0, n - 1 DO BEGIN

; A*z = lambda*z

alhs = array ## eigenvectors[*,i]

arhs = eigenvalues[i]*eigenvectors[*,i]

maxErr = maxErr > MAX(ABS(alhs - arhs))

ENDFOR

PRINT, 'LA_EIGENPROBLEM Error:', maxErr

; Now try the generalized eigenproblem:

b = IDENTITY(n) + 0.01*RANDOMN(seed, n, n)

eigenvalues = LA_EIGENPROBLEM(Array, B)

PRINT, 'LA_EIGENPROBLEM Generalized Eigenvalues:'

PRINT, EIGENVALUES

END

ExLA_EIGENPROBLEM

When this program is compiled and run, IDL prints:

LA_EIGENPROBLEM Eigenvalues:

( -1.50248, 0.592900)( -1.50248, -0.592900)( 1.99779, 0.000000)( 1.06499, 0.000000)

LA_EIGENPROBLEM Error: 9.5367432e-007

LA_EIGENPROBLEM Generalized Eigenvalues:

( -1.51732, 0.591994)( -1.51732, -0.591994)( 2.02658, 0.000000)( 1.04831, 0.000000)

## Syntax

Result = LA_EIGENPROBLEM( A [, B] [, ALPHA=variable] [, BALANCE=value] [, BETA=variable] [, /DOUBLE] [, EIGENVECTORS=variable] [, LEFT_EIGENVECTORS=variable] [, NORM_BALANCE = variable] [, PERMUTE_RESULT=variable] [, SCALE_RESULT=variable] [, RCOND_VALUE=variable] [, RCOND_VECTOR=variable] [, STATUS=variable] )

## Return Value

The result is a complex n-element vector containing the eigenvalues.

## Arguments

### A

The real or complex array for which to compute eigenvalues and eigenvectors.

### B

An optional real or complex n-by-n array used for the generalized eigenproblem. The elements of B are converted to the same type as A before computation.

## Keywords

### ALPHA

For the generalized eigenproblem with the B argument, set this keyword to a named variable in which the numerator of the eigenvalues will be returned as a complex n -element vector. For the standard eigenproblem this keyword is ignored.

Tip: The ALPHA and BETA values are useful for eigenvalues which underflow or overflow. In this case the eigenvalue problem may be rewritten as αAv = βBv.

### BALANCE

Set this keyword to one of the following values:

- BALANCE = 0: No balancing is applied to A.
- BALANCE = 1: Both permutation and scale balancing are performed.
- BALANCE = 2: Permutations are performed to make the array more nearly upper triangular.
- BALANCE = 3: Diagonally scale the array to make the columns and rows more equal in norm.

The default is BALANCE = 1, which performs both permutation and scaling balances. Balancing a nonsymmetric (or non-Hermitian) array is recommended to reduce the sensitivity of eigenvalues to rounding errors.

### BETA

For the generalized eigenproblem with the B argument, set this keyword to a named variable in which the denominator of the eigenvalues will be returned as a real or complex n-element vector. For the standard eigenproblem this keyword is ignored.

Tip: The ALPHA and BETA values are useful for eigenvalues which underflow or overflow. In this case, the eigenvalue problem may be rewritten as αAv = βBv.

### DOUBLE

Set this keyword to use double-precision for computations and to return a double-precision (real or complex) result. Set DOUBLE = 0 to use single-precision for computations and to return a single-precision (real or complex) result. The default is /DOUBLE if A is double precision, otherwise the default is DOUBLE = 0.

### EIGENVECTORS

Set this keyword to a named variable in which the eigenvectors will be returned as a set of row vectors. If this variable is omitted then eigenvectors will not be computed unless the RCOND_VALUE or RCOND_VECTOR keywords are present.

Note: For the standard eigenproblem the eigenvectors are normalized and rotated to have norm 1 and largest component real. For the generalized eigenproblem the eigenvectors are normalized so that the largest component has abs(real) + abs(imaginary) = 1.

### LEFT_EIGENVECTORS

Set this keyword to a named variable in which the left eigenvectors will be returned as a set of row vectors. If this variable is omitted then left eigenvectors will not be computed unless the RCOND_VALUE or RCOND_VECTOR keywords are present.

Note: Note - For the standard eigenproblem the eigenvectors are normalized and rotated to have norm 1 and largest component real. For the generalized eigenproblem the eigenvectors are normalized so that the largest component has abs(real) + abs(imaginary) = 1.

### NORM_BALANCE

Set this keyword to a named variable in which the one-norm of the balanced matrix will be returned. The one-norm is defined as the maximum value of the sum of absolute values of the columns. For the standard eigenproblem, this will be returned as a scalar value; for the generalized eigenproblem this will be returned as a two-element vector containing the A and B norms.

### PERMUTE_RESULT

Set this keyword to a named variable in which the result for permutation balancing will be returned as a two-element vector [ilo, ihi]. If permute balancing is not done then the values will be ilo = 1 and ihi = n.

### RCOND_VALUE

Set this keyword to a named variable in which the reciprocal condition numbers for the eigenvalues will be returned as an n-element vector. If RCOND_VALUE is present then left and right eigenvectors must be computed.

### RCOND_VECTOR

Set this keyword to a named variable in which the reciprocal condition numbers for the eigenvectors will be returned as an n-element vector. If RCOND_VECTOR is present then left and right eigenvectors must be computed.

### SCALE_RESULT

Set this keyword to a named variable in which the results for permute and scale balancing will be returned. For the standard eigenproblem, this will be returned as an n-element vector. For the generalized eigenproblem, this will be returned as a n-by-2 array with the first row containing the permute and scale factors for the left side of A and B and the second row containing the factors for the right side of A and B.

### STATUS

Set this keyword to a named variable that will contain the status of the computation. Possible values are:

- STATUS = 0: The computation was successful.
- STATUS > 0: The QR algorithm failed to compute all eigenvalues; no eigenvectors or condition numbers were computed. The STATUS value indicates that eigenvalues ilo:STATUS (starting at index 1) did not converge; all other eigenvalues converged.

Note: If STATUS is not specified, any error messages will be output to the screen.

## Version History

5.6 | Introduced

## Resources and References

For details see Anderson et al., LAPACK Users' Guide, 3rd ed., SIAM, 1999.

## See Also

LA_EIGENVEC, LA_ELMHES, LA_HQR