Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_zgeev (f08nn)

## Purpose

nag_lapack_zgeev (f08nn) computes the eigenvalues and, optionally, the left and/or right eigenvectors for an n$n$ by n$n$ complex nonsymmetric matrix A$A$.

## Syntax

[a, w, vl, vr, info] = f08nn(jobvl, jobvr, a, 'n', n)
[a, w, vl, vr, info] = nag_lapack_zgeev(jobvl, jobvr, a, 'n', n)

## Description

The right eigenvector vj${v}_{j}$ of A$A$ satisfies
 A vj = λj vj $A vj = λj vj$
where λj${\lambda }_{j}$ is the j$j$th eigenvalue of A$A$. The left eigenvector uj${u}_{j}$ of A$A$ satisfies
 ujH A = λj ujH $ujH A = λj ujH$
where ujH${u}_{j}^{\mathrm{H}}$ denotes the conjugate transpose of uj${u}_{j}$.
The matrix A$A$ is first reduced to upper Hessenberg form by means of unitary similarity transformations, and the QR$QR$ algorithm is then used to further reduce the matrix to upper triangular Schur form, T$T$, from which the eigenvalues are computed. Optionally, the eigenvectors of T$T$ are also computed and backtransformed to those of A$A$.

## References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## Parameters

### Compulsory Input Parameters

1:     jobvl – string (length ≥ 1)
If jobvl = 'N'${\mathbf{jobvl}}=\text{'N'}$, the left eigenvectors of A$A$ are not computed.
If jobvl = 'V'${\mathbf{jobvl}}=\text{'V'}$, the left eigenvectors of A$A$ are computed.
Constraint: jobvl = 'N'${\mathbf{jobvl}}=\text{'N'}$ or 'V'$\text{'V'}$.
2:     jobvr – string (length ≥ 1)
If jobvr = 'N'${\mathbf{jobvr}}=\text{'N'}$, the right eigenvectors of A$A$ are not computed.
If jobvr = 'V'${\mathbf{jobvr}}=\text{'V'}$, the right eigenvectors of A$A$ are computed.
Constraint: jobvr = 'N'${\mathbf{jobvr}}=\text{'N'}$ or 'V'$\text{'V'}$.
3:     a(lda, : $:$) – complex array
The first dimension of the array a must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The n$n$ by n$n$ matrix A$A$.

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array a and the second dimension of the array a. (An error is raised if these dimensions are not equal.)
n$n$, the order of the matrix A$A$.
Constraint: n0${\mathbf{n}}\ge 0$.

### Input Parameters Omitted from the MATLAB Interface

lda ldvl ldvr work lwork rwork

### Output Parameters

1:     a(lda, : $:$) – complex array
The first dimension of the array a will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
2:     w( : $:$) – complex array
Note: the dimension of the array w must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
Contains the computed eigenvalues.
3:     vl(ldvl, : $:$) – complex array
The first dimension, ldvl, of the array vl will be
• if jobvl = 'V'${\mathbf{jobvl}}=\text{'V'}$, ldvl max (1,n) $\mathit{ldvl}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ldvl1$\mathit{ldvl}\ge 1$.
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if jobvl = 'V'${\mathbf{jobvl}}=\text{'V'}$, and at least 1$1$ otherwise
If jobvl = 'V'${\mathbf{jobvl}}=\text{'V'}$, the left eigenvectors uj${u}_{j}$ are stored one after another in the columns of vl, in the same order as their corresponding eigenvalues; that is uj = vl( : ,j)${u}_{j}={\mathbf{vl}}\left(:,j\right)$, the j$j$th column of vl.
If jobvl = 'N'${\mathbf{jobvl}}=\text{'N'}$, vl is not referenced.
4:     vr(ldvr, : $:$) – complex array
The first dimension, ldvr, of the array vr will be
• if jobvr = 'V'${\mathbf{jobvr}}=\text{'V'}$, ldvr max (1,n) $\mathit{ldvr}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ldvr1$\mathit{ldvr}\ge 1$.
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if jobvr = 'V'${\mathbf{jobvr}}=\text{'V'}$, and at least 1$1$ otherwise
If jobvr = 'V'${\mathbf{jobvr}}=\text{'V'}$, the right eigenvectors vj${v}_{j}$ are stored one after another in the columns of vr, in the same order as their corresponding eigenvalues; that is vj = vr( : ,j)${v}_{j}={\mathbf{vr}}\left(:,j\right)$, the j$j$th column of vr.
If jobvr = 'N'${\mathbf{jobvr}}=\text{'N'}$, vr is not referenced.
5:     info – int64int32nag_int scalar
info = 0${\mathbf{info}}=0$ unless the function detects an error (see Section [Error Indicators and Warnings]).

