F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08YKF (DTGEVC)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F08YKF (DTGEVC) computes some or all of the right and/or left generalized eigenvectors of a pair of real matrices $\left(A,B\right)$ which are in generalized real Schur form.

## 2  Specification

 SUBROUTINE F08YKF ( SIDE, HOWMNY, SELECT, N, A, LDA, B, LDB, VL, LDVL, VR, LDVR, MM, M, WORK, INFO)
 INTEGER N, LDA, LDB, LDVL, LDVR, MM, M, INFO REAL (KIND=nag_wp) A(LDA,*), B(LDB,*), VL(LDVL,*), VR(LDVR,*), WORK(6*N) LOGICAL SELECT(*) CHARACTER(1) SIDE, HOWMNY
The routine may be called by its LAPACK name dtgevc.

## 3  Description

F08YKF (DTGEVC) computes some or all of the right and/or left generalized eigenvectors of the matrix pair $\left(A,B\right)$ which is assumed to be in generalized upper Schur form. If the matrix pair $\left(A,B\right)$ is not in the generalized upper Schur form, then F08XEF (DHGEQZ) should be called before invoking F08YKF (DTGEVC).
The right generalized eigenvector $x$ and the left generalized eigenvector $y$ of $\left(A,B\right)$ corresponding to a generalized eigenvalue $\lambda$ are defined by
 $A-λBx=0$
and
 $yH A-λ B=0.$
If a generalized eigenvalue is determined as $0/0$, which is due to zero diagonal elements at the same locations in both $A$ and $B$, a unit vector is returned as the corresponding eigenvector.
Note that the generalized eigenvalues are computed using F08XEF (DHGEQZ) but F08YKF (DTGEVC) does not explicitly require the generalized eigenvalues to compute eigenvectors. The ordering of the eigenvectors is based on the ordering of the eigenvalues as computed by F08YKF (DTGEVC).
If all eigenvectors are requested, the routine may either return the matrices $X$ and/or $Y$ of right or left eigenvectors of $\left(A,B\right)$, or the products $ZX$ and/or $QY$, where $Z$ and $Q$ are two matrices supplied by you. Usually, $Q$ and $Z$ are chosen as the orthogonal matrices returned by F08XEF (DHGEQZ). Equivalently, $Q$ and $Z$ are the left and right Schur vectors of the matrix pair supplied to F08XEF (DHGEQZ). In that case, $QY$ and $ZX$ are the left and right generalized eigenvectors, respectively, of the matrix pair supplied to F08XEF (DHGEQZ).
$A$ must be block upper triangular; with $1$ by $1$ and $2$ by $2$ diagonal blocks. Corresponding to each $2$ by $2$ diagonal block is a complex conjugate pair of eigenvalues and eigenvectors; only one eigenvector of the pair is computed, namely the one corresponding to the eigenvalue with positive imaginary part. Each $1$ by $1$ block gives a real generalized eigenvalue and a corresponding eigenvector.

## 4  References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Moler C B and Stewart G W (1973) An algorithm for generalized matrix eigenproblems SIAM J. Numer. Anal. 10 241–256
Stewart G W and Sun J-G (1990) Matrix Perturbation Theory Academic Press, London

## 5  Parameters

