F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08YUF (ZTGSEN)

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

F08YUF (ZTGSEN) reorders the generalized Schur factorization of a complex matrix pair in generalized Schur form, so that a selected cluster of eigenvalues appears in the leading elements on the diagonal of the generalized Schur form. The routine also, optionally, computes the reciprocal condition numbers of the cluster of eigenvalues and/or corresponding deflating subspaces.

## 2  Specification

 SUBROUTINE F08YUF ( IJOB, WANTQ, WANTZ, SELECT, N, A, LDA, B, LDB, ALPHA, BETA, Q, LDQ, Z, LDZ, M, PL, PR, DIF, WORK, LWORK, IWORK, LIWORK, INFO)
 INTEGER IJOB, N, LDA, LDB, LDQ, LDZ, M, LWORK, IWORK(max(1,LIWORK)), LIWORK, INFO REAL (KIND=nag_wp) PL, PR, DIF(*) COMPLEX (KIND=nag_wp) A(LDA,*), B(LDB,*), ALPHA(N), BETA(N), Q(LDQ,*), Z(LDZ,*), WORK(max(1,LWORK)) LOGICAL WANTQ, WANTZ, SELECT(N)
The routine may be called by its LAPACK name ztgsen.

## 3  Description

F08YUF (ZTGSEN) factorizes the generalized complex $n$ by $n$ matrix pair $\left(S,T\right)$ in generalized Schur form, using a unitary equivalence transformation as
 $S = Q^ S^ Z^H , T= Q^ T^ Z^H ,$
where $\left(\stackrel{^}{S},\stackrel{^}{T}\right)$ are also in generalized Schur form and have the selected eigenvalues as the leading diagonal elements. The leading columns of $Q$ and $Z$ are the generalized Schur vectors corresponding to the selected eigenvalues and form orthonormal subspaces for the left and right eigenspaces (deflating subspaces) of the pair $\left(S,T\right)$.
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 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)$. The eigenvalues are given by
 $λi = αi / βi ,$
but are returned as the pair $\left({\alpha }_{i},{\beta }_{i}\right)$ in order to avoid possible overflow in computing ${\lambda }_{i}$. Optionally, the routine returns reciprocals of condition number estimates for the selected eigenvalue cluster, $p$ and $q$, the right and left projection norms, and of deflating subspaces, ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$. For more information see Sections 2.4.8 and 4.11 of Anderson et al. (1999).
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, optionally, the matrices $Q$ and $Z$ can be updated as $Q\stackrel{^}{Q}$ and $Z\stackrel{^}{Z}$. Note that the condition numbers of the pair $\left(S,T\right)$ are the same as those of the pair $\left(A,B\right)$.

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

## 5  Arguments

