# NAG Library Routine Document

## 1Purpose

f08qyf (ztrsna) estimates condition numbers for specified eigenvalues and/or right eigenvectors of a complex upper triangular matrix.

## 2Specification

Fortran Interface
 Subroutine f08qyf ( job, n, t, ldt, vl, ldvl, vr, ldvr, s, sep, mm, m, work, info)
 Integer, Intent (In) :: n, ldt, ldvl, ldvr, mm, ldwork Integer, Intent (Out) :: m, info Real (Kind=nag_wp), Intent (Inout) :: s(*), sep(*), rwork(*) Complex (Kind=nag_wp), Intent (In) :: t(ldt,*), vl(ldvl,*), vr(ldvr,*) Complex (Kind=nag_wp), Intent (Inout) :: work(ldwork,*) Logical, Intent (In) :: select(*) Character (1), Intent (In) :: job, howmny
#include <nagmk26.h>
 void f08qyf_ (const char *job, const char *howmny, const logical sel[], const Integer *n, const Complex t[], const Integer *ldt, const Complex vl[], const Integer *ldvl, const Complex vr[], const Integer *ldvr, double s[], double sep[], const Integer *mm, Integer *m, Complex work[], const Integer *ldwork, double rwork[], Integer *info, const Charlen length_job, const Charlen length_howmny)
The routine may be called by its LAPACK name ztrsna.

## 3Description

f08qyf (ztrsna) estimates condition numbers for specified eigenvalues and/or right eigenvectors of a complex upper triangular matrix $T$. These are the same as the condition numbers of the eigenvalues and right eigenvectors of an original matrix $A=ZT{Z}^{\mathrm{H}}$ (with unitary $Z$), from which $T$ may have been derived.
f08qyf (ztrsna) computes the reciprocal of the condition number of an eigenvalue ${\lambda }_{i}$ as
 $si = vHu uEvE ,$
where $u$ and $v$ are the right and left eigenvectors of $T$, respectively, corresponding to ${\lambda }_{i}$. This reciprocal condition number always lies between zero (i.e., ill-conditioned) and one (i.e., well-conditioned).
An approximate error estimate for a computed eigenvalue ${\lambda }_{i}$ is then given by
 $εT si ,$
where $\epsilon$ is the machine precision.
To estimate the reciprocal of the condition number of the right eigenvector corresponding to ${\lambda }_{i}$, the routine first calls f08qtf (ztrexc) to reorder the eigenvalues so that ${\lambda }_{i}$ is in the leading position:
 $T =Q λi cH 0 T22 QH.$
The reciprocal condition number of the eigenvector is then estimated as ${\mathit{sep}}_{i}$, the smallest singular value of the matrix $\left({T}_{22}-{\lambda }_{i}I\right)$. This number ranges from zero (i.e., ill-conditioned) to very large (i.e., well-conditioned).
An approximate error estimate for a computed right eigenvector $u$ corresponding to ${\lambda }_{i}$ is then given by
 $εT sepi .$

