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_ztgevc (f08yx)

## Purpose

nag_lapack_ztgevc (f08yx) computes some or all of the right and/or left generalized eigenvectors of a pair of complex upper triangular matrices (A,B)$\left(A,B\right)$.

## Syntax

[vl, vr, m, info] = f08yx(side, howmny, select, a, b, vl, vr, mm, 'n', n)
[vl, vr, m, info] = nag_lapack_ztgevc(side, howmny, select, a, b, vl, vr, mm, 'n', n)

## Description

nag_lapack_ztgevc (f08yx) computes some or all of the right and/or left generalized eigenvectors of the matrix pair (A,B)$\left(A,B\right)$ which is assumed to be in upper triangular form. If the matrix pair (A,B)$\left(A,B\right)$ is not upper triangular then the function nag_lapack_zhgeqz (f08xs) should be called before invoking nag_lapack_ztgevc (f08yx).
The right generalized eigenvector x$x$ and the left generalized eigenvector y$y$ of (A,B)$\left(A,B\right)$ corresponding to a generalized eigenvalue λ$\lambda$ are defined by
 (A − λB)x = 0 $(A-λB)x=0$
and
 yH (A − λB) = 0. $yH (A-λ B)=0.$
If a generalized eigenvalue is determined as 0 / 0$0/0$, which is due to zero diagonal elements at the same locations in both A$A$ and B$B$, a unit vector is returned as the corresponding eigenvector.
Note that the generalized eigenvalues are computed using nag_lapack_zhgeqz (f08xs) but nag_lapack_ztgevc (f08yx) does not explicitly require the generalized eigenvalues to compute eigenvectors. The ordering of the eigenvectors is based on the ordering of the eigenvalues as computed by nag_lapack_ztgevc (f08yx).
If all eigenvectors are requested, the function may either return the matrices X$X$ and/or Y$Y$ of right or left eigenvectors of (A,B)$\left(A,B\right)$, or the products ZX$ZX$ and/or QY$QY$, where Z$Z$ and Q$Q$ are two matrices supplied by you. Usually, Q$Q$ and Z$Z$ are chosen as the unitary matrices returned by nag_lapack_zhgeqz (f08xs). Equivalently, Q$Q$ and Z$Z$ are the left and right Schur vectors of the matrix pair supplied to nag_lapack_zhgeqz (f08xs). In that case, QY$QY$ and ZX$ZX$ are the left and right generalized eigenvectors, respectively, of the matrix pair supplied to nag_lapack_zhgeqz (f08xs).

## 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
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Moler C B and Stewart G W (1973) An algorithm for generalized matrix eigenproblems SIAM J. Numer. Anal. 10 241–256
Stewart G W and Sun J-G (1990) Matrix Perturbation Theory Academic Press, London

## Parameters

### Compulsory Input Parameters