1:     $\mathrm{IJOB}$ – INTEGERInput
On entry: specifies whether condition numbers are required for the cluster of eigenvalues ($p$ and $q$) or the deflating subspaces (${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$).
${\mathbf{IJOB}}=0$
Only reorder with respect to SELECT. No extras.
${\mathbf{IJOB}}=1$
Reciprocal of norms of ‘projections’ onto left and right eigenspaces with respect to the selected cluster ($p$ and $q$).
${\mathbf{IJOB}}=2$
The upper bounds on ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$. $F$-norm-based estimate (${\mathbf{DIF}}\left(1:2\right)$).
${\mathbf{IJOB}}=3$
Estimate of ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$. $1$-norm-based estimate (${\mathbf{DIF}}\left(1:2\right)$). About five times as expensive as ${\mathbf{IJOB}}=2$.
${\mathbf{IJOB}}=4$
Compute PL, PR and DIF as in ${\mathbf{IJOB}}=0$, $1$ and $2$. Economic version to get it all.
${\mathbf{IJOB}}=5$
Compute PL, PR and DIF as in ${\mathbf{IJOB}}=0$, $1$ and $3$.
Constraint: $0\le {\mathbf{IJOB}}\le 5$.
2:     $\mathrm{WANTQ}$ – LOGICALInput
On entry: if ${\mathbf{WANTQ}}=\mathrm{.TRUE.}$, update the left transformation matrix $Q$.
If ${\mathbf{WANTQ}}=\mathrm{.FALSE.}$, do not update $Q$.
3:     $\mathrm{WANTZ}$ – LOGICALInput
On entry: if ${\mathbf{WANTZ}}=\mathrm{.TRUE.}$, update the right transformation matrix $Z$.
If ${\mathbf{WANTZ}}=\mathrm{.FALSE.}$, do not update $Z$.
4:     $\mathrm{SELECT}\left({\mathbf{N}}\right)$ – LOGICAL arrayInput
On entry: specifies the eigenvalues in the selected cluster. To select an eigenvalue ${\lambda }_{j}$, ${\mathbf{SELECT}}\left(j\right)$ must be set to .TRUE..
5:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the order of the matrices $S$ and $T$.
Constraint: ${\mathbf{N}}\ge 0$.
6:     $\mathrm{A}\left({\mathbf{LDA}},*\right)$ – COMPLEX (KIND=nag_wp) arrayInput/Output
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 $S$ in the pair $\left(S,T\right)$.
On exit: the updated matrix $\stackrel{^}{S}$.
7:     $\mathrm{LDA}$ – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08YUF (ZTGSEN) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
8:     $\mathrm{B}\left({\mathbf{LDB}},*\right)$ – COMPLEX (KIND=nag_wp) arrayInput/Output
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 $T$, in the pair $\left(S,T\right)$.
On exit: the updated matrix $\stackrel{^}{T}$
9:     $\mathrm{LDB}$ – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F08YUF (ZTGSEN) is called.
Constraint: ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
10:   $\mathrm{ALPHA}\left({\mathbf{N}}\right)$ – COMPLEX (KIND=nag_wp) arrayOutput
11:   $\mathrm{BETA}\left({\mathbf{N}}\right)$ – COMPLEX (KIND=nag_wp) arrayOutput
On exit: ALPHA and BETA contain diagonal elements of $\stackrel{^}{S}$ and $\stackrel{^}{T}$, respectively, when the pair $\left(S,T\right)$ has been reduced to generalized Schur form. ${\mathbf{ALPHA}}\left(\mathit{i}\right)/{\mathbf{BETA}}\left(\mathit{i}\right)$, for $\mathit{i}=1,2,\dots ,{\mathbf{N}}$, are the eigenvalues.
12:   $\mathrm{Q}\left({\mathbf{LDQ}},*\right)$ – COMPLEX (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array Q must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{WANTQ}}=\mathrm{.TRUE.}$, and at least $1$ otherwise.
On entry: if ${\mathbf{WANTQ}}=\mathrm{.TRUE.}$, the $n$ by $n$ matrix $Q$.
On exit: if ${\mathbf{WANTQ}}=\mathrm{.TRUE.}$, the updated matrix $Q\stackrel{^}{Q}$.
If ${\mathbf{WANTQ}}=\mathrm{.FALSE.}$, Q is not referenced.
13:   $\mathrm{LDQ}$ – INTEGERInput
On entry: the first dimension of the array Q as declared in the (sub)program from which F08YUF (ZTGSEN) is called.
Constraints:
• if ${\mathbf{WANTQ}}=\mathrm{.TRUE.}$, ${\mathbf{LDQ}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDQ}}\ge 1$.
14:   $\mathrm{Z}\left({\mathbf{LDZ}},*\right)$ – COMPLEX (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array Z must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ if ${\mathbf{WANTZ}}=\mathrm{.TRUE.}$, and at least $1$ otherwise.
On entry: if ${\mathbf{WANTZ}}=\mathrm{.TRUE.}$, the $n$ by $n$ matrix $Z$.
On exit: if ${\mathbf{WANTZ}}=\mathrm{.TRUE.}$, the updated matrix $Z\stackrel{^}{Z}$.
If ${\mathbf{WANTZ}}=\mathrm{.FALSE.}$, Z is not referenced.
15:   $\mathrm{LDZ}$ – INTEGERInput
On entry: the first dimension of the array Z as declared in the (sub)program from which F08YUF (ZTGSEN) is called.
Constraints:
• if ${\mathbf{WANTZ}}=\mathrm{.TRUE.}$, ${\mathbf{LDZ}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• otherwise ${\mathbf{LDZ}}\ge 1$.
16:   $\mathrm{M}$ – INTEGEROutput
On exit: the dimension of the specified pair of left and right eigenspaces (deflating subspaces).
Constraint: $0\le {\mathbf{M}}\le {\mathbf{N}}$.
17:   $\mathrm{PL}$ – REAL (KIND=nag_wp)Output
18:   $\mathrm{PR}$ – REAL (KIND=nag_wp)Output
On exit: if ${\mathbf{IJOB}}=1$, $4$ or $5$, PL and PR are lower bounds on the reciprocal of the norm of ‘projections’ $p$ and $q$ onto left and right eigenspace with respect to the selected cluster. $0<{\mathbf{PL}}$, ${\mathbf{PR}}\le 1$.
If ${\mathbf{M}}=0$ or ${\mathbf{M}}={\mathbf{N}}$, ${\mathbf{PL}}={\mathbf{PR}}=1$.
If ${\mathbf{IJOB}}=0$, $2$ or $3$, PL and PR are not referenced.
19:   $\mathrm{DIF}\left(*\right)$ – REAL (KIND=nag_wp) arrayOutput
Note: the dimension of the array DIF must be at least $2$.
On exit: if ${\mathbf{IJOB}}\ge 2$, ${\mathbf{DIF}}\left(1:2\right)$ store the estimates of ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$.
If ${\mathbf{IJOB}}=2$ or $4$, ${\mathbf{DIF}}\left(1:2\right)$ are $F$-norm-based upper bounds on ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$.
If ${\mathbf{IJOB}}=3$ or $5$, ${\mathbf{DIF}}\left(1:2\right)$ are $1$-norm-based estimates of ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$.
If ${\mathbf{M}}=0$ or $n$, ${\mathbf{DIF}}\left(1:2\right)$ $={‖\left(A,B\right)‖}_{F}$.
If ${\mathbf{IJOB}}=0$ or $1$, DIF is not referenced.
20:   $\mathrm{WORK}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LWORK}}\right)\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.
21:   $\mathrm{LWORK}$ – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08YUF (ZTGSEN) is called.
If ${\mathbf{LWORK}}=-1$, a workspace query is assumed; the routine only calculates the minimum sizes of the WORK and IWORK arrays, returns these values as the first entries of the WORK and IWORK arrays, and no error message related to LWORK or LIWORK is issued.
Constraints:
if ${\mathbf{LWORK}}\ne -1$,
• if ${\mathbf{IJOB}}=1$, $2$ or $4$, ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,2×{\mathbf{M}}×\left({\mathbf{N}}-{\mathbf{M}}\right)\right)$;
• if ${\mathbf{IJOB}}=3$ or $5$, ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,4×{\mathbf{M}}×\left({\mathbf{N}}-{\mathbf{M}}\right)\right)$;
• otherwise ${\mathbf{LWORK}}\ge 1$.
22:   $\mathrm{IWORK}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LIWORK}}\right)\right)$ – INTEGER arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, ${\mathbf{IWORK}}\left(1\right)$ returns the minimum LIWORK.
23:   $\mathrm{LIWORK}$ – INTEGERInput
On entry: the dimension of the array IWORK as declared in the (sub)program from which F08YUF (ZTGSEN) is called.
If ${\mathbf{LIWORK}}=-1$, a workspace query is assumed; the routine only calculates the minimum sizes of the WORK and IWORK arrays, returns these values as the first entries of the WORK and IWORK arrays, and no error message related to LWORK or LIWORK is issued.
Constraints:
if ${\mathbf{LIWORK}}\ne -1$,
• if ${\mathbf{IJOB}}=1$, $2$ or $4$, ${\mathbf{LIWORK}}\ge {\mathbf{N}}+2$;
• if ${\mathbf{IJOB}}=3$ or $5$, ${\mathbf{LIWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{N}}+2,2×{\mathbf{M}}×\left({\mathbf{N}}-{\mathbf{M}}\right)\right)$;
• otherwise ${\mathbf{LIWORK}}\ge 1$.
24:   $\mathrm{INFO}$ – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