## Error Indicators and Warnings

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ had an illegal value on entry. The parameters are numbered as follows:
1: jobvl, 2: jobvr, 3: n, 4: a, 5: lda, 6: w, 7: vl, 8: ldvl, 9: vr, 10: ldvr, 11: work, 12: lwork, 13: rwork, 14: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.
W INFO > 0${\mathbf{INFO}}>0$
If info = i${\mathbf{info}}=i$, the QR$QR$ algorithm failed to compute all the eigenvalues, and no eigenvectors have been computed; elements i + 1 : n$i+1:{\mathbf{n}}$ of w contain eigenvalues which have converged.

## Accuracy

The computed eigenvalues and eigenvectors are exact for a nearby matrix (A + E)$\left(A+E\right)$, where
 ‖E‖2 = O(ε) ‖A‖2 , $‖E‖2 = O(ε) ‖A‖2 ,$
and ε$\epsilon$ is the machine precision. See Section 4.8 of Anderson et al. (1999) for further details.

Each eigenvector is normalized to have Euclidean norm equal to unity and the element of largest absolute value real and positive.
The total number of floating point operations is proportional to n3${n}^{3}$.
The real analogue of this function is nag_lapack_dgeev (f08na).

## Example

```function nag_lapack_zgeev_example
jobvl = 'No left vectors';
jobvr = 'Vectors (right)';
a = [0,  -4.11 + 3.7i,  -0.34 + 1.01i,  1.29 - 0.86i;
0 + 0i,  1.52 - 0.43i,  1.88 - 5.38i,  3.36 + 0.65i;
0 + 0i,  2.5 + 3.45i,  0.88 - 1.08i,  0.64 - 1.48i;
-1.1 + 0.82i,  1.81 - 1.59i,  3.25 + 1.33i,  1.57 - 3.44i];
[aOut, w, vl, vr, info] = nag_lapack_zgeev(jobvl, jobvr, a)
```
```

aOut =

-4.8428 + 0.1160i   0.6732 + 2.5490i   1.1615 - 0.7687i   0.3890 + 0.5858i
0.0000 + 0.0000i  -0.1019 - 0.0784i   1.2544 + 3.4039i  -1.0927 + 1.0847i
0.0000 + 0.0000i   0.0000 + 0.0000i   2.2454 - 3.1030i  -2.0702 - 1.5769i
0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   6.6694 - 1.8845i

w =

-4.8428 + 0.1160i
-0.1019 - 0.0784i
2.2454 - 3.1030i
6.6694 - 1.8845i

vl =

1.0027e-316 +1.0027e-316i

vr =

0.6389 + 0.0000i   0.9676 + 0.0000i   0.4172 - 0.2851i  -0.4783 + 0.1809i
0.3594 + 0.4192i   0.0552 + 0.0759i   0.0013 + 0.3266i   0.6645 + 0.0000i
0.2314 - 0.4052i   0.0393 - 0.1345i  -0.0528 - 0.2842i   0.2389 + 0.3280i
-0.2469 - 0.0905i   0.1730 + 0.0738i   0.7446 + 0.0000i   0.3302 - 0.1525i

info =

0

```
```function f08nn_example
jobvl = 'No left vectors';
jobvr = 'Vectors (right)';
a = [0,  -4.11 + 3.7i,  -0.34 + 1.01i,  1.29 - 0.86i;
0 + 0i,  1.52 - 0.43i,  1.88 - 5.38i,  3.36 + 0.65i;
0 + 0i,  2.5 + 3.45i,  0.88 - 1.08i,  0.64 - 1.48i;
-1.1 + 0.82i,  1.81 - 1.59i,  3.25 + 1.33i,  1.57 - 3.44i];
[aOut, w, vl, vr, info] = f08nn(jobvl, jobvr, a)
```
```

aOut =

-4.8428 + 0.1160i   0.6732 + 2.5490i   1.1615 - 0.7687i   0.3890 + 0.5858i
0.0000 + 0.0000i  -0.1019 - 0.0784i   1.2544 + 3.4039i  -1.0927 + 1.0847i
0.0000 + 0.0000i   0.0000 + 0.0000i   2.2454 - 3.1030i  -2.0702 - 1.5769i
0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   6.6694 - 1.8845i

w =

-4.8428 + 0.1160i
-0.1019 - 0.0784i
2.2454 - 3.1030i
6.6694 - 1.8845i

vl =

0.0000 + 0.0000i

vr =

0.6389 + 0.0000i   0.9676 + 0.0000i   0.4172 - 0.2851i  -0.4783 + 0.1809i
0.3594 + 0.4192i   0.0552 + 0.0759i   0.0013 + 0.3266i   0.6645 + 0.0000i
0.2314 - 0.4052i   0.0393 - 0.1345i  -0.0528 - 0.2842i   0.2389 + 0.3280i
-0.2469 - 0.0905i   0.1730 + 0.0738i   0.7446 + 0.0000i   0.3302 - 0.1525i

info =

0

```