# NAG Library Routine Document

## 1Purpose

f08qtf (ztrexc) reorders the Schur factorization of a complex general matrix.

## 2Specification

Fortran Interface
 Subroutine f08qtf ( n, t, ldt, q, ldq, ifst, ilst, info)
 Integer, Intent (In) :: n, ldt, ldq, ifst, ilst Integer, Intent (Out) :: info Complex (Kind=nag_wp), Intent (Inout) :: t(ldt,*), q(ldq,*) Character (1), Intent (In) :: compq
#include <nagmk26.h>
 void f08qtf_ (const char *compq, const Integer *n, Complex t[], const Integer *ldt, Complex q[], const Integer *ldq, const Integer *ifst, const Integer *ilst, Integer *info, const Charlen length_compq)
The routine may be called by its LAPACK name ztrexc.

## 3Description

f08qtf (ztrexc) reorders the Schur factorization of a complex general matrix $A=QT{Q}^{\mathrm{H}}$, so that the diagonal element of $T$ with row index ifst is moved to row ilst.
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}}$.

## 4References

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

## 5Arguments

1:     $\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'}$.
2:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the order of the matrix $T$.
Constraint: ${\mathbf{n}}\ge 0$.
3:     $\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}$.
4:     $\mathbf{ldt}$ – IntegerInput
On entry: the first dimension of the array t as declared in the (sub)program from which f08qtf (ztrexc) is called.
Constraint: ${\mathbf{ldt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
5:     $\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.
On exit: if ${\mathbf{compq}}=\text{'V'}$, q contains the updated matrix of Schur vectors.
If ${\mathbf{compq}}=\text{'N'}$, q is not referenced.
6:     $\mathbf{ldq}$ – IntegerInput
On entry: the first dimension of the array q as declared in the (sub)program from which f08qtf (ztrexc) 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$.
7:     $\mathbf{ifst}$ – IntegerInput
8:     $\mathbf{ilst}$ – IntegerInput
On entry: ifst and ilst must specify the reordering of the diagonal elements of $T$. The element with row index ifst is moved to row ilst by a sequence of exchanges between adjacent elements.
Constraint: $1\le {\mathbf{ifst}}\le {\mathbf{n}}$ and $1\le {\mathbf{ilst}}\le {\mathbf{n}}$.
9:     $\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 exactly similar to a matrix $\left(T+E\right)$, where
 $E2 = Oε T2 ,$
and $\epsilon$ is the machine precision.
The values of the eigenvalues are never changed by the reordering.

## 8Parallelism and Performance

f08qtf (ztrexc) 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 total number of real floating-point operations is approximately $20nr$ if ${\mathbf{compq}}=\text{'N'}$, and $40nr$ if ${\mathbf{compq}}=\text{'V'}$, where $r=\left|{\mathbf{ifst}}-{\mathbf{ilst}}\right|$.
The real analogue of this routine is f08qff (dtrexc).

## 10Example

This example reorders the Schur factorization of the matrix $T$ so that element ${t}_{11}$ is moved to ${t}_{44}$, where
 $T = -6.00-7.00i 0.36-0.36i -0.19+0.48i 0.88-0.25i 0.00+0.00i -5.00+2.00i -0.03-0.72i -0.23+0.13i 0.00+0.00i 0.00+0.00i 8.00-1.00i 0.94+0.53i 0.00+0.00i 0.00+0.00i 0.00+0.00i 3.00-4.00i .$

### 10.1Program Text

Program Text (f08qtfe.f90)

### 10.2Program Data

Program Data (f08qtfe.d)

### 10.3Program Results

Program Results (f08qtfe.r)