F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08QUF (ZTRSEN)

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

F08QUF (ZTRSEN) reorders the Schur factorization of a complex general matrix so that a selected cluster of eigenvalues appears in the leading elements on the diagonal of the Schur form. The routine also optionally computes the reciprocal condition numbers of the cluster of eigenvalues and/or the invariant subspace.

## 2  Specification

 SUBROUTINE F08QUF ( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M, S, SEP, WORK, LWORK, INFO)
 INTEGER N, LDT, LDQ, M, LWORK, INFO REAL (KIND=nag_wp) S, SEP COMPLEX (KIND=nag_wp) T(LDT,*), Q(LDQ,*), W(*), WORK(max(1,LWORK)) LOGICAL SELECT(*) CHARACTER(1) JOB, COMPQ
The routine may be called by its LAPACK name ztrsen.

## 3  Description

F08QUF (ZTRSEN) reorders the Schur factorization of a complex general matrix $A=QT{Q}^{\mathrm{H}}$, so that a selected cluster of eigenvalues appears in the leading diagonal elements of the Schur form.
The reordered Schur form $\stackrel{~}{T}$ is computed by a unitary similarity transformation: $\stackrel{~}{T}={Z}^{\mathrm{H}}TZ$. Optionally the updated matrix $\stackrel{~}{Q}$ of Schur vectors is computed as $\stackrel{~}{Q}=QZ$, giving $A=\stackrel{~}{Q}\stackrel{~}{T}{\stackrel{~}{Q}}^{\mathrm{H}}$.
Let $\stackrel{~}{T}=\left(\begin{array}{cc}{T}_{11}& {T}_{12}\\ 0& {T}_{22}\end{array}\right)$, where the selected eigenvalues are precisely the eigenvalues of the leading $m$ by $m$ sub-matrix ${T}_{11}$. Let $\stackrel{~}{Q}$ be correspondingly partitioned as $\left(\begin{array}{cc}{Q}_{1}& {Q}_{2}\end{array}\right)$ where ${Q}_{1}$ consists of the first $m$ columns of $Q$. Then $A{Q}_{1}={Q}_{1}{T}_{11}$, and so the $m$ columns of ${Q}_{1}$ form an orthonormal basis for the invariant subspace corresponding to the selected cluster of eigenvalues.
Optionally the routine also computes estimates of the reciprocal condition numbers of the average of the cluster of eigenvalues and of the invariant subspace.

## 4  References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5  Parameters

