# NAG FL Interfacef08qkf (dtrevc)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f08qkf computes selected left and/or right eigenvectors of a real upper quasi-triangular matrix.

## 2Specification

Fortran Interface
 Subroutine f08qkf ( job, n, t, ldt, vl, ldvl, vr, ldvr, mm, m, work, info)
 Integer, Intent (In) :: n, ldt, ldvl, ldvr, mm Integer, Intent (Out) :: m, info Real (Kind=nag_wp), Intent (In) :: t(ldt,*) Real (Kind=nag_wp), Intent (Inout) :: vl(ldvl,*), vr(ldvr,*) Real (Kind=nag_wp), Intent (Out) :: work(3*n) Logical, Intent (Inout) :: select(*) Character (1), Intent (In) :: job, howmny
#include <nag.h>
 void f08qkf_ (const char *job, const char *howmny, logical sel[], const Integer *n, const double t[], const Integer *ldt, double vl[], const Integer *ldvl, double vr[], const Integer *ldvr, const Integer *mm, Integer *m, double work[], Integer *info, const Charlen length_job, const Charlen length_howmny)
The routine may be called by the names f08qkf, nagf_lapackeig_dtrevc or its LAPACK name dtrevc.

## 3Description

f08qkf computes left and/or right eigenvectors of a real upper quasi-triangular matrix $T$ in canonical Schur form. Such a matrix arises from the Schur factorization of a real general matrix, as computed by f08pef, for example.
The right eigenvector $x$, and the left eigenvector $y$, corresponding to an eigenvalue $\lambda$, are defined by:
 $Tx = λx and yHT = λyH (or ​TTy=λ¯y) .$
Note that even though $T$ is real, $\lambda$, $x$ and $y$ may be complex. If $x$ is an eigenvector corresponding to a complex eigenvalue $\lambda$, then the complex conjugate vector $\overline{x}$ is the eigenvector corresponding to the complex conjugate eigenvalue $\overline{\lambda }$.
The routine can compute the eigenvectors corresponding to selected eigenvalues, or it can compute all the eigenvectors. In the latter case the eigenvectors may optionally be pre-multiplied by an input matrix $Q$. Normally $Q$ is an orthogonal matrix from the Schur factorization of a matrix $A$ as $A=QT{Q}^{\mathrm{T}}$; if $x$ is a (left or right) eigenvector of $T$, then $Qx$ is an eigenvector of $A$.
The eigenvectors are computed by forward or backward substitution. They are scaled so that, for a real eigenvector $x$, $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(|{x}_{i}|\right)=1$, and for a complex eigenvector, $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(|\mathrm{Re}\left({x}_{i}\right)|+|\mathrm{Im}\left({x}_{i}\right)|\right)=1$.

