f02 Chapter Contents
f02 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_complex_eigensystem_sel (f02gcc)

## 1  Purpose

nag_complex_eigensystem_sel (f02gcc) computes selected eigenvalues and eigenvectors of a complex general matrix.

## 2  Specification

 #include #include
 void nag_complex_eigensystem_sel (Nag_Select_Eigenvalues crit, Integer n, Complex a[], Integer tda, double wl, double wu, Integer mest, Integer *m, Complex w[], Complex v[], Integer tdv, NagError *fail)

## 3  Description

nag_complex_eigensystem_sel (f02gcc) computes selected eigenvalues and the corresponding right eigenvectors of a complex general matrix $A$:
 $Ax i = λ i x i .$
Eigenvalues ${\lambda }_{i}$ may be selected either by modulus, satisfying:
 $w l ≤ λ i ≤ w u ,$
or by real part, satisfying:
 $w l ≤ Re λ i ≤ w u .$

## 4  References

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

## 5  Arguments

1:    $\mathbf{crit}$Nag_Select_EigenvaluesInput
On entry: indicates the criterion for selecting eigenvalues:
• if ${\mathbf{crit}}=\mathrm{Nag_Select_Modulus}$, then eigenvalues are selected according to their moduli: ${w}_{l}\le \left|{\lambda }_{i}\right|\le {w}_{u}$.
• if ${\mathbf{crit}}=\mathrm{Nag_Select_RealPart}$, then eigenvalues are selected according to their real parts: ${w}_{l}\le \mathrm{Re}\left({\lambda }_{i}\right)\le {w}_{u}$.
Constraint: ${\mathbf{crit}}=\mathrm{Nag_Select_Modulus}$ or $\mathrm{Nag_Select_RealPart}$.
2:    $\mathbf{n}$IntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
3:    $\mathbf{a}\left[{\mathbf{n}}×{\mathbf{tda}}\right]$ComplexInput/Output
Note: the $\left(i,j\right)$th element of the matrix $A$ is stored in ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{tda}}+j-1\right]$.
On entry: the $n$ by $n$ general matrix $A$.
On exit: a contains the Hessenberg form of the balanced input matrix ${A}^{\prime }$ (see Section 9).
4:    $\mathbf{tda}$IntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: ${\mathbf{tda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
5:    $\mathbf{wl}$doubleInput
6:    $\mathbf{wu}$doubleInput
On entry: ${w}_{l}$ and ${w}_{u}$, the lower and upper bounds on the criterion for the selected eigenvalues.
Constraint: ${\mathbf{wu}}>{\mathbf{wl}}$.
7:    $\mathbf{mest}$IntegerInput
On entry: mest must be an upper bound on $m$, the number of eigenvalues and eigenvectors selected. No eigenvectors are computed if ${\mathbf{mest}}.
Constraint: ${\mathbf{mest}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,m\right)$.
8:    $\mathbf{m}$Integer *Output
On exit: $m$, the number of eigenvalues actually selected.
9:    $\mathbf{w}\left[\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)\right]$ComplexOutput
On exit: the first m elements of w hold the selected eigenvalues; elements from the index m to ${\mathbf{n}}-1$ contain the other eigenvalues.
10:  $\mathbf{v}\left[{\mathbf{n}}×{\mathbf{tdv}}\right]$ComplexOutput
Note: the $\left(i,j\right)$th element of the matrix $V$ is stored in ${\mathbf{v}}\left[\left(i-1\right)×{\mathbf{tdv}}+j-1\right]$.
On exit: v contains the selected eigenvectors, with the $i$th column holding the eigenvector associated with the eigenvalue ${\lambda }_{i}$ (stored in ${\mathbf{w}}\left[i-1\right]$).
11:  $\mathbf{tdv}$IntegerInput
On entry: the stride separating matrix column elements in the array v.
Constraint: ${\mathbf{tdv}}\ge {\mathbf{mest}}$.
12:  $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, ${\mathbf{tdv}}=〈\mathit{\text{value}}〉$ while ${\mathbf{mest}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdv}}\ge {\mathbf{mest}}$.
NE_2_REAL_ARG_LE
On entry, ${\mathbf{wu}}=〈\mathit{\text{value}}〉$ while ${\mathbf{wl}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{wu}}>{\mathbf{wl}}$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument crit had an illegal value.
NE_EIGVEC
Inverse iteration failed to compute all the specified eigenvectors. If an eigenvector failed to converge, the corresponding column of v is set to zero.
NE_INT_2
On entry, ${\mathbf{tda}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{tda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
NE_INT_ARG_LT
On entry, ${\mathbf{mest}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{mest}}\ge 1$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
NE_QR_FAIL
The QR algorithm failed to compute all the eigenvalues. No eigenvectors have been computed.
NE_REQD_EIGVAL
There are more than mest eigenvalues in the specified range. The actual number of eigenvalues in the range is returned in m. No eigenvectors have been computed.
Rerun with the second dimension of ${\mathbf{v}}={\mathbf{mest}}\ge {\mathbf{m}}$.

## 7  Accuracy

If ${\lambda }_{i}$ is an exact eigenvalue, and ${\stackrel{~}{\lambda }}_{i}$ is the corresponding computed value, then
 $λ ~ i - λ i ≤ c n ε A ′ 2 s i ,$
where $c\left(n\right)$ is a modestly increasing function of $n$, $\epsilon$ is the machine precision, and ${s}_{i}$ is the reciprocal condition number of ${\lambda }_{i}$; ${A}^{\prime }$ is the balanced form of the original matrix $A$, and $‖{A}^{\prime }‖\le ‖A‖$.
If ${x}_{i}$ is the corresponding exact 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 , x i ≤ c n ε A ′ 2 sep i$
where ${sep}_{i}$ is the reciprocal condition number of ${x}_{i}$.

## 8  Parallelism and Performance

Not applicable.

nag_complex_eigensystem_sel (f02gcc) first balances the matrix, using a diagonal similarity transformation to reduce its norm; and then reduces the balanced matrix ${A}^{\prime }$ to upper Hessenberg form $H$, using a unitary similarity transformation: ${A}^{\prime }={QHQ}^{H}$. The function uses the Hessenberg $QR$ algorithm to compute all the eigenvalues of $H$, which are the same as the eigenvalues of $A$. It computes the eigenvectors of $H$ which correspond to the selected eigenvalues, using inverse iteration. It premultiplies the eigenvectors by $Q$ to form the eigenvectors of ${A}^{\prime }$; and finally transforms the eigenvectors to those of the original matrix $A$.
Each eigenvector $x$ is normalized so that ${‖x‖}_{2}=1$, and the element of largest absolute value is real and positive.
The inverse iteration function may make a small perturbation to the real parts of close eigenvalues, and this may shift their moduli just outside the specified bounds. If you are relying on eigenvalues being within the bounds, you should test them on return from nag_complex_eigensystem_sel (f02gcc).
The time taken by the function is approximately proportional to ${n}^{3}$.
The function can be used to compute all eigenvalues and eigenvectors, by setting wl large and negative, and wu large and positive.

## 10  Example

To compute those eigenvalues of the matrix $A$ whose moduli lie in the range $\left[-5.5,+5.5\right]$, and their corresponding eigenvectors, where
 $A = -3.97 - 5.04 i -4.11 + 3.70 i -0.34 + 1.01 i 1.29 - 0.86 i - 0.34 - 1.50 i - 1.52 - 0.43 i - 1.88 - 5.38 i 3.36 + 0.65 i - 3.31 - 3.85 i - 2.50 + 3.45 i - 0.88 - 1.08 i 0.64 - 1.48 i -1.10 + 0.82 i - 1.81 - 1.59 i - 3.25 + 1.33 i 1.57 - 3.44 i$

### 10.1  Program Text

Program Text (f02gcce.c)

### 10.2  Program Data

Program Data (f02gcce.d)

### 10.3  Program Results

Program Results (f02gcce.r)