# NAG Library Routine Document

## 1Purpose

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.

## 2Specification

Fortran Interface
 Subroutine f08quf ( job, n, t, ldt, q, ldq, w, m, s, sep, work, info)
 Integer, Intent (In) :: n, ldt, ldq, lwork Integer, Intent (Out) :: m, info Real (Kind=nag_wp), Intent (Out) :: s, sep Complex (Kind=nag_wp), Intent (Inout) :: t(ldt,*), q(ldq,*), w(*) Complex (Kind=nag_wp), Intent (Out) :: work(max(1,lwork)) Logical, Intent (In) :: select(*) Character (1), Intent (In) :: job, compq
#include <nagmk26.h>
 void f08quf_ (const char *job, const char *compq, const logical sel[], const Integer *n, Complex t[], const Integer *ldt, Complex q[], const Integer *ldq, Complex w[], Integer *m, double *s, double *sep, Complex work[], const Integer *lwork, Integer *info, const Charlen length_job, const Charlen length_compq)
The routine may be called by its LAPACK name ztrsen.

## 3Description

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.

## 4References

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

## 5Arguments

1:     $\mathbf{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:     $\mathbf{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:     $\mathbf{select}\left(*\right)$ – 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:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the order of the matrix $T$.
Constraint: ${\mathbf{n}}\ge 0$.
5:     $\mathbf{t}\left({\mathbf{ldt}},*\right)$ – 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:     $\mathbf{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:     $\mathbf{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{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:     $\mathbf{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:     $\mathbf{w}\left(*\right)$ – 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:   $\mathbf{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:   $\mathbf{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{s}}=1$.
If ${\mathbf{job}}=\text{'N'}$ or $\text{'V'}$, s is not referenced.
12:   $\mathbf{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{sep}}=‖T‖$.
If ${\mathbf{job}}=\text{'N'}$ or $\text{'E'}$, sep is not referenced.
13:   $\mathbf{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.
14:   $\mathbf{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,\mathit{m}×\left({\mathbf{n}}-\mathit{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,2\mathit{m}×\left({\mathbf{n}}-\mathit{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:   $\mathbf{info}$ – IntegerOutput
On exit: ${\mathbf{info}}=0$ unless the routine detects an error (see Section 6).

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

## 7Accuracy

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.

## 8Parallelism and Performance

f08quf (ztrsen) 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 f08qgf (dtrsen).

## 10Example

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 10 in f08ntf (zunghr).

### 10.1Program Text

Program Text (f08qufe.f90)

### 10.2Program Data

Program Data (f08qufe.d)

### 10.3Program Results

Program Results (f08qufe.r)