f08 Chapter Contents
f08 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_dtgsen (f08ygc)

## 1  Purpose

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

## 2  Specification

 #include #include
 void nag_dtgsen (Nag_OrderType order, Integer ijob, Nag_Boolean wantq, Nag_Boolean wantz, const Nag_Boolean select[], Integer n, double a[], Integer pda, double b[], Integer pdb, double alphar[], double alphai[], double beta[], double q[], Integer pdq, double z[], Integer pdz, Integer *m, double *pl, double *pr, double dif[], NagError *fail)

## 3  Description

nag_dtgsen (f08ygc) factorizes the generalized real $n$ by $n$ matrix pair $\left(S,T\right)$ in real generalized Schur form, using an orthogonal equivalence transformation as
 $S = Q^ S^ Z^T , T= Q^ T^ Z^T ,$
where $\left(\stackrel{^}{S},\stackrel{^}{T}\right)$ are also in real generalized Schur form and have the selected eigenvalues as the leading diagonal elements, or diagonal blocks. 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 real generalized Schur form if $S$ is block upper triangular with $1$ by $1$ and $2$ by $2$ diagonal blocks and $T$ is upper triangular as returned, for example, by nag_dgges (f08xac), or nag_dhgeqz (f08xec) with ${\mathbf{job}}=\mathrm{Nag_Schur}$. The diagonal elements, or blocks, 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 function 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 = QSZT , B= QTZT$
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:     orderNag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or Nag_ColMajor.
2:     ijobIntegerInput
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 (stored in ${\mathbf{dif}}\left[0\right]$ and ${\mathbf{dif}}\left[1\right]$ respectively).
${\mathbf{ijob}}=3$
Estimate of ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$. $1$-norm-based estimate (stored in ${\mathbf{dif}}\left[0\right]$ and ${\mathbf{dif}}\left[1\right]$ respectively). 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$.
3:     wantqNag_BooleanInput
On entry: if ${\mathbf{wantq}}=\mathrm{Nag_TRUE}$, update the left transformation matrix $Q$.
If ${\mathbf{wantq}}=\mathrm{Nag_FALSE}$, do not update $Q$.
4:     wantzNag_BooleanInput
On entry: if ${\mathbf{wantz}}=\mathrm{Nag_TRUE}$, update the right transformation matrix $Z$.
If ${\mathbf{wantz}}=\mathrm{Nag_FALSE}$, do not update $Z$.
5:     select[n]const Nag_BooleanInput
On entry: specifies the eigenvalues in the selected cluster. To select a real eigenvalue ${\lambda }_{j}$, ${\mathbf{select}}\left[j-1\right]$ must be set to Nag_TRUE.
To select a complex conjugate pair of eigenvalues ${\lambda }_{j}$ and ${\lambda }_{j+1}$, corresponding to a $2$ by $2$ diagonal block, either ${\mathbf{select}}\left[j-1\right]$ or ${\mathbf{select}}\left[j\right]$ or both must be set to Nag_TRUE; a complex conjugate pair of eigenvalues must be either both included in the cluster or both excluded.
6:     nIntegerInput
On entry: $n$, the order of the matrices $S$ and $T$.
Constraint: ${\mathbf{n}}\ge 0$.
7:     a[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pda}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix $A$ is stored in
• ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{pda}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the matrix $S$ in the pair $\left(S,T\right)$.
On exit: the updated matrix $\stackrel{^}{S}$.
8:     pdaIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array a.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
9:     b[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array b must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdb}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix $B$ is stored in
• ${\mathbf{b}}\left[\left(j-1\right)×{\mathbf{pdb}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{pdb}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the matrix $T$, in the pair $\left(S,T\right)$.
On exit: the updated matrix $\stackrel{^}{T}$
10:   pdbIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array b.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
11:   alphar[n]doubleOutput
On exit: see the description of beta.
12:   alphai[n]doubleOutput
On exit: see the description of beta.
13:   beta[n]doubleOutput
On exit: ${\mathbf{alphar}}\left[\mathit{j}-1\right]/{\mathbf{beta}}\left[\mathit{j}-1\right]$ and ${\mathbf{alphai}}\left[\mathit{j}-1\right]/{\mathbf{beta}}\left[\mathit{j}-1\right]$ are the real and imaginary parts respectively of the $\mathit{j}$th eigenvalue, for $\mathit{j}=1,2,\dots ,{\mathbf{n}}$.
If ${\mathbf{alphai}}\left[j-1\right]$ is zero, then the $j$th eigenvalue is real; if positive then ${\mathbf{alphai}}\left[j\right]$ is negative, and the $j$th and $\left(j+1\right)$st eigenvalues are a complex conjugate pair.
Conjugate pairs of eigenvalues correspond to the $2$ by $2$ diagonal blocks of $\stackrel{^}{S}$. These $2$ by $2$ blocks can be reduced by applying complex unitary transformations to $\left(\stackrel{^}{S},\stackrel{^}{T}\right)$ to obtain the complex Schur form $\left(\stackrel{~}{S},\stackrel{~}{T}\right)$, where $\stackrel{~}{S}$ is triangular (and complex). In this form ${\mathbf{alphar}}+i{\mathbf{alphai}}$ and beta are the diagonals of $\stackrel{~}{S}$ and $\stackrel{~}{T}$ respectively.
14:   q[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array q must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdq}}×{\mathbf{n}}\right)$ when ${\mathbf{wantq}}=\mathrm{Nag_TRUE}$;
• $1$ otherwise.
The $\left(i,j\right)$th element of the matrix $Q$ is stored in
• ${\mathbf{q}}\left[\left(j-1\right)×{\mathbf{pdq}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{q}}\left[\left(i-1\right)×{\mathbf{pdq}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: if ${\mathbf{wantq}}=\mathrm{Nag_TRUE}$, the $n$ by $n$ matrix $Q$.
On exit: if ${\mathbf{wantq}}=\mathrm{Nag_TRUE}$, the updated matrix $Q\stackrel{^}{Q}$.
If ${\mathbf{wantq}}=\mathrm{Nag_FALSE}$, q is not referenced.
15:   pdqIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array q.
Constraints:
• if ${\mathbf{wantq}}=\mathrm{Nag_TRUE}$, ${\mathbf{pdq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ${\mathbf{pdq}}\ge 1$.
16:   z[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array z must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdz}}×{\mathbf{n}}\right)$ when ${\mathbf{wantz}}=\mathrm{Nag_TRUE}$;
• $1$ otherwise.
The $\left(i,j\right)$th element of the matrix $Z$ is stored in
• ${\mathbf{z}}\left[\left(j-1\right)×{\mathbf{pdz}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{z}}\left[\left(i-1\right)×{\mathbf{pdz}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: if ${\mathbf{wantz}}=\mathrm{Nag_TRUE}$, the $n$ by $n$ matrix $Z$.
On exit: if ${\mathbf{wantz}}=\mathrm{Nag_TRUE}$, the updated matrix $Z\stackrel{^}{Z}$.
If ${\mathbf{wantz}}=\mathrm{Nag_FALSE}$, z is not referenced.
17:   pdzIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array z.
Constraints:
• if ${\mathbf{wantz}}=\mathrm{Nag_TRUE}$, ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ${\mathbf{pdz}}\ge 1$.
18:   mInteger *Output
On exit: the dimension of the specified pair of left and right eigenspaces (deflating subspaces).
19:   pldouble *Output
20:   prdouble *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 eigenspaces 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.
21:   dif[$\mathit{dim}$]doubleOutput
Note: the dimension, dim, of the array dif must be at least $2$.
On exit: if ${\mathbf{ijob}}\ge 2$, ${\mathbf{dif}}\left[0\right]$ and ${\mathbf{dif}}\left[1\right]$ store the estimates of ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$.
If ${\mathbf{ijob}}=2$ or $4$, ${\mathbf{dif}}\left[0\right]$ and ${\mathbf{dif}}\left[1\right]$ are $F$-norm-based upper bounds on ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$.
If ${\mathbf{ijob}}=3$ or $5$, ${\mathbf{dif}}\left[0\right]$ and ${\mathbf{dif}}\left[1\right]$ are $1$-norm-based estimates of ${\mathrm{Dif}}_{u}$ and ${\mathrm{Dif}}_{l}$.
If ${\mathbf{m}}=0$ or $n$, ${\mathbf{dif}}\left[0\right]$ and ${\mathbf{dif}}\left[1\right]$ $={‖\left(A,B\right)‖}_{F}$.
If ${\mathbf{ijob}}=0$ or $1$, dif is not referenced.
22:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_CONSTRAINT
On entry, ${\mathbf{wantq}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdq}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{wantq}}=\mathrm{Nag_TRUE}$, ${\mathbf{pdq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
otherwise ${\mathbf{pdq}}\ge 1$.
On entry, ${\mathbf{wantz}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdz}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{wantz}}=\mathrm{Nag_TRUE}$, ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
otherwise ${\mathbf{pdz}}\ge 1$.
NE_INT
On entry, ${\mathbf{ijob}}=〈\mathit{\text{value}}〉$.
Constraint: $0\le {\mathbf{ijob}}\le 5$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}>0$.
On entry, ${\mathbf{pdb}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdb}}>0$.
On entry, ${\mathbf{pdq}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdq}}>0$.
On entry, ${\mathbf{pdz}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdz}}>0$.
NE_INT_2
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry, ${\mathbf{pdb}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdb}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_SCHUR
Reordering of $\left(S,T\right)$ failed because the transformed matrix pair 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[0\right]$ and ${\mathbf{dif}}\left[1\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.

The complex analogue of this function is nag_ztgsen (f08yuc).

## 9  Example

This example reorders the generalized Schur factors $S$ and $T$ and update the matrices $Q$ and $Z$ given by
 $S = 4.0 1.0 1.0 2.0 0.0 3.0 4.0 1.0 0.0 1.0 3.0 1.0 0.0 0.0 0.0 6.0 , T= 2.0 1.0 1.0 3.0 0.0 1.0 2.0 1.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 2.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 first and fourth 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.

### 9.1  Program Text

Program Text (f08ygce.c)

### 9.2  Program Data

Program Data (f08ygce.d)

### 9.3  Program Results

Program Results (f08ygce.r)