# NAG CL Interfacef02gcc (complex_​gen_​eigsys)

Settings help

CL Name Style:

## 1Purpose

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

## 2Specification

 #include
 void f02gcc (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)
The function may be called by the names: f02gcc, nag_eigen_complex_gen_eigsys or nag_complex_eigensystem_sel.

## 3Description

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

## 4References

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

## 5Arguments

1: $\mathbf{crit}$Nag_Select_Eigenvalues Input
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 |{\lambda }_{i}|\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}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
3: $\mathbf{a}\left[{\mathbf{n}}×{\mathbf{tda}}\right]$Complex Input/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×n$ general matrix $A$.
On exit: a contains the Hessenberg form of the balanced input matrix ${A}^{\prime }$ (see Section 9).
4: $\mathbf{tda}$Integer Input
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}$double Input
6: $\mathbf{wu}$double Input
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}$Integer Input
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]$Complex Output
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]$Complex Output
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}$Integer Input
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 7 in the Introduction to the NAG Library CL Interface).

## 6Error 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}}$.

## 7Accuracy

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

## 8Parallelism and Performance

f02gcc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
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.

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

## 10Example

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.1Program Text

Program Text (f02gcce.c)

### 10.2Program Data

Program Data (f02gcce.d)

### 10.3Program Results

Program Results (f02gcce.r)