# NAG FL Interfacef08qff (dtrexc)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f08qff reorders the Schur factorization of a real general matrix.

## 2Specification

Fortran Interface
 Subroutine f08qff ( n, t, ldt, q, ldq, ifst, ilst, work, info)
 Integer, Intent (In) :: n, ldt, ldq Integer, Intent (Inout) :: ifst, ilst Integer, Intent (Out) :: info Real (Kind=nag_wp), Intent (Inout) :: t(ldt,*), q(ldq,*) Real (Kind=nag_wp), Intent (Out) :: work(n) Character (1), Intent (In) :: compq
#include <nag.h>
 void f08qff_ (const char *compq, const Integer *n, double t[], const Integer *ldt, double q[], const Integer *ldq, Integer *ifst, Integer *ilst, double work[], Integer *info, const Charlen length_compq)
The routine may be called by the names f08qff, nagf_lapackeig_dtrexc or its LAPACK name dtrexc.

## 3Description

f08qff reorders the Schur factorization of a real general matrix $A=QT{Q}^{\mathrm{T}}$, so that the diagonal element or block of $T$ with row index ifst is moved to row ilst.
The reordered Schur form $\stackrel{~}{T}$ is computed by an orthogonal similarity transformation: $\stackrel{~}{T}={Z}^{\mathrm{T}}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{T}}$.
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}$Integer Input
On entry: $n$, the order of the matrix $T$.
Constraint: ${\mathbf{n}}\ge 0$.
3: $\mathbf{t}\left({\mathbf{ldt}},*\right)$Real (Kind=nag_wp) array Input/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×n$ upper quasi-triangular matrix $T$ in canonical Schur form, as returned by f08pef.
On exit: t is overwritten by the updated matrix $\stackrel{~}{T}$. See also Section 9.
4: $\mathbf{ldt}$Integer Input
On entry: the first dimension of the array t as declared in the (sub)program from which f08qff 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)$Real (Kind=nag_wp) array Input/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×n$ orthogonal 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}$Integer Input
On entry: the first dimension of the array q as declared in the (sub)program from which f08qff 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}$Integer Input/Output
8: $\mathbf{ilst}$Integer Input/Output
On entry: ifst and ilst must specify the reordering of the diagonal elements or blocks of $T$. The element or block with row index ifst is moved to row ilst by a sequence of exchanges between adjacent elements or blocks.
On exit: if ifst pointed to the second row of a $2×2$ block on entry, 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$).
Constraint: $1\le {\mathbf{ifst}}\le {\mathbf{n}}$ and $1\le {\mathbf{ilst}}\le {\mathbf{n}}$.
9: $\mathbf{work}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Workspace
10: $\mathbf{info}$Integer Output
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.
${\mathbf{info}}=1$
Two adjacent diagonal elements or blocks could not be successfully exchanged. This error can only occur if the exchange involves at least one $2×2$ block; it implies that the problem is very ill-conditioned, and that the eigenvalues of the two blocks are very close. On exit, $T$ may have been partially reordered, and ilst points to the first row of the current position of the block being moved; $Q$ (if requested) is updated consistently with $T$.

## 7Accuracy

The computed matrix $\stackrel{~}{T}$ is exactly similar to a matrix $\left(T+E\right)$, where
 $‖E‖2 = O(ε) ‖T‖2 ,$
and $\epsilon$ is the machine precision.
Note that if a $2×2$ diagonal block is involved in the reordering, its off-diagonal elements are in general changed; the diagonal elements and the eigenvalues of the block are unchanged unless the block is sufficiently ill-conditioned, in which case they may be noticeably altered. It is possible for a $2×2$ block to break into two $1×1$ blocks, i.e., for a pair of complex eigenvalues to become purely real. The values of real eigenvalues however are never changed by the reordering.

## 8Parallelism and Performance

f08qff 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 floating-point operations is approximately $6nr$ if ${\mathbf{compq}}=\text{'N'}$, and $12nr$ if ${\mathbf{compq}}=\text{'V'}$, where $r=|{\mathbf{ifst}}-{\mathbf{ilst}}|$.
The input matrix $T$ must be in canonical Schur form, as is the output matrix $\stackrel{~}{T}$. This has the following structure.
If all the computed eigenvalues are real, $T$ is upper triangular and its diagonal elements are the eigenvalues.
If some of the computed eigenvalues form complex conjugate pairs, then $T$ has $2×2$ diagonal blocks. Each diagonal block has the form
 $( tii ti,i+1 ti+1,i ti+1,i+1 )= ( α β γ α )$
where $\beta \gamma <0$. The corresponding eigenvalues are $\alpha ±\sqrt{\beta \gamma }$.
The complex analogue of this routine is f08qtf.

## 10Example

This example reorders the Schur factorization of the matrix $T$ so that the $2×2$ block with row index $2$ is moved to row $1$, where
 $T = ( 0.80 -0.11 0.01 0.03 0.00 -0.10 0.25 0.35 0.00 -0.65 -0.10 0.20 0.00 0.00 0.00 -0.10 ) .$

### 10.1Program Text

Program Text (f08qffe.f90)

### 10.2Program Data

Program Data (f08qffe.d)

### 10.3Program Results

Program Results (f08qffe.r)