1:     JOB – CHARACTER(1)Input
On entry: indicates whether condition numbers are required for the cluster of eigenvalues and/or the invariant subspace.
${\mathbf{JOB}}=\text{'N'}$
No condition numbers are required.
${\mathbf{JOB}}=\text{'E'}$
Only the condition number for the cluster of eigenvalues is computed.
${\mathbf{JOB}}=\text{'V'}$
Only the condition number for the invariant subspace is computed.
${\mathbf{JOB}}=\text{'B'}$
Condition numbers for both the cluster of eigenvalues and the invariant subspace are computed.
Constraint: ${\mathbf{JOB}}=\text{'N'}$, $\text{'E'}$, $\text{'V'}$ or $\text{'B'}$.
2:     COMPQ – CHARACTER(1)Input
On entry: indicates whether the matrix $Q$ of Schur vectors is to be updated.
${\mathbf{COMPQ}}=\text{'V'}$
The matrix $Q$ of Schur vectors is updated.
${\mathbf{COMPQ}}=\text{'N'}$
No Schur vectors are updated.
Constraint: ${\mathbf{COMPQ}}=\text{'V'}$ or $\text{'N'}$.
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)$.
On entry: specifies the eigenvalues in the selected cluster. To select a complex eigenvalue ${\lambda }_{j}$, ${\mathbf{SELECT}}\left(j\right)$ must be set .TRUE..
4:     N – INTEGERInput
On entry: $n$, the order of the matrix $T$.
Constraint: ${\mathbf{N}}\ge 0$.
5:     T(LDT,$*$) – COMPLEX (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array T must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the $n$ by $n$ upper triangular matrix $T$, as returned by F08PSF (ZHSEQR).
On exit: T is overwritten by the updated matrix $\stackrel{~}{T}$.
6:     LDT – INTEGERInput
On entry: the first dimension of the array T as declared in the (sub)program from which F08QUF (ZTRSEN) is called.
Constraint: ${\mathbf{LDT}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
7:     Q(LDQ,$*$) – 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{COMPQ}}=\text{'V'}$ and at least $1$ if ${\mathbf{COMPQ}}=\text{'N'}$.
On entry: if ${\mathbf{COMPQ}}=\text{'V'}$, Q must contain the $n$ by $n$ unitary matrix $Q$ of Schur vectors, as returned by F08PSF (ZHSEQR).
On exit: if ${\mathbf{COMPQ}}=\text{'V'}$, Q contains the updated matrix of Schur vectors; the first $m$ columns of $Q$ form an orthonormal basis for the specified invariant subspace.
If ${\mathbf{COMPQ}}=\text{'N'}$, Q is not referenced.
8:     LDQ – INTEGERInput
On entry: the first dimension of the array Q as declared in the (sub)program from which F08QUF (ZTRSEN) is called.
Constraints:
• if ${\mathbf{COMPQ}}=\text{'V'}$, ${\mathbf{LDQ}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$;
• if ${\mathbf{COMPQ}}=\text{'N'}$, ${\mathbf{LDQ}}\ge 1$.
9:     W($*$) – COMPLEX (KIND=nag_wp) arrayOutput
Note: the dimension of the array W must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On exit: the reordered eigenvalues of $\stackrel{~}{T}$. The eigenvalues are stored in the same order as on the diagonal of $\stackrel{~}{T}$.
10:   M – INTEGEROutput
On exit: $m$, the dimension of the specified invariant subspace, which is the same as the number of selected eigenvalues (see SELECT); $0\le m\le n$.
11:   S – REAL (KIND=nag_wp)Output
On exit: if ${\mathbf{JOB}}=\text{'E'}$ or $\text{'B'}$, S is a lower bound on the reciprocal condition number of the average of the selected cluster of eigenvalues. If ${\mathbf{M}}=0\text{​ or ​}{\mathbf{N}}$, ${\mathbf{S}}=1$.
If ${\mathbf{JOB}}=\text{'N'}$ or $\text{'V'}$, S is not referenced.
12:   SEP – REAL (KIND=nag_wp)Output
On exit: if ${\mathbf{JOB}}=\text{'V'}$ or $\text{'B'}$, SEP is the estimated reciprocal condition number of the specified invariant subspace. If ${\mathbf{M}}=0\text{​ or ​}{\mathbf{N}}$, ${\mathbf{SEP}}=‖T‖$.
If ${\mathbf{JOB}}=\text{'N'}$ or $\text{'E'}$, SEP is not referenced.
13:   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.
14:   LWORK – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08QUF (ZTRSEN) is called, unless ${\mathbf{LWORK}}=-1$, in which case a workspace query is assumed and the routine only calculates the minimum dimension of WORK.
Constraints:
• if ${\mathbf{JOB}}=\text{'N'}$, ${\mathbf{LWORK}}\ge 1$ or ${\mathbf{LWORK}}=-1$;
• if ${\mathbf{JOB}}=\text{'E'}$, ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,m×\left({\mathbf{N}}-m\right)\right)$ or ${\mathbf{LWORK}}=-1$;
• if ${\mathbf{JOB}}=\text{'V'}$ or $\text{'B'}$, ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,2m×\left({\mathbf{N}}-m\right)\right)$ or ${\mathbf{LWORK}}=-1$.
The actual amount of workspace required cannot exceed ${{\mathbf{N}}}^{2}/4$ if ${\mathbf{JOB}}=\text{'E'}$ or ${{\mathbf{N}}}^{2}/2$ if ${\mathbf{JOB}}=\text{'V'}$ or $\text{'B'}$.
15:   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

The computed matrix $\stackrel{~}{T}$ is similar to a matrix $\left(T+E\right)$, where
 $E2 = Oε T2 ,$
and $\epsilon$ is the machine precision.
S cannot underestimate the true reciprocal condition number by more than a factor of $\sqrt{\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(m,n-m\right)}$. SEP may differ from the true value by $\sqrt{m\left(n-m\right)}$. The angle between the computed invariant subspace and the true subspace is $\frac{\mathit{O}\left(\epsilon \right){‖A‖}_{2}}{\mathit{sep}}$.
The values of the eigenvalues are never changed by the reordering.

## 8  Further Comments

The real analogue of this routine is F08QGF (DTRSEN).

## 9  Example

This example reorders the Schur factorization of the matrix $A=QT{Q}^{\mathrm{H}}$ such that the eigenvalues stored in elements ${t}_{11}$ and ${t}_{44}$ appear as the leading elements on the diagonal of the reordered matrix $\stackrel{~}{T}$, where
 $T = -6.0004-6.9999i 0.3637-0.3656i -0.1880+0.4787i 0.8785-0.2539i 0.0000+0.0000i -5.0000+2.0060i -0.0307-0.7217i -0.2290+0.1313i 0.0000+0.0000i 0.0000+0.0000i 7.9982-0.9964i 0.9357+0.5359i 0.0000+0.0000i 0.0000+0.0000i 0.0000+0.0000i 3.0023-3.9998i$
and
 $Q = -0.8347-0.1364i -0.0628+0.3806i 0.2765-0.0846i 0.0633-0.2199i 0.0664-0.2968i 0.2365+0.5240i -0.5877-0.4208i 0.0835+0.2183i -0.0362-0.3215i 0.3143-0.5473i 0.0576-0.5736i 0.0057-0.4058i 0.0086+0.2958i -0.3416-0.0757i -0.1900-0.1600i 0.8327-0.1868i .$
The original matrix $A$ is given in Section 9 in F08NTF (ZUNGHR).

### 9.1  Program Text

Program Text (f08qufe.f90)

### 9.2  Program Data

Program Data (f08qufe.d)

### 9.3  Program Results

Program Results (f08qufe.r)