## 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 left and/or right eigenvectors are to be computed.
${\mathbf{job}}=\text{'R'}$
Only right eigenvectors are computed.
${\mathbf{job}}=\text{'L'}$
Only left eigenvectors are computed.
${\mathbf{job}}=\text{'B'}$
Both left and right eigenvectors are computed.
Constraint: ${\mathbf{job}}=\text{'R'}$, $\text{'L'}$ or $\text{'B'}$.
2: $\mathbf{howmny}$Character(1) Input
On entry: indicates how many eigenvectors are to be computed.
${\mathbf{howmny}}=\text{'A'}$
All eigenvectors (as specified by job) are computed.
${\mathbf{howmny}}=\text{'B'}$
All eigenvectors (as specified by job) are computed and then pre-multiplied by the matrix $Q$ (which is overwritten).
${\mathbf{howmny}}=\text{'S'}$
Selected eigenvectors (as specified by job and select) are computed.
Constraint: ${\mathbf{howmny}}=\text{'A'}$, $\text{'B'}$ or $\text{'S'}$.
3: $\mathbf{select}\left(*\right)$Logical array Input/Output
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 which eigenvectors are to be computed if ${\mathbf{howmny}}=\text{'S'}$. To obtain the real eigenvector corresponding to the real eigenvalue ${\lambda }_{j}$, ${\mathbf{select}}\left(j\right)$ must be set .TRUE.. To select the complex eigenvector corresponding to a complex conjugate pair of eigenvalues ${\lambda }_{j}$ and ${\lambda }_{j+1}$, ${\mathbf{select}}\left(j\right)$ and/or ${\mathbf{select}}\left(j+1\right)$ must be set .TRUE.; the eigenvector corresponding to the first eigenvalue in the pair is computed.
On exit: if a complex eigenvector was selected as specified above, ${\mathbf{select}}\left(j\right)$ is set to .TRUE. and ${\mathbf{select}}\left(j+1\right)$ to .FALSE..
If ${\mathbf{howmny}}=\text{'A'}$ or $\text{'B'}$, select is not referenced.
4: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $T$.
Constraint: ${\mathbf{n}}\ge 0$.
5: $\mathbf{t}\left({\mathbf{ldt}},*\right)$Real (Kind=nag_wp) array Input
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.
6: $\mathbf{ldt}$Integer Input
On entry: the first dimension of the array t as declared in the (sub)program from which f08qkf 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)$Real (Kind=nag_wp) array Input/Output
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{'L'}$ or $\text{'B'}$.
On entry: if ${\mathbf{howmny}}=\text{'B'}$ and ${\mathbf{job}}=\text{'L'}$ or $\text{'B'}$, vl must contain an $n×n$ matrix $Q$ (usually the matrix of Schur vectors returned by f08pef).
If ${\mathbf{howmny}}=\text{'A'}$ or $\text{'S'}$, vl need not be set.
On exit: if ${\mathbf{job}}=\text{'L'}$ or $\text{'B'}$, vl contains the computed left eigenvectors (as specified by howmny and select). The eigenvectors are stored consecutively in the columns of the array, in the same order as their eigenvalues. Corresponding to each real eigenvalue is a real eigenvector, occupying one column. Corresponding to each complex conjugate pair of eigenvalues, is a complex eigenvector occupying two columns; the first column holds the real part and the second column holds the imaginary part.
If ${\mathbf{job}}=\text{'R'}$, vl is not referenced.
8: $\mathbf{ldvl}$Integer Input
On entry: the first dimension of the array vl as declared in the (sub)program from which f08qkf is called.
Constraints:
• if ${\mathbf{job}}=\text{'L'}$ or $\text{'B'}$, ${\mathbf{ldvl}}\ge {\mathbf{n}}$;
• if ${\mathbf{job}}=\text{'R'}$, ${\mathbf{ldvl}}\ge 1$.
9: $\mathbf{vr}\left({\mathbf{ldvr}},*\right)$Real (Kind=nag_wp) array Input/Output
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{'R'}$ or $\text{'B'}$.
On entry: if ${\mathbf{howmny}}=\text{'B'}$ and ${\mathbf{job}}=\text{'R'}$ or $\text{'B'}$, vr must contain an $n×n$ matrix $Q$ (usually the matrix of Schur vectors returned by f08pef).
If ${\mathbf{howmny}}=\text{'A'}$ or $\text{'S'}$, vr need not be set.
On exit: if ${\mathbf{job}}=\text{'R'}$ or $\text{'B'}$, vr contains the computed right eigenvectors (as specified by howmny and select). The eigenvectors are stored consecutively in the columns of the array, in the same order as their eigenvalues. Corresponding to each real eigenvalue is a real eigenvector, occupying one column. Corresponding to each complex conjugate pair of eigenvalues, is a complex eigenvector occupying two columns; the first column holds the real part and the second column holds the imaginary part.
If ${\mathbf{job}}=\text{'L'}$, vr is not referenced.
10: $\mathbf{ldvr}$Integer Input
On entry: the first dimension of the array vr as declared in the (sub)program from which f08qkf is called.
Constraints:
• if ${\mathbf{job}}=\text{'R'}$ or $\text{'B'}$, ${\mathbf{ldvr}}\ge {\mathbf{n}}$;
• if ${\mathbf{job}}=\text{'L'}$, ${\mathbf{ldvr}}\ge 1$.
11: $\mathbf{mm}$Integer Input
On entry: the number of columns in the arrays vl and/or vr. The precise number of columns required, $\mathit{m}$, is $n$ if ${\mathbf{howmny}}=\text{'A'}$ or $\text{'B'}$; if ${\mathbf{howmny}}=\text{'S'}$, $\mathit{m}$ is obtained by counting $1$ for each selected real eigenvector and $2$ for each selected complex eigenvector (see select), in which case $0\le \mathit{m}\le n$.
Constraints:
• if ${\mathbf{howmny}}=\text{'A'}$ or $\text{'B'}$, ${\mathbf{mm}}\ge {\mathbf{n}}$;
• otherwise ${\mathbf{mm}}\ge \mathit{m}$.
12: $\mathbf{m}$Integer Output
On exit: $\mathit{m}$, the number of columns of vl and/or vr actually used to store the computed eigenvectors. If ${\mathbf{howmny}}=\text{'A'}$ or $\text{'B'}$, m is set to $n$.
13: $\mathbf{work}\left(3×{\mathbf{n}}\right)$Real (Kind=nag_wp) array Workspace
14: $\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.

## 7Accuracy

If ${x}_{i}$ is an exact right eigenvector, and ${\stackrel{~}{x}}_{i}$ is the corresponding computed eigenvector, then the angle $\theta \left({\stackrel{~}{x}}_{i},{x}_{i}\right)$ between them is bounded as follows:
 $θ (x~i,xi) ≤ c (n) ε ‖T‖2 sepi$
where ${\mathit{sep}}_{i}$ is the reciprocal condition number of ${x}_{i}$.
The condition number ${\mathit{sep}}_{i}$ may be computed by calling f08qlf.