F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08YYF (ZTGSNA)

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

F08YYF (ZTGSNA) estimates condition numbers for specified eigenvalues and/or eigenvectors of a complex matrix pair in generalized Schur form.

## 2  Specification

 SUBROUTINE F08YYF ( JOB, HOWMNY, SELECT, N, A, LDA, B, LDB, VL, LDVL, VR, LDVR, S, DIF, MM, M, WORK, LWORK, IWORK, INFO)
 INTEGER N, LDA, LDB, LDVL, LDVR, MM, M, LWORK, IWORK(*), INFO REAL (KIND=nag_wp) S(*), DIF(*) COMPLEX (KIND=nag_wp) A(LDA,*), B(LDB,*), VL(LDVL,*), VR(LDVR,*), WORK(max(1,LWORK)) LOGICAL SELECT(*) CHARACTER(1) JOB, HOWMNY
The routine may be called by its LAPACK name ztgsna.

## 3  Description

F08YYF (ZTGSNA) estimates condition numbers for specified eigenvalues and/or right eigenvectors of an $n$ by $n$ matrix pair $\left(S,T\right)$ in generalized Schur form. The routine actually returns estimates of the reciprocals of the condition numbers in order to avoid possible overflow.
The pair $\left(S,T\right)$ are in generalized Schur form if $S$ and $T$ are upper triangular as returned, for example, by F08XNF (ZGGES) or F08XPF (ZGGESX), or F08XSF (ZHGEQZ) with ${\mathbf{JOB}}=\text{'S'}$. The diagonal elements define the generalized eigenvalues $\left({\alpha }_{\mathit{i}},{\beta }_{\mathit{i}}\right)$, for $\mathit{i}=1,2,\dots ,n$, of the pair $\left(S,T\right)$ and the eigenvalues are given by
 $λi = αi / βi ,$
so that
 $βi S xi = αi T xi or S xi = λi T xi ,$
where ${x}_{i}$ is the corresponding (right) eigenvector.
If $S$ and $T$ are the result of a generalized Schur factorization of a matrix pair $\left(A,B\right)$
 $A = QSZH , B = QTZH$
then the eigenvalues and condition numbers of the pair $\left(S,T\right)$ are the same as those of the pair $\left(A,B\right)$.
Let $\left(\alpha ,\beta \right)\ne \left(0,0\right)$ be a simple generalized eigenvalue of $\left(A,B\right)$. Then the reciprocal of the condition number of the eigenvalue $\lambda =\alpha /\beta$ is defined as
 $sλ= yHAx 2 + yHBx 2 1/2 x2 y2 ,$
where $x$ and $y$ are the right and left eigenvectors of $\left(A,B\right)$ corresponding to $\lambda$. If both $\alpha$ and $\beta$ are zero, then $\left(A,B\right)$ is singular and $s\left(\lambda \right)=-1$ is returned.
If $U$ and $V$ are unitary transformations such that
 $UH A,B V= S,T = α * 0 S22 β * 0 T22 ,$
where ${S}_{22}$ and ${T}_{22}$ are $\left(n-1\right)$ by $\left(n-1\right)$ matrices, then the reciprocal condition number is given by
 $Difx ≡ Dify = Difα,β,S22,T22 = σmin Z ,$
where ${\sigma }_{\mathrm{min}}\left(Z\right)$ denotes the smallest singular value of the $2\left(n-1\right)$ by $2\left(n-1\right)$ matrix
 $Z = α⊗I -1⊗S22 β⊗I -1⊗T22$
and $\otimes$ is the Kronecker product.
See Sections 2.4.8 and 4.11 of Anderson et al. (1999) and Kågström and Poromaa (1996) for further details and information.

## 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 http://www.netlib.org/lapack/lug
Kågström B and Poromaa P (1996) LAPACK-style algorithms and software for solving the generalized Sylvester equation and estimating the separation between regular matrix pairs ACM Trans. Math. Software 22 78–103

## 5  Parameters