1:     SIDE – CHARACTER(1)Input
On entry: specifies the required sets of generalized eigenvectors.
${\mathbf{SIDE}}=\text{'R'}$
Only right eigenvectors are computed.
${\mathbf{SIDE}}=\text{'L'}$
Only left eigenvectors are computed.
${\mathbf{SIDE}}=\text{'B'}$
Both left and right eigenvectors are computed.
Constraint: ${\mathbf{SIDE}}=\text{'B'}$, $\text{'L'}$ or $\text{'R'}$.
2:     HOWMNY – CHARACTER(1)Input
On entry: specifies further details of the required generalized eigenvectors.
${\mathbf{HOWMNY}}=\text{'A'}$
All right and/or left eigenvectors are computed.
${\mathbf{HOWMNY}}=\text{'B'}$
All right and/or left eigenvectors are computed; they are backtransformed using the input matrices supplied in arrays VR and/or VL.
${\mathbf{HOWMNY}}=\text{'S'}$
Selected right and/or left eigenvectors, defined by the array SELECT, are computed.
Constraint: ${\mathbf{HOWMNY}}=\text{'A'}$, $\text{'B'}$ or $\text{'S'}$.
3:     SELECT($*$) – LOGICAL arrayInput
Note: the dimension of the array SELECT must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{HOWMNY}}=\text{'S'}$, and at least $1$ otherwise.
On entry: specifies the eigenvectors to be computed if ${\mathbf{HOWMNY}}=\text{'S'}$. To select the generalized eigenvector corresponding to the $j$th generalized eigenvalue, the $j$th element of SELECT should be set to .TRUE.; if the eigenvalue corresponds to a complex conjugate pair, then real and imaginary parts of eigenvectors corresponding to the complex conjugate eigenvalue pair will be computed.
Constraint: ${\mathbf{SELECT}}\left(\mathit{j}\right)=\mathrm{.TRUE.}$ or $\mathrm{.FALSE.}$, for $\mathit{j}=1,2,\dots ,n$.
4:     N – INTEGERInput
On entry: $n$, the order of the matrices $A$ and $B$.
Constraint: ${\mathbf{N}}\ge 0$.
5:     A(LDA,$*$) – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array A must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the matrix pair $\left(A,B\right)$ must be in the generalized Schur form. Usually, this is the matrix $A$ returned by F08XEF (DHGEQZ).
6:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08YKF (DTGEVC) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
7:     B(LDB,$*$) – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array B must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the matrix pair $\left(A,B\right)$ must be in the generalized Schur form. If $A$ has a $2$ by $2$ diagonal block then the corresponding $2$ by $2$ block of $B$ must be diagonal with positive elements. Usually, this is the matrix $B$ returned by F08XEF (DHGEQZ).
8:     LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F08YKF (DTGEVC) is called.
Constraint: ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
9:     VL(LDVL,$*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array VL must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{MM}}\right)$ if ${\mathbf{SIDE}}=\text{'L'}$ or $\text{'B'}$ and at least $1$ if ${\mathbf{SIDE}}=\text{'R'}$.
On entry: if ${\mathbf{HOWMNY}}=\text{'B'}$ and ${\mathbf{SIDE}}=\text{'L'}$ or $\text{'B'}$, VL must be initialized to an $n$ by $n$ matrix $Q$. Usually, this is the orthogonal matrix $Q$ of left Schur vectors returned by F08XEF (DHGEQZ).
On exit: if ${\mathbf{SIDE}}=\text{'L'}$ or $\text{'B'}$, VL contains:
• if ${\mathbf{HOWMNY}}=\text{'A'}$, the matrix $Y$ of left eigenvectors of $\left(A,B\right)$;
• if ${\mathbf{HOWMNY}}=\text{'B'}$, the matrix $QY$;
• if ${\mathbf{HOWMNY}}=\text{'S'}$, the left eigenvectors of $\left(A,B\right)$ specified by SELECT, stored consecutively in the columns of the array VL, in the same order as their corresponding eigenvalues.
A complex eigenvector corresponding to a complex eigenvalue is stored in two consecutive columns, the first holding the real part, and the second the imaginary part.
10:   LDVL – INTEGERInput
On entry: the first dimension of the array VL as declared in the (sub)program from which F08YKF (DTGEVC) is called.
Constraints:
• if ${\mathbf{SIDE}}=\text{'L'}$ or $\text{'B'}$, ${\mathbf{LDVL}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• if ${\mathbf{SIDE}}=\text{'R'}$, ${\mathbf{LDVL}}\ge 1$.
11:   VR(LDVR,$*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array VR must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{MM}}\right)$ if ${\mathbf{SIDE}}=\text{'R'}$ or $\text{'B'}$ and at least $1$ if ${\mathbf{SIDE}}=\text{'L'}$.
On entry: if ${\mathbf{HOWMNY}}=\text{'B'}$ and ${\mathbf{SIDE}}=\text{'R'}$ or $\text{'B'}$, VR must be initialized to an $n$ by $n$ matrix $Z$. Usually, this is the orthogonal matrix $Z$ of right Schur vectors returned by F08XEF (DHGEQZ).
On exit: if ${\mathbf{SIDE}}=\text{'R'}$ or $\text{'B'}$, VR contains:
• if ${\mathbf{HOWMNY}}=\text{'A'}$, the matrix $X$ of right eigenvectors of $\left(A,B\right)$;
• if ${\mathbf{HOWMNY}}=\text{'B'}$, the matrix $ZX$;
• if ${\mathbf{HOWMNY}}=\text{'S'}$, the right eigenvectors of $\left(A,B\right)$ specified by SELECT, stored consecutively in the columns of the array VR, in the same order as their corresponding eigenvalues.
A complex eigenvector corresponding to a complex eigenvalue is stored in two consecutive columns, the first holding the real part, and the second the imaginary part.
12:   LDVR – INTEGERInput
On entry: the first dimension of the array VR as declared in the (sub)program from which F08YKF (DTGEVC) is called.
Constraints:
• if ${\mathbf{SIDE}}=\text{'R'}$ or $\text{'B'}$, ${\mathbf{LDVR}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• if ${\mathbf{SIDE}}=\text{'L'}$, ${\mathbf{LDVR}}\ge 1$.
13:   MM – INTEGERInput
On entry: the number of columns in the arrays VL and/or VR.
Constraints:
• if ${\mathbf{HOWMNY}}=\text{'A'}$ or $\text{'B'}$, ${\mathbf{MM}}\ge {\mathbf{N}}$;
• if ${\mathbf{HOWMNY}}=\text{'S'}$, MM must not be less than the number of requested eigenvectors.
14:   M – INTEGEROutput
On exit: the number of columns in the arrays VL and/or VR actually used to store the eigenvectors. If ${\mathbf{HOWMNY}}=\text{'A'}$ or $\text{'B'}$, M is set to N. Each selected real eigenvector occupies one column and each selected complex eigenvector occupies two columns.
15:   WORK($6×{\mathbf{N}}$) – REAL (KIND=nag_wp) arrayWorkspace
16:   INFO – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

Errors or warnings detected by the routine:
${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.
${\mathbf{INFO}}>0$
If ${\mathbf{INFO}}=i$, the $2$ by $2$ block $\left({\mathbf{INFO}}:{\mathbf{INFO}}+1\right)$ does not have complex eigenvalues.

## 7  Accuracy

It is beyond the scope of this manual to summarise the accuracy of the solution of the generalized eigenvalue problem. Interested readers should consult Section 4.11 of the LAPACK Users' Guide (see Anderson et al. (1999)) and Chapter 6 of Stewart and Sun (1990).

F08YKF (DTGEVC) is the sixth step in the solution of the real generalized eigenvalue problem and is called after F08XEF (DHGEQZ).
The complex analogue of this routine is F08YXF (ZTGEVC).

## 9  Example

This example computes the $\alpha$ and $\beta$ parameters, which defines the generalized eigenvalues and the corresponding left and right eigenvectors, of the matrix pair $\left(A,B\right)$ given by
 $A = 1.0 1.0 1.0 1.0 1.0 2.0 4.0 8.0 16.0 32.0 3.0 9.0 27.0 81.0 243.0 4.0 16.0 64.0 256.0 1024.0 5.0 25.0 125.0 625.0 3125.0 and B= 1.0 2.0 3.0 4.0 5.0 1.0 4.0 9.0 16.0 25.0 1.0 8.0 27.0 64.0 125.0 1.0 16.0 81.0 256.0 625.0 1.0 32.0 243.0 1024.0 3125.0 .$
To compute generalized eigenvalues, it is required to call five routines: F08WHF (DGGBAL) to balance the matrix, F08AEF (DGEQRF) to perform the $QR$ factorization of $B$, F08AGF (DORMQR) to apply $Q$ to $A$, F08WEF (DGGHRD) to reduce the matrix pair to the generalized Hessenberg form and F08XEF (DHGEQZ) to compute the eigenvalues via the $QZ$ algorithm.
The computation of generalized eigenvectors is done by calling F08YKF (DTGEVC) to compute the eigenvectors of the balanced matrix pair. The routine F08WJF (DGGBAK) is called to backward transform the eigenvectors to the user-supplied matrix pair. If both left and right eigenvectors are required then F08WJF (DGGBAK) must be called twice.

### 9.1  Program Text

Program Text (f08ykfe.f90)

### 9.2  Program Data

Program Data (f08ykfe.d)

### 9.3  Program Results

Program Results (f08ykfe.r)