# NAG Library Function Document

## 1Purpose

nag_dgebak (f08njc) transforms eigenvectors of a balanced matrix to those of the original real nonsymmetric matrix.

## 2Specification

 #include #include
 void nag_dgebak (Nag_OrderType order, Nag_JobType job, Nag_SideType side, Integer n, Integer ilo, Integer ihi, const double scale[], Integer m, double v[], Integer pdv, NagError *fail)

## 3Description

nag_dgebak (f08njc) is intended to be used after a real nonsymmetric matrix $A$ has been balanced by nag_dgebal (f08nhc), and eigenvectors of the balanced matrix ${A}_{22}^{\prime \prime }$ have subsequently been computed.
For a description of balancing, see the document for nag_dgebal (f08nhc). 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.

## 5Arguments

1:    $\mathbf{order}$Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:    $\mathbf{job}$Nag_JobTypeInput
On entry: this must be the same argument job as supplied to nag_dgebal (f08nhc).
Constraint: ${\mathbf{job}}=\mathrm{Nag_DoNothing}$, $\mathrm{Nag_Permute}$, $\mathrm{Nag_Scale}$ or $\mathrm{Nag_DoBoth}$.
3:    $\mathbf{side}$Nag_SideTypeInput
On entry: indicates whether left or right eigenvectors are to be transformed.
${\mathbf{side}}=\mathrm{Nag_LeftSide}$
The left eigenvectors are transformed.
${\mathbf{side}}=\mathrm{Nag_RightSide}$
The right eigenvectors are transformed.
Constraint: ${\mathbf{side}}=\mathrm{Nag_LeftSide}$ or $\mathrm{Nag_RightSide}$.
4:    $\mathbf{n}$IntegerInput
On entry: $n$, the number of rows of the matrix of eigenvectors.
Constraint: ${\mathbf{n}}\ge 0$.
5:    $\mathbf{ilo}$IntegerInput
6:    $\mathbf{ihi}$IntegerInput
On entry: the values ${i}_{\mathrm{lo}}$ and ${i}_{\mathrm{hi}}$, as returned by nag_dgebal (f08nhc).
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$.
7:    $\mathbf{scale}\left[\mathit{dim}\right]$const doubleInput
Note: the dimension, dim, of the array scale must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: details of the permutations and/or the scaling factors used to balance the original real nonsymmetric matrix, as returned by nag_dgebal (f08nhc).
8:    $\mathbf{m}$IntegerInput
On entry: $m$, the number of columns of the matrix of eigenvectors.
Constraint: ${\mathbf{m}}\ge 0$.
9:    $\mathbf{v}\left[\mathit{dim}\right]$doubleInput/Output
Note: the dimension, dim, of the array v must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdv}}×{\mathbf{m}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}×{\mathbf{pdv}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $V$ is stored in
• ${\mathbf{v}}\left[\left(j-1\right)×{\mathbf{pdv}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{v}}\left[\left(i-1\right)×{\mathbf{pdv}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the matrix of left or right eigenvectors to be transformed.
On exit: the transformed eigenvectors.
10:  $\mathbf{pdv}$IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array v.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
11:  $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pdv}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdv}}>0$.
NE_INT_2
On entry, ${\mathbf{pdv}}=〈\mathit{\text{value}}〉$ and ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
On entry, ${\mathbf{pdv}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdv}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
NE_INT_3
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$, ${\mathbf{ilo}}=〈\mathit{\text{value}}〉$ and ${\mathbf{ihi}}=〈\mathit{\text{value}}〉$.
Constraint: 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$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

The errors are negligible.

## 8Parallelism and Performance

nag_dgebak (f08njc) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
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.

The total number of floating-point operations is approximately proportional to $nm$.