1:     side – string (length ≥ 1)
Specifies the required sets of generalized eigenvectors.
side = 'R'${\mathbf{side}}=\text{'R'}$
Only right eigenvectors are computed.
side = 'L'${\mathbf{side}}=\text{'L'}$
Only left eigenvectors are computed.
side = 'B'${\mathbf{side}}=\text{'B'}$
Both left and right eigenvectors are computed.
Constraint: side = 'B'${\mathbf{side}}=\text{'B'}$, 'L'$\text{'L'}$ or 'R'$\text{'R'}$.
2:     howmny – string (length ≥ 1)
Specifies further details of the required generalized eigenvectors.
howmny = 'A'${\mathbf{howmny}}=\text{'A'}$
All right and/or left eigenvectors are computed.
howmny = 'B'${\mathbf{howmny}}=\text{'B'}$
All right and/or left eigenvectors are computed; they are backtransformed using the input matrices supplied in arrays vr and/or vl.
howmny = 'S'${\mathbf{howmny}}=\text{'S'}$
Selected right and/or left eigenvectors, defined by the array select, are computed.
Constraint: howmny = 'A'${\mathbf{howmny}}=\text{'A'}$, 'B'$\text{'B'}$ or 'S'$\text{'S'}$.
3:     select( : $:$) – logical array
Note: the dimension of the array select must be at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if howmny = 'S'${\mathbf{howmny}}=\text{'S'}$, and at least 1$1$ otherwise.
Specifies the eigenvectors to be computed if howmny = 'S'${\mathbf{howmny}}=\text{'S'}$. To select the generalized eigenvector corresponding to the j$j$th generalized eigenvalue, the j$j$th element of select should be set to true.
Constraint: select(j) = true${\mathbf{select}}\left(\mathit{j}\right)=\mathbf{true}$ or false$\mathbf{false}$, for j = 1,2,,n$\mathit{j}=1,2,\dots ,n$.
4:     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 matrix A$A$ must be in upper triangular form. Usually, this is the matrix A$A$ returned by nag_lapack_zhgeqz (f08xs).
5:     b(ldb, : $:$) – complex array
The first dimension of the array b 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 matrix B$B$ must be in upper triangular form with non-negative real diagonal elements. Usually, this is the matrix B$B$ returned by nag_lapack_zhgeqz (f08xs).
6:     vl(ldvl, : $:$) – complex array
The first dimension, ldvl, of the array vl must satisfy
• if side = 'L'${\mathbf{side}}=\text{'L'}$ or 'B'$\text{'B'}$, ldvl max (1,n) $\mathit{ldvl}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if side = 'R'${\mathbf{side}}=\text{'R'}$, ldvl1$\mathit{ldvl}\ge 1$.
The second dimension of the array must be at least max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if side = 'L'${\mathbf{side}}=\text{'L'}$ or 'B'$\text{'B'}$ and at least 1$1$ if side = 'R'${\mathbf{side}}=\text{'R'}$
If howmny = 'B'${\mathbf{howmny}}=\text{'B'}$ and side = 'L'${\mathbf{side}}=\text{'L'}$ or 'B'$\text{'B'}$, vl must be initialized to an n$n$ by n$n$ matrix Q$Q$. Usually, this is the unitary matrix Q$Q$ of left Schur vectors returned by nag_lapack_zhgeqz (f08xs).
7:     vr(ldvr, : $:$) – complex array
The first dimension, ldvr, of the array vr must satisfy
• if side = 'R'${\mathbf{side}}=\text{'R'}$ or 'B'$\text{'B'}$, ldvr max (1,n) $\mathit{ldvr}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if side = 'L'${\mathbf{side}}=\text{'L'}$, ldvr1$\mathit{ldvr}\ge 1$.
The second dimension of the array must be at least max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if side = 'R'${\mathbf{side}}=\text{'R'}$ or 'B'$\text{'B'}$ and at least 1$1$ if side = 'L'${\mathbf{side}}=\text{'L'}$
If howmny = 'B'${\mathbf{howmny}}=\text{'B'}$ and side = 'R'${\mathbf{side}}=\text{'R'}$ or 'B'$\text{'B'}$, vr must be initialized to an n$n$ by n$n$ matrix Z$Z$. Usually, this is the unitary matrix Z$Z$ of right Schur vectors returned by nag_lapack_dhgeqz (f08xe).
8:     mm – int64int32nag_int scalar
The number of columns in the arrays vl and/or vr.
Constraints:
• if howmny = 'A'${\mathbf{howmny}}=\text{'A'}$ or 'B'$\text{'B'}$, mmn${\mathbf{mm}}\ge {\mathbf{n}}$;
• if howmny = 'S'${\mathbf{howmny}}=\text{'S'}$, mm must not be less than the number of requested eigenvectors.

### Optional Input Parameters

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

### Input Parameters Omitted from the MATLAB Interface

lda ldb ldvl ldvr work rwork

### Output Parameters

