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_dgeev (f08na)

## Purpose

nag_lapack_dgeev (f08na) computes the eigenvalues and, optionally, the left and/or right eigenvectors for an n$n$ by n$n$ real nonsymmetric matrix A$A$.

## Syntax

[a, wr, wi, vl, vr, info] = f08na(jobvl, jobvr, a, 'n', n)
[a, wr, wi, vl, vr, info] = nag_lapack_dgeev(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 orthogonal similarity transformations, and the QR$QR$ algorithm is then used to further reduce the matrix to upper quasi-triangular Schur form, T$T$, with 1$1$ by 1$1$ and 2$2$ by 2$2$ blocks on the main diagonal. The eigenvalues are computed from T$T$, the 2$2$ by 2$2$ blocks corresponding to complex conjugate pairs and, optionally, the eigenvectors of T$T$ are computed and backtransformed to the eigenvectors 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, : $:$) – double 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

### Output Parameters

1:     a(lda, : $:$) – double 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:     wr( : $:$) – double array
3:     wi( : $:$) – double array
Note: the dimension of the arrays wr and wi must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
wr and wi contain the real and imaginary parts, respectively, of the computed eigenvalues. Complex conjugate pairs of eigenvalues appear consecutively with the eigenvalue having the positive imaginary part first.
4:     vl(ldvl, : $:$) – double 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. If the j$j$th eigenvalue is real, then uj = vl( : ,j)${u}_{j}={\mathbf{vl}}\left(:,j\right)$, the j$j$th column of vl. If the j$j$th and (j + 1)$\left(j+1\right)$st eigenvalues form a complex conjugate pair, then uj = vl( : ,j) + i × vl( : ,j + 1)${u}_{j}={\mathbf{vl}}\left(:,j\right)+i×{\mathbf{vl}}\left(:,j+1\right)$ and uj + 1 = vl( : ,j)i × vl( : ,j + 1)${u}_{j+1}={\mathbf{vl}}\left(:,j\right)-i×{\mathbf{vl}}\left(:,j+1\right)$.
If jobvl = 'N'${\mathbf{jobvl}}=\text{'N'}$, vl is not referenced.
5:     vr(ldvr, : $:$) – double 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. If the j$j$th eigenvalue is real, then vj = vr( : ,j)${v}_{j}={\mathbf{vr}}\left(:,j\right)$, the j$j$th column of vr. If the j$j$th and (j + 1)$\left(j+1\right)$st eigenvalues form a complex conjugate pair, then vj = vr( : ,j) + i × vr( : ,j + 1)${v}_{j}={\mathbf{vr}}\left(:,j\right)+i×{\mathbf{vr}}\left(:,j+1\right)$ and vj + 1 = vr( : ,j)i × vr( : ,j + 1)${v}_{j+1}={\mathbf{vr}}\left(:,j\right)-i×{\mathbf{vr}}\left(:,j+1\right)$.
If jobvr = 'N'${\mathbf{jobvr}}=\text{'N'}$, vr is not referenced.
6:     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: wr, 7: wi, 8: vl, 9: ldvl, 10: vr, 11: ldvr, 12: work, 13: lwork, 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 wr and wi 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 complex analogue of this function is nag_lapack_zgeev (f08nn).

## Example

```function nag_lapack_dgeev_example
jobvl = 'No left vectors';
jobvr = 'Vectors (right)';
a = [0, 0.45, -0.14, -0.17;
0, 0.07, -0.54, 0.35;
0, -0.33, -0.03, 0.17;
0.25, -0.32, -0.13, 0.11];
[aOut, wr, wi, vl, vr, info] = nag_lapack_dgeev(jobvl, jobvr, a)
```
```

aOut =

-0.1280   -0.1651   -0.3690    0.2446
0.6753   -0.1280   -0.1836   -0.1114
0         0   -0.0509    0.1800
0         0         0    0.4569

wr =

-0.1280
-0.1280
-0.0509
0.4569

wi =

0.3339
-0.3339
0
0

vl =

0

vr =

-0.2708    0.3271   -0.3282   -0.6887
0.1909   -0.3732   -0.3848   -0.6091
0.2941   -0.2549   -0.5282    0.3853
0.7018         0   -0.6820   -0.0788

info =

0

```
```function f08na_example
jobvl = 'No left vectors';
jobvr = 'Vectors (right)';
a = [0, 0.45, -0.14, -0.17;
0, 0.07, -0.54, 0.35;
0, -0.33, -0.03, 0.17;
0.25, -0.32, -0.13, 0.11];
[aOut, wr, wi, vl, vr, info] = f08na(jobvl, jobvr, a)
```
```

aOut =

-0.1280   -0.1651   -0.3690    0.2446
0.6753   -0.1280   -0.1836   -0.1114
0         0   -0.0509    0.1800
0         0         0    0.4569

wr =

-0.1280
-0.1280
-0.0509
0.4569

wi =

0.3339
-0.3339
0
0

vl =

0

vr =

-0.2708    0.3271   -0.3282   -0.6887
0.1909   -0.3732   -0.3848   -0.6091
0.2941   -0.2549   -0.5282    0.3853
0.7018         0   -0.6820   -0.0788

info =

0

```