# NAG CL Interfacef08qfc (dtrexc)

Settings help

CL Name Style:

## 1Purpose

f08qfc reorders the Schur factorization of a real general matrix.

## 2Specification

 #include
 void f08qfc (Nag_OrderType order, Nag_ComputeQType compq, Integer n, double t[], Integer pdt, double q[], Integer pdq, Integer *ifst, Integer *ilst, NagError *fail)
The function may be called by the names: f08qfc, nag_lapackeig_dtrexc or nag_dtrexc.

## 3Description

f08qfc 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}}$.

## 4References

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

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{compq}$Nag_ComputeQType Input
On entry: indicates whether the matrix $Q$ of Schur vectors is to be updated.
${\mathbf{compq}}=\mathrm{Nag_UpdateSchur}$
The matrix $Q$ of Schur vectors is updated.
${\mathbf{compq}}=\mathrm{Nag_NotQ}$
No Schur vectors are updated.
Constraint: ${\mathbf{compq}}=\mathrm{Nag_UpdateSchur}$ or $\mathrm{Nag_NotQ}$.
3: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $T$.
Constraint: ${\mathbf{n}}\ge 0$.
4: $\mathbf{t}\left[\mathit{dim}\right]$double Input/Output
Note: the dimension, dim, of the array t must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdt}}×{\mathbf{n}}\right)$.
The $\left(i,j\right)$th element of the matrix $T$ is stored in
• ${\mathbf{t}}\left[\left(j-1\right)×{\mathbf{pdt}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{t}}\left[\left(i-1\right)×{\mathbf{pdt}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the $n×n$ upper quasi-triangular matrix $T$ in canonical Schur form, as returned by f08pec.
On exit: t is overwritten by the updated matrix $\stackrel{~}{T}$. See also Section 9.
5: $\mathbf{pdt}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array t.
Constraint: ${\mathbf{pdt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
6: $\mathbf{q}\left[\mathit{dim}\right]$double Input/Output
Note: the dimension, dim, of the array q must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdq}}×{\mathbf{n}}\right)$ when ${\mathbf{compq}}=\mathrm{Nag_UpdateSchur}$;
• $1$ when ${\mathbf{compq}}=\mathrm{Nag_NotQ}$.
The $\left(i,j\right)$th element of the matrix $Q$ is stored in
• ${\mathbf{q}}\left[\left(j-1\right)×{\mathbf{pdq}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{q}}\left[\left(i-1\right)×{\mathbf{pdq}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: if ${\mathbf{compq}}=\mathrm{Nag_UpdateSchur}$, q must contain the $n×n$ orthogonal matrix $Q$ of Schur vectors.
On exit: if ${\mathbf{compq}}=\mathrm{Nag_UpdateSchur}$, q contains the updated matrix of Schur vectors.
If ${\mathbf{compq}}=\mathrm{Nag_NotQ}$, q is not referenced.
7: $\mathbf{pdq}$Integer Input
On entry: the stride separating row or column elements (depending on the value of order) in the array q.
Constraints:
• if ${\mathbf{compq}}=\mathrm{Nag_UpdateSchur}$, ${\mathbf{pdq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{compq}}=\mathrm{Nag_NotQ}$, ${\mathbf{pdq}}\ge 1$.
8: $\mathbf{ifst}$Integer * Input/Output
9: $\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}}$.
10: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_ENUM_INT_2
On entry, ${\mathbf{compq}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdq}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{compq}}=\mathrm{Nag_UpdateSchur}$, ${\mathbf{pdq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
if ${\mathbf{compq}}=\mathrm{Nag_NotQ}$, ${\mathbf{pdq}}\ge 1$.
NE_EXCHANGE
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$.
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pdq}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdq}}>0$.
On entry, ${\mathbf{pdt}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdt}}>0$.
NE_INT_2
On entry, ${\mathbf{pdt}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
NE_INT_3
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{ifst}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{ilst}}=⟨\mathit{\text{value}}⟩$.
Constraint: $1\le {\mathbf{ifst}}\le {\mathbf{n}}$ and $1\le {\mathbf{ilst}}\le {\mathbf{n}}$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

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

f08qfc 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 function. 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}}=\mathrm{Nag_NotQ}$, and $12nr$ if ${\mathbf{compq}}=\mathrm{Nag_UpdateSchur}$, 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 function is f08qtc.

## 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 (f08qfce.c)

### 10.2Program Data

Program Data (f08qfce.d)

### 10.3Program Results

Program Results (f08qfce.r)