1:     vl(ldvl, : $:$) – complex array
The first dimension, ldvl, of the array vl will be
• if side = 'L'${\mathbf{side}}=\text{'L'}$ or 'B'$\text{'B'}$, ldvl max (1,n) $\mathit{ldvl}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if side = 'R'${\mathbf{side}}=\text{'R'}$, ldvl1$\mathit{ldvl}\ge 1$.
The second dimension of the array will be max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if side = 'L'${\mathbf{side}}=\text{'L'}$ or 'B'$\text{'B'}$ and at least 1$1$ if side = 'R'${\mathbf{side}}=\text{'R'}$
If side = 'L'${\mathbf{side}}=\text{'L'}$ or 'B'$\text{'B'}$, vl contains:
• if howmny = 'A'${\mathbf{howmny}}=\text{'A'}$, the matrix Y$Y$ of left eigenvectors of (A,B)$\left(A,B\right)$;
• if howmny = 'B'${\mathbf{howmny}}=\text{'B'}$, the matrix QY$QY$;
• if howmny = 'S'${\mathbf{howmny}}=\text{'S'}$, the left eigenvectors of (A,B)$\left(A,B\right)$ specified by select, stored consecutively in the columns of the array vl, in the same order as their corresponding eigenvalues.
2:     vr(ldvr, : $:$) – complex array
The first dimension, ldvr, of the array vr will be
• if side = 'R'${\mathbf{side}}=\text{'R'}$ or 'B'$\text{'B'}$, ldvr max (1,n) $\mathit{ldvr}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if side = 'L'${\mathbf{side}}=\text{'L'}$, ldvr1$\mathit{ldvr}\ge 1$.
The second dimension of the array will be max (1,mm)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{mm}}\right)$ if side = 'R'${\mathbf{side}}=\text{'R'}$ or 'B'$\text{'B'}$ and at least 1$1$ if side = 'L'${\mathbf{side}}=\text{'L'}$
If side = 'R'${\mathbf{side}}=\text{'R'}$ or 'B'$\text{'B'}$, vr contains:
• if howmny = 'A'${\mathbf{howmny}}=\text{'A'}$, the matrix X$X$ of right eigenvectors of (A,B)$\left(A,B\right)$;
• if howmny = 'B'${\mathbf{howmny}}=\text{'B'}$, the matrix ZX$ZX$;
• if howmny = 'S'${\mathbf{howmny}}=\text{'S'}$, the right eigenvectors of (A,B)$\left(A,B\right)$ specified by select, stored consecutively in the columns of the array vr, in the same order as their corresponding eigenvalues.
3:     m – int64int32nag_int scalar
The number of columns in the arrays vl and/or vr actually used to store the eigenvectors. If howmny = 'A'${\mathbf{howmny}}=\text{'A'}$ or 'B'$\text{'B'}$, m is set to n. Each selected eigenvector occupies one column.
4:     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

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: side, 2: howmny, 3: select, 4: n, 5: a, 6: lda, 7: b, 8: ldb, 9: vl, 10: ldvl, 11: vr, 12: ldvr, 13: mm, 14: m, 15: work, 16: rwork, 17: 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.

## Accuracy

It is beyond the scope of this manual to summarise the accuracy of the solution of the generalized eigenvalue problem. Interested readers should consult Section 4.11 of the LAPACK Users' Guide (see Anderson et al. (1999)) and Chapter 6 of Stewart and Sun (1990).

nag_lapack_ztgevc (f08yx) is the sixth step in the solution of the complex generalized eigenvalue problem and is usually called after nag_lapack_zhgeqz (f08xs).
The real analogue of this function is nag_lapack_dtgevc (f08yk).

## Example

