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_zgebak (f08nw)

## Purpose

nag_lapack_zgebak (f08nw) transforms eigenvectors of a balanced matrix to those of the original complex general matrix.

## Syntax

[v, info] = f08nw(job, side, ilo, ihi, scale, v, 'n', n, 'm', m)
[v, info] = nag_lapack_zgebak(job, side, ilo, ihi, scale, v, 'n', n, 'm', m)

## Description

nag_lapack_zgebak (f08nw) is intended to be used after a complex general matrix $A$ has been balanced by nag_lapack_zgebal (f08nv), and eigenvectors of the balanced matrix ${A}_{22}^{\prime \prime }$ have subsequently been computed.
For a description of balancing, see the document for nag_lapack_zgebal (f08nv). The balanced matrix ${A}^{\prime \prime }$ is obtained as ${A}^{\prime \prime }=DPA{P}^{\mathrm{T}}{D}^{-1}$, where $P$ is a permutation matrix and $D$ is a diagonal scaling matrix. This function transforms left or right eigenvectors as follows:
• if $x$ is a right eigenvector of ${A}^{\prime \prime }$, ${P}^{\mathrm{T}}{D}^{-1}x$ is a right eigenvector of $A$;
• if $y$ is a left eigenvector of ${A}^{\prime \prime }$, ${P}^{\mathrm{T}}Dy$ is a left eigenvector of $A$.

None.

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{job}$ – string (length ≥ 1)
This must be the same argument job as supplied to nag_lapack_zgebal (f08nv).
Constraint: ${\mathbf{job}}=\text{'N'}$, $\text{'P'}$, $\text{'S'}$ or $\text{'B'}$.
2:     $\mathrm{side}$ – string (length ≥ 1)
Indicates whether left or right eigenvectors are to be transformed.
${\mathbf{side}}=\text{'L'}$
The left eigenvectors are transformed.
${\mathbf{side}}=\text{'R'}$
The right eigenvectors are transformed.
Constraint: ${\mathbf{side}}=\text{'L'}$ or $\text{'R'}$.
3:     $\mathrm{ilo}$int64int32nag_int scalar
4:     $\mathrm{ihi}$int64int32nag_int scalar
The values ${i}_{\mathrm{lo}}$ and ${i}_{\mathrm{hi}}$, as returned by nag_lapack_zgebal (f08nv).
Constraints:
• if ${\mathbf{n}}>0$, $1\le {\mathbf{ilo}}\le {\mathbf{ihi}}\le {\mathbf{n}}$;
• if ${\mathbf{n}}=0$, ${\mathbf{ilo}}=1$ and ${\mathbf{ihi}}=0$.
5:     $\mathrm{scale}\left(:\right)$ – double array
The dimension of the array scale must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
Details of the permutations and/or the scaling factors used to balance the original complex general matrix, as returned by nag_lapack_zgebal (f08nv).
6:     $\mathrm{v}\left(\mathit{ldv},:\right)$ – complex array
The first dimension of the array v must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The second dimension of the array v must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
The matrix of left or right eigenvectors to be transformed.

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the first dimension of the array v.
$n$, the number of rows of the matrix of eigenvectors.
Constraint: ${\mathbf{n}}\ge 0$.
2:     $\mathrm{m}$int64int32nag_int scalar
Default: the second dimension of the array v.
$m$, the number of columns of the matrix of eigenvectors.
Constraint: ${\mathbf{m}}\ge 0$.

### Output Parameters

1:     $\mathrm{v}\left(\mathit{ldv},:\right)$ – complex array
The first dimension of the array v will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The second dimension of the array v will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
The transformed eigenvectors.
2:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

${\mathbf{info}}=-i$
If ${\mathbf{info}}=-i$, parameter $i$ had an illegal value on entry. The parameters are numbered as follows:
1: job, 2: side, 3: n, 4: ilo, 5: ihi, 6: scale, 7: m, 8: v, 9: ldv, 10: 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

The errors are negligible.

The total number of real floating-point operations is approximately proportional to $nm$.
The real analogue of this function is nag_lapack_dgebak (f08nj).

## Example

See Example in nag_lapack_zgebal (f08nv).
```function f08nw_example

fprintf('f08nw example results\n\n');

n = int64(4);
a = [  1.50 - 2.75i,  0.00 + 0.00i,  0.00 + 0.00i,  0.00 + 0.00i;
-8.06 - 1.24i, -2.50 - 0.50i,  0.00 + 0.00i, -0.75 + 0.50i;
-2.09 + 7.56i,  1.39 + 3.97i, -1.25 + 0.75i, -4.82 - 5.67i;
6.18 + 9.79i, -0.92 - 0.62i,  0.00 + 0.00i, -2.50 - 0.50i];

% Balance A
job = 'Both';
[a, ilo, ihi, scale, info] = f08nv(job, a);

% Reduce a to upper Hessenberg form
[H, tau, info] = f08ns(ilo, ihi, a);

% Form Q
[Q, info] = f08nt(ilo, ihi, H, tau);

% Calculate the eigenvalues and Schur factorisation of A
[H, w, Z, info] = f08ps( ...
'Schur Form', 'Vectors', ilo, ihi, H, Q);

disp('Eigenvalues:');
disp(w);

% Calculate the eigenvectors of A
[select, ~, VR, m, info] = ...
f08qx( ...
'Right', 'Backtransform', false, H, complex(zeros(1)), Z, n);
% Rescale
[VR, info] = f08nw( ...
'Both', 'Right', ilo, ihi, scale, VR);

% Normalize: largest elements are real
for i = 1:n
[~,k] = max(abs(real(VR(:,i)))+abs(imag(VR(:,i))));
VR(:,i) = VR(:,i)*conj(VR(k,i))/abs(VR(k,i))/norm(VR(:,i));
end

disp('Eigenvectors:');
disp(VR);

```
```f08nw example results

Eigenvalues:
-1.2500 + 0.7500i
-1.5000 - 0.4975i
-3.5000 - 0.5025i
1.5000 - 2.7500i

Eigenvectors:
0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.1418 - 0.0407i
0.0000 + 0.0000i  -0.1015 + 0.0009i   0.1756 - 0.4131i  -0.2711 - 0.1812i
1.0000 + 0.0000i   0.9884 + 0.0000i   0.7420 + 0.0000i   0.8213 + 0.0000i
0.0000 + 0.0000i   0.0941 + 0.0619i   0.4170 - 0.2722i   0.1110 + 0.4303i

```