${\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}}=1$
Reordering of $\left(S,T\right)$ failed because the transformed matrix pair $\left(\stackrel{^}{S},\stackrel{^}{T}\right)$ would be too far from generalized Schur form; the problem is very ill-conditioned. $\left(S,T\right)$ may have been partially reordered. If requested, $0$ is returned in ${\mathbf{DIF}}\left(1:2\right)$, PL and PR.

## 7  Accuracy

The computed generalized Schur form is nearly the exact generalized Schur form for nearby matrices $\left(S+E\right)$ and $\left(T+F\right)$, where
 $E2 = O⁡ε S2 and F2= O⁡ε T2 ,$
and $\epsilon$ is the machine precision. See Section 4.11 of Anderson et al. (1999) for further details of error bounds for the generalized nonsymmetric eigenproblem, and for information on the condition numbers returned.

## 8  Parallelism and Performance

F08YUF (ZTGSEN) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

The real analogue of this routine is F08YGF (DTGSEN).

## 10  Example

This example reorders the generalized Schur factors $S$ and $T$ and update the matrices $Q$ and $Z$ 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 ,$
 $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 ,$
 $Q = 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 and Z= 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 1.0 ,$
selecting the second and third generalized eigenvalues to be moved to the leading positions. Bases for the left and right deflating subspaces, and estimates of the condition numbers for the eigenvalues and Frobenius norm based bounds on the condition numbers for the deflating subspaces are also output.

### 10.1  Program Text

Program Text (f08yufe.f90)

### 10.2  Program Data

Program Data (f08yufe.d)

### 10.3  Program Results

Program Results (f08yufe.r)