1:     JOB – CHARACTER(1)Input
On entry: indicates whether condition numbers are required for eigenvalues and/or eigenvectors.
${\mathbf{JOB}}=\text{'E'}$
Condition numbers for eigenvalues only are computed.
${\mathbf{JOB}}=\text{'V'}$
Condition numbers for eigenvectors only are computed.
${\mathbf{JOB}}=\text{'B'}$
Condition numbers for both eigenvalues and eigenvectors are computed.
Constraint: ${\mathbf{JOB}}=\text{'E'}$, $\text{'V'}$ or $\text{'B'}$.
2:     HOWMNY – CHARACTER(1)Input
On entry: indicates how many condition numbers are to be computed.
${\mathbf{HOWMNY}}=\text{'A'}$
Condition numbers for all eigenpairs are computed.
${\mathbf{HOWMNY}}=\text{'S'}$
Condition numbers for selected eigenpairs (as specified by SELECT) are computed.
Constraint: ${\mathbf{HOWMNY}}=\text{'A'}$ 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 eigenpairs for which condition numbers are to be computed if ${\mathbf{HOWMNY}}=\text{'S'}$. To select condition numbers for the eigenpair corresponding to the eigenvalue ${\lambda }_{j}$, ${\mathbf{SELECT}}\left(j\right)$ must be set to .TRUE..
If ${\mathbf{HOWMNY}}=\text{'A'}$, SELECT is not referenced.
4:     N – INTEGERInput
On entry: $n$, the order of the matrix pair $\left(S,T\right)$.
Constraint: ${\mathbf{N}}\ge 0$.
5:     A(LDA,$*$) – COMPLEX (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 upper triangular matrix $S$.
6:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08YYF (ZTGSNA) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
7:     B(LDB,$*$) – COMPLEX (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 upper triangular matrix $T$.
8:     LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F08YYF (ZTGSNA) is called.
Constraint: ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
9:     VL(LDVL,$*$) – COMPLEX (KIND=nag_wp) arrayInput
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{JOB}}=\text{'E'}$ or $\text{'B'}$, and at least $1$ otherwise.
On entry: if ${\mathbf{JOB}}=\text{'E'}$ or $\text{'B'}$, VL must contain left eigenvectors of $\left(S,T\right)$, corresponding to the eigenpairs specified by HOWMNY and SELECT. The eigenvectors must be stored in consecutive columns of VL, as returned by F08WNF (ZGGEV) or F08YXF (ZTGEVC).
If ${\mathbf{JOB}}=\text{'V'}$, VL is not referenced.
10:   LDVL – INTEGERInput
On entry: the first dimension of the array VL as declared in the (sub)program from which F08YYF (ZTGSNA) is called.
Constraints:
• if ${\mathbf{JOB}}=\text{'E'}$ or $\text{'B'}$, ${\mathbf{LDVL}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDVL}}\ge 1$.
11:   VR(LDVR,$*$) – COMPLEX (KIND=nag_wp) arrayInput
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{JOB}}=\text{'E'}$ or $\text{'B'}$, and at least $1$ otherwise.
On entry: if ${\mathbf{JOB}}=\text{'E'}$ or $\text{'B'}$, VR must contain right eigenvectors of $\left(S,T\right)$, corresponding to the eigenpairs specified by HOWMNY and SELECT. The eigenvectors must be stored in consecutive columns of VR, as returned by F08WNF (ZGGEV) or F08YXF (ZTGEVC).
If ${\mathbf{JOB}}=\text{'V'}$, VR is not referenced.
12:   LDVR – INTEGERInput
On entry: the first dimension of the array VR as declared in the (sub)program from which F08YYF (ZTGSNA) is called.
Constraints:
• if ${\mathbf{JOB}}=\text{'E'}$ or $\text{'B'}$, ${\mathbf{LDVR}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDVR}}\ge 1$.
13:   S($*$) – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array S must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{MM}}\right)$ if ${\mathbf{JOB}}=\text{'E'}$ or $\text{'B'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{JOB}}=\text{'E'}$ or $\text{'B'}$, the reciprocal condition numbers of the selected eigenvalues, stored in consecutive elements of the array.
If ${\mathbf{JOB}}=\text{'V'}$, S is not referenced.
14:   DIF($*$) – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array DIF must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{MM}}\right)$ if ${\mathbf{JOB}}=\text{'V'}$ or $\text{'B'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{JOB}}=\text{'V'}$ or $\text{'B'}$, the estimated reciprocal condition numbers of the selected eigenvectors, stored in consecutive elements of the array. If the eigenvalues cannot be reordered to compute ${\mathbf{DIF}}\left(j\right)$, ${\mathbf{DIF}}\left(j\right)$ is set to $0$; this can only occur when the true value would be very small anyway.
If ${\mathbf{JOB}}=\text{'E'}$, DIF is not referenced.
15:   MM – INTEGERInput
On entry: the number of elements in the arrays S and DIF.
Constraint: ${\mathbf{MM}}\ge {\mathbf{N}}$.
16:   M – INTEGEROutput
On exit: the number of elements of the arrays S and DIF used to store the specified condition numbers; for each selected eigenvalue one element is used.
If ${\mathbf{HOWMNY}}=\text{'A'}$, M is set to N.
17:   WORK($\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LWORK}}\right)$) – COMPLEX (KIND=nag_wp) arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, the real part of ${\mathbf{WORK}}\left(1\right)$ contains the minimum value of LWORK required for optimal performance.
18:   LWORK – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08YYF (ZTGSNA) is called.
If ${\mathbf{LWORK}}=-1$, a workspace query is assumed; the routine only calculates the minimum 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.
Constraints:
if ${\mathbf{LWORK}}\ne -1$,
• if ${\mathbf{JOB}}=\text{'V'}$ or $\text{'B'}$, ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,2×{\mathbf{N}}×{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
19:   IWORK($*$) – INTEGER arrayWorkspace
Note: the dimension of the array IWORK must be at least $\left({\mathbf{N}}+2\right)$.
If ${\mathbf{JOB}}=\text{'E'}$, IWORK is not referenced.
20:   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.

## 7  Accuracy

None.

An approximate asymptotic error bound on the chordal distance between the computed eigenvalue $\stackrel{~}{\lambda }$ and the corresponding exact eigenvalue $\lambda$ is
 $χλ~,λ ≤ εA,BF / Sλ$
where $\epsilon$ is the machine precision.
An approximate asymptotic error bound for the right or left computed eigenvectors $\stackrel{~}{x}$ or $\stackrel{~}{y}$ corresponding to the right and left eigenvectors $x$ and $y$ is given by
 $θz~,z ≤ ε A,BF / Dif .$
The real analogue of this routine is F08YLF (DTGSNA).

## 9  Example

This example estimates condition numbers and approximate error estimates for all the eigenvalues and right eigenvectors of the pair $\left(S,T\right)$ given by
 $S = 4.0+4.0i 1.0+1.0i 1.0+1.0i 2.0-1.0i 0.0i+0.0 2.0+1.0i 1.0+1.0i 1.0+1.0i 0.0i+0.0 0.0i+0.0 2.0-1.0i 1.0+1.0i 0.0i+0.0 0.0i+0.0 0.0i+0.0 6.0-2.0i$
and
 $T = 2.0 1.0+1.0i 1.0+1.0i 3.0-1.0i 0.0 1.0i+0.0 2.0+1.0i 1.0+1.0i 0.0 0.0i+0.0 1.0i+0.0 1.0+1.0i 0.0 0.0i+0.0 0.0i+0.0 2.0i+0.0 .$
The eigenvalues and eigenvectors are computed by calling F08YXF (ZTGEVC).

### 9.1  Program Text

Program Text (f08yyfe.f90)

### 9.2  Program Data

Program Data (f08yyfe.d)

### 9.3  Program Results

Program Results (f08yyfe.r)