## 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 eigenvalues and/or eigenvectors.
${\mathbf{job}}=\text{'E'}$
Condition numbers for eigenvalues only are computed.
${\mathbf{job}}=\text{'V'}$
Condition numbers for eigenvectors only are computed.
${\mathbf{job}}=\text{'B'}$
Condition numbers for both eigenvalues and eigenvectors are computed.
Constraint: ${\mathbf{job}}=\text{'E'}$, $\text{'V'}$ or $\text{'B'}$.
2:     $\mathbf{howmny}$ – Character(1)Input
On entry: indicates how many condition numbers are to be computed.
${\mathbf{howmny}}=\text{'A'}$
Condition numbers for all eigenpairs are computed.
${\mathbf{howmny}}=\text{'S'}$
Condition numbers for selected eigenpairs (as specified by select) are computed.
Constraint: ${\mathbf{howmny}}=\text{'A'}$ or $\text{'S'}$.
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)$ if ${\mathbf{howmny}}=\text{'S'}$, and at least $1$ otherwise.
On entry: specifies the eigenpairs for which condition numbers are to be computed if ${\mathbf{howmny}}=\text{'S'}$. To select condition numbers for the eigenpair corresponding to the eigenvalue ${\lambda }_{j}$, ${\mathbf{select}}\left(j\right)$ must be set to .TRUE..
If ${\mathbf{howmny}}=\text{'A'}$, select is not referenced.
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
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).
6:     $\mathbf{ldt}$ – IntegerInput
On entry: the first dimension of the array t as declared in the (sub)program from which f08qyf (ztrsna) is called.
Constraint: ${\mathbf{ldt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
7:     $\mathbf{vl}\left({\mathbf{ldvl}},*\right)$ – Complex (Kind=nag_wp) arrayInput
Note: the second dimension of the array vl must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if ${\mathbf{job}}=\text{'E'}$ or $\text{'B'}$.
On entry: if ${\mathbf{job}}=\text{'E'}$ or $\text{'B'}$, vl must contain the left eigenvectors of $T$ (or of any matrix $QT{Q}^{\mathrm{H}}$ with $Q$ unitary) corresponding to the eigenpairs specified by howmny and select. The eigenvectors must be stored in consecutive columns of vl, as returned by f08pxf (zhsein) or f08qxf (ztrevc).
If ${\mathbf{job}}=\text{'V'}$, vl is not referenced.
8:     $\mathbf{ldvl}$ – IntegerInput
On entry: the first dimension of the array vl as declared in the (sub)program from which f08qyf (ztrsna) is called.
Constraints:
• if ${\mathbf{job}}=\text{'E'}$ or $\text{'B'}$, ${\mathbf{ldvl}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{job}}=\text{'V'}$, ${\mathbf{ldvl}}\ge 1$.
9:     $\mathbf{vr}\left({\mathbf{ldvr}},*\right)$ – Complex (Kind=nag_wp) arrayInput
Note: the second dimension of the array vr must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if ${\mathbf{job}}=\text{'E'}$ or $\text{'B'}$.
On entry: if ${\mathbf{job}}=\text{'E'}$ or $\text{'B'}$, vr must contain the right eigenvectors of $T$ (or of any matrix $QT{Q}^{\mathrm{H}}$ with $Q$ unitary) corresponding to the eigenpairs specified by howmny and select. The eigenvectors must be stored in consecutive columns of vr, as returned by f08pxf (zhsein) or f08qxf (ztrevc).
If ${\mathbf{job}}=\text{'V'}$, vr is not referenced.
10:   $\mathbf{ldvr}$ – IntegerInput
On entry: the first dimension of the array vr as declared in the (sub)program from which f08qyf (ztrsna) is called.
Constraints:
• if ${\mathbf{job}}=\text{'E'}$ or $\text{'B'}$, ${\mathbf{ldvr}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{job}}=\text{'V'}$, ${\mathbf{ldvr}}\ge 1$.
11:   $\mathbf{s}\left(*\right)$ – Real (Kind=nag_wp) arrayOutput
Note: the dimension of the array s must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if ${\mathbf{job}}=\text{'E'}$ or $\text{'B'}$.
On exit: the reciprocal condition numbers of the selected eigenvalues if ${\mathbf{job}}=\text{'E'}$ or $\text{'B'}$, stored in consecutive elements of the array. Thus ${\mathbf{s}}\left(j\right)$, ${\mathbf{sep}}\left(j\right)$ and the $j$th columns of vl and vr all correspond to the same eigenpair (but not in general the $j$th eigenpair unless all eigenpairs have been selected).
If ${\mathbf{job}}=\text{'V'}$, s is not referenced.
12:   $\mathbf{sep}\left(*\right)$ – Real (Kind=nag_wp) arrayOutput
Note: the dimension of the array sep must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if ${\mathbf{job}}=\text{'V'}$ or $\text{'B'}$, and at least $1$ otherwise.
On exit: the estimated reciprocal condition numbers of the selected right eigenvectors if ${\mathbf{job}}=\text{'V'}$ or $\text{'B'}$, stored in consecutive elements of the array.
If ${\mathbf{job}}=\text{'E'}$, sep is not referenced.
13:   $\mathbf{mm}$ – IntegerInput
On entry: the number of elements in the arrays s and sep, and the number of columns in the arrays vl and vr (if used). The precise number required, $\mathit{m}$, is $n$ if ${\mathbf{howmny}}=\text{'A'}$; if ${\mathbf{howmny}}=\text{'S'}$, $\mathit{m}$ is the number of selected eigenpairs (see select), in which case $0\le \mathit{m}\le n$.
Constraints:
• if ${\mathbf{howmny}}=\text{'A'}$, ${\mathbf{mm}}\ge {\mathbf{n}}$;
• otherwise ${\mathbf{mm}}\ge \mathit{m}$.
14:   $\mathbf{m}$ – IntegerOutput
On exit: $\mathit{m}$, the number of selected eigenpairs. If ${\mathbf{howmny}}=\text{'A'}$, m is set to $n$.
15:   $\mathbf{work}\left({\mathbf{ldwork}},*\right)$ – Complex (Kind=nag_wp) arrayWorkspace
Note: the second dimension of the array work must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}+1\right)$ if ${\mathbf{job}}=\text{'V'}$ or $\text{'B'}$ and at least $1$ if ${\mathbf{job}}=\text{'E'}$.
If ${\mathbf{job}}=\text{'E'}$, work is not referenced.
16:   $\mathbf{ldwork}$ – IntegerInput
On entry: the first dimension of the array work as declared in the (sub)program from which f08qyf (ztrsna) is called.
Constraints:
• if ${\mathbf{job}}=\text{'V'}$ or $\text{'B'}$, ${\mathbf{ldwork}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{job}}=\text{'E'}$, ${\mathbf{ldwork}}\ge 1$.
17:   $\mathbf{rwork}\left(*\right)$ – Real (Kind=nag_wp) arrayWorkspace
Note: the dimension of the array rwork must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
18:   $\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 values ${\mathit{sep}}_{i}$ may over estimate the true value, but seldom by a factor of more than $3$.

## 8Parallelism and Performance

f08qyf (ztrsna) 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 f08qlf (dtrsna).

## 10Example

This example computes approximate error estimates for all the eigenvalues and right eigenvectors of the matrix $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 .$

### 10.1Program Text

Program Text (f08qyfe.f90)

### 10.2Program Data

Program Data (f08qyfe.d)

### 10.3Program Results

Program Results (f08qyfe.r)