```function nag_lapack_ztgevc_example
side = 'B';
howmny = 'B';
select = [false];
a = [ -0.1438233530385224 + 0.3741062911974998i, ...
1.619781251864666 + 0.5366170936785172i,  -5.73564259051686 - 3.142957175229123i, ...
0.8798344594474423 + 2.121055303267389i;
0 + 0i,  0.2823856561928724 + 0.5208777880043725i, ...
0.8621110088889029 - 2.167166334598099i,  -3.106018675330553 + 1.841506903478952i;
0 + 0i,  0 + 0i,  1.855074244893335 - 0.137336971784532i, ...
-1.098834831815077 - 0.9880107323733596i;
0 + 0i,  0 + 0i,  0 + 0i,  0.07048820152838613 - 0.1296769105942374i];
b = [0.2263375141379972,  -0.002717330036079723 - 0.7423473646116365i, ...
-3.468409696159831 + 0.1539788635359557i,  0.7560522313684904 + 1.232848952545645i;
0 + 0i,  0.5722925376877426 + 0i, ...
0.5726907354403078 - 2.024908875044398i,  -3.138311880819062 + 1.830164861889475i;
0 + 0i,  0 + 0i,  2.750626071820657 + 0i,  -1.220622047233075 - 1.233359591775969i;
0 + 0i,  0 + 0i,  0 + 0i,  0.1539006001169547 + 0i];
vl = [ -0.7090128348336845 - 0.4614766052957729i, ...
-0.03302144109782951 + 0.09031754537464898i,  -0.1628796424652455 - 0.4924480172799654i, ...
0.07738808120167298 - 0.008290082415805335i;
-0.4837138711442771 + 0.01888381070268117i, ...
0.1585276550385831 + 0.2160986717612117i,  0.6753888500844341 + 0.4579080836762112i, ...
-0.1663170609273306 + 0.0185300441734911i;
0.01301179598327496 + 0.04484513137596133i, ...
0.07439715940099263 + 0.2069093549321275i,  0.1013875542126264 + 0.09091777594277473i, ...
0.9636186134385214 - 0.04865057630715362i;
0.1975761880057718 + 0.09374269385944185i, ...
-0.03434567875120977 + 0.9324144078370313i,  -0.0529966554546879 - 0.2092394246122108i, ...
-0.1815547581349474 - 0.04525252686036998i];
vr = [ 0.1125541434588206 - 0.2530015045809291i, ...
-0.8454652086827854 - 0.0439376337233772i,  0.3778872609370834 - 0.1354773959002216i, ...
-0.1007041124568257 + 0.1878447328930133i;
-0.1679732170998382 + 0.1870876653951373i, ...
0.3287962269251304 + 0.1147271208604701i,  0.8540175661380118 - 0.1668164345930881i, ...
-0.220993168644864 - 0.09747936182932303i;
0.6207048630041609 - 0.6731519289895047i, ...
0.2900654196264747 + 0.1373850965514047i,  0.08053884907529973 - 0.06748539251590967i, ...
-0.08875151592027926 - 0.1991525172615823i;
-0.08915551057292456 + 0.1172529562072554i, ...
-0.2275026764742463 + 0.08496301506044719i,  -0.2211484305422954 - 0.1473972671191666i, ...
-0.5421617631561396 - 0.744818700993698i];
mm = int64(4);
[vlOut, vrOut, m, info] = nag_lapack_ztgevc(side, howmny, select, a, b, vl, vr, mm)
```
```

vlOut =

-0.2725 - 0.1776i   0.0474 + 0.0490i  -0.1146 - 0.1935i   0.0765 - 0.0082i
0.2762 + 0.0441i  -0.1435 - 0.0529i   0.3578 + 0.2103i  -0.1643 + 0.0183i
-0.9540 - 0.0460i   0.8642 + 0.1358i  -0.6773 - 0.3227i   0.9519 - 0.0481i
0.1276 - 0.0192i  -0.1641 + 0.0312i   0.0941 + 0.0343i  -0.1794 - 0.0447i

vrOut =

0.0870 - 0.1955i   0.0550 + 0.0318i  -0.5392 - 0.2697i   0.0467 - 0.0597i
-0.1298 + 0.1446i  -0.1060 - 0.0705i   0.6027 + 0.1760i  -0.0801 + 0.0956i
0.4797 - 0.5203i   0.6392 + 0.3608i  -0.7265 - 0.2735i   0.5616 - 0.4384i
-0.0689 + 0.0906i  -0.1388 - 0.0303i  -0.0422 - 0.0065i  -0.1293 + 0.0420i

m =

4

info =

0

```
```function f08yx_example
side = 'B';
howmny = 'B';
select = [false];
a = [ -0.1438233530385224 + 0.3741062911974998i, ...
1.619781251864666 + 0.5366170936785172i,  -5.73564259051686 - 3.142957175229123i, ...
0.8798344594474423 + 2.121055303267389i;
0 + 0i,  0.2823856561928724 + 0.5208777880043725i, ...
0.8621110088889029 - 2.167166334598099i,  -3.106018675330553 + 1.841506903478952i;
0 + 0i,  0 + 0i,  1.855074244893335 - 0.137336971784532i, ...
-1.098834831815077 - 0.9880107323733596i;
0 + 0i,  0 + 0i,  0 + 0i,  0.07048820152838613 - 0.1296769105942374i];
b = [0.2263375141379972,  -0.002717330036079723 - 0.7423473646116365i, ...
-3.468409696159831 + 0.1539788635359557i,  0.7560522313684904 + 1.232848952545645i;
0 + 0i,  0.5722925376877426 + 0i, ...
0.5726907354403078 - 2.024908875044398i,  -3.138311880819062 + 1.830164861889475i;
0 + 0i,  0 + 0i,  2.750626071820657 + 0i,  -1.220622047233075 - 1.233359591775969i;
0 + 0i,  0 + 0i,  0 + 0i,  0.1539006001169547 + 0i];
vl = [ -0.7090128348336845 - 0.4614766052957729i, ...
-0.03302144109782951 + 0.09031754537464898i,  -0.1628796424652455 - 0.4924480172799654i, ...
0.07738808120167298 - 0.008290082415805335i;
-0.4837138711442771 + 0.01888381070268117i, ...
0.1585276550385831 + 0.2160986717612117i,  0.6753888500844341 + 0.4579080836762112i, ...
-0.1663170609273306 + 0.0185300441734911i;
0.01301179598327496 + 0.04484513137596133i, ...
0.07439715940099263 + 0.2069093549321275i,  0.1013875542126264 + 0.09091777594277473i, ...
0.9636186134385214 - 0.04865057630715362i;
0.1975761880057718 + 0.09374269385944185i, ...
-0.03434567875120977 + 0.9324144078370313i,  -0.0529966554546879 - 0.2092394246122108i, ...
-0.1815547581349474 - 0.04525252686036998i];
vr = [ 0.1125541434588206 - 0.2530015045809291i, ...
-0.8454652086827854 - 0.0439376337233772i,  0.3778872609370834 - 0.1354773959002216i, ...
-0.1007041124568257 + 0.1878447328930133i;
-0.1679732170998382 + 0.1870876653951373i, ...
0.3287962269251304 + 0.1147271208604701i,  0.8540175661380118 - 0.1668164345930881i, ...
-0.220993168644864 - 0.09747936182932303i;
0.6207048630041609 - 0.6731519289895047i, ...
0.2900654196264747 + 0.1373850965514047i,  0.08053884907529973 - 0.06748539251590967i, ...
-0.08875151592027926 - 0.1991525172615823i;
-0.08915551057292456 + 0.1172529562072554i, ...
-0.2275026764742463 + 0.08496301506044719i,  -0.2211484305422954 - 0.1473972671191666i, ...
-0.5421617631561396 - 0.744818700993698i];
mm = int64(4);
[vlOut, vrOut, m, info] = f08yx(side, howmny, select, a, b, vl, vr, mm)
```
```

vlOut =

-0.2725 - 0.1776i   0.0474 + 0.0490i  -0.1146 - 0.1935i   0.0765 - 0.0082i
0.2762 + 0.0441i  -0.1435 - 0.0529i   0.3578 + 0.2103i  -0.1643 + 0.0183i
-0.9540 - 0.0460i   0.8642 + 0.1358i  -0.6773 - 0.3227i   0.9519 - 0.0481i
0.1276 - 0.0192i  -0.1641 + 0.0312i   0.0941 + 0.0343i  -0.1794 - 0.0447i

vrOut =

0.0870 - 0.1955i   0.0550 + 0.0318i  -0.5392 - 0.2697i   0.0467 - 0.0597i
-0.1298 + 0.1446i  -0.1060 - 0.0705i   0.6027 + 0.1760i  -0.0801 + 0.0956i
0.4797 - 0.5203i   0.6392 + 0.3608i  -0.7265 - 0.2735i   0.5616 - 0.4384i
-0.0689 + 0.0906i  -0.1388 - 0.0303i  -0.0422 - 0.0065i  -0.1293 + 0.0420i

m =

4

info =

0

```