F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08YFF (DTGEXC)

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

F08YFF (DTGEXC) reorders the generalized Schur factorization of a matrix pair in real generalized Schur form.

## 2  Specification

 SUBROUTINE F08YFF ( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z, LDZ, IFST, ILST, WORK, LWORK, INFO)
 INTEGER N, LDA, LDB, LDQ, LDZ, IFST, ILST, LWORK, INFO REAL (KIND=nag_wp) A(LDA,*), B(LDB,*), Q(LDQ,*), Z(LDZ,*), WORK(max(1,LWORK)) LOGICAL WANTQ, WANTZ
The routine may be called by its LAPACK name dtgexc.

## 3  Description

F08YFF (DTGEXC) reorders the generalized real $n$ by $n$ matrix pair $\left(S,T\right)$ in real generalized Schur form, so that the diagonal element or block of $\left(S,T\right)$ with row index ${i}_{1}$ is moved to row ${i}_{2}$, using an orthogonal equivalence transformation. That is, $S$ and $T$ are factorized 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.
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 F08XAF (DGGES), or F08XEF (DHGEQZ) with ${\mathbf{JOB}}=\text{'S'}$.
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}$.

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

1:     $\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$.
2:     $\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$.
3:     $\mathrm{N}$ – INTEGERInput
On entry: $n$, the order of the matrices $S$ and $T$.
Constraint: ${\mathbf{N}}\ge 0$.
4:     $\mathrm{A}\left({\mathbf{LDA}},*\right)$ – REAL (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}$.
5:     $\mathrm{LDA}$ – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08YFF (DTGEXC) is called.
Constraint: ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
6:     $\mathrm{B}\left({\mathbf{LDB}},*\right)$ – REAL (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}$
7:     $\mathrm{LDB}$ – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F08YFF (DTGEXC) is called.
Constraint: ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
8:     $\mathrm{Q}\left({\mathbf{LDQ}},*\right)$ – REAL (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 orthogonal matrix $Q$.
On exit: if ${\mathbf{WANTQ}}=\mathrm{.TRUE.}$, the updated matrix $Q\stackrel{^}{Q}$.
If ${\mathbf{WANTQ}}=\mathrm{.FALSE.}$, Q is not referenced.
9:     $\mathrm{LDQ}$ – INTEGERInput
On entry: the first dimension of the array Q as declared in the (sub)program from which F08YFF (DTGEXC) 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$.
10:   $\mathrm{Z}\left({\mathbf{LDZ}},*\right)$ – REAL (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 orthogonal matrix $Z$.
On exit: if ${\mathbf{WANTZ}}=\mathrm{.TRUE.}$, the updated matrix $Z\stackrel{^}{Z}$.
If ${\mathbf{WANTZ}}=\mathrm{.FALSE.}$, Z is not referenced.
11:   $\mathrm{LDZ}$ – INTEGERInput
On entry: the first dimension of the array Z as declared in the (sub)program from which F08YFF (DTGEXC) 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$.
12:   $\mathrm{IFST}$ – INTEGERInput/Output
13:   $\mathrm{ILST}$ – INTEGERInput/Output
On entry: the indices ${i}_{1}$ and ${i}_{2}$ that specify the reordering of the diagonal blocks of $\left(S,T\right)$. The block with row index IFST is moved to row ILST, by a sequence of swapping between adjacent blocks.
On exit: if IFST pointed on entry to the second row of a $2$ by $2$ block, it is changed to point to the first row; ILST always points to the first row of the block in its final position (which may differ from its input value by $+1$ or $-1$).
Constraint: $1\le {\mathbf{IFST}}\le {\mathbf{N}}$ and $1\le {\mathbf{ILST}}\le {\mathbf{N}}$.
14:   $\mathrm{WORK}\left(\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LWORK}}\right)\right)$ – REAL (KIND=nag_wp) arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, ${\mathbf{WORK}}\left(1\right)$ contains the minimum value of LWORK required for optimal performance.
15:   $\mathrm{LWORK}$ – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08YFF (DTGEXC) 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{N}}\le 1$, ${\mathbf{LWORK}}\ge 1$;
• otherwise ${\mathbf{LWORK}}\ge 4×{\mathbf{N}}+16$.
16:   $\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$
The transformed matrix pair $\left(\stackrel{^}{S},\stackrel{^}{T}\right)$ would be too far from generalized Schur form; the problem is ill-conditioned. $\left(S,T\right)$ may have been partially reordered, and ILST points to the first row of the current position of the block being moved.

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

## 8  Parallelism and Performance

F08YFF (DTGEXC) is not threaded by NAG in any implementation.
F08YFF (DTGEXC) 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 complex analogue of this routine is F08YTF (ZTGEXC).

## 10  Example

This example exchanges blocks $2$ and $1$ of the matrix pair $\left(S,T\right)$, where
 $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 and 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 .$

### 10.1  Program Text

Program Text (f08yffe.f90)

### 10.2  Program Data

Program Data (f08yffe.d)

### 10.3  Program Results

Program Results (f08yffe.r)