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_dormhr (f08ng)

## Purpose

nag_lapack_dormhr (f08ng) multiplies an arbitrary real matrix C$C$ by the real orthogonal matrix Q$Q$ which was determined by nag_lapack_dgehrd (f08ne) when reducing a real general matrix to Hessenberg form.

## Syntax

[c, info] = f08ng(side, trans, ilo, ihi, a, tau, c, 'm', m, 'n', n)
[c, info] = nag_lapack_dormhr(side, trans, ilo, ihi, a, tau, c, 'm', m, 'n', n)

## Description

nag_lapack_dormhr (f08ng) is intended to be used following a call to nag_lapack_dgehrd (f08ne), which reduces a real general matrix A$A$ to upper Hessenberg form H$H$ by an orthogonal similarity transformation: A = QHQT$A=QH{Q}^{\mathrm{T}}$. nag_lapack_dgehrd (f08ne) represents the matrix Q$Q$ as a product of ihiilo${i}_{\mathrm{hi}}-{i}_{\mathrm{lo}}$ elementary reflectors. Here ilo${i}_{\mathrm{lo}}$ and ihi${i}_{\mathrm{hi}}$ are values determined by nag_lapack_dgebal (f08nh) when balancing the matrix; if the matrix has not been balanced, ilo = 1${i}_{\mathrm{lo}}=1$ and ihi = n${i}_{\mathrm{hi}}=n$.
This function may be used to form one of the matrix products
 QC , QTC , CQ ​ or ​ CQT , $QC , QTC , CQ ​ or ​ CQT ,$
overwriting the result on C$C$ (which may be any real rectangular matrix).
A common application of this function is to transform a matrix V$V$ of eigenvectors of H$H$ to the matrix QV$\mathit{QV}$ of eigenvectors of A$A$.

## References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## Parameters

### Compulsory Input Parameters

1:     side – string (length ≥ 1)
Indicates how Q$Q$ or QT${Q}^{\mathrm{T}}$ is to be applied to C$C$.
side = 'L'${\mathbf{side}}=\text{'L'}$
Q$Q$ or QT${Q}^{\mathrm{T}}$ is applied to C$C$ from the left.
side = 'R'${\mathbf{side}}=\text{'R'}$
Q$Q$ or QT${Q}^{\mathrm{T}}$ is applied to C$C$ from the right.
Constraint: side = 'L'${\mathbf{side}}=\text{'L'}$ or 'R'$\text{'R'}$.
2:     trans – string (length ≥ 1)
Indicates whether Q$Q$ or QT${Q}^{\mathrm{T}}$ is to be applied to C$C$.
trans = 'N'${\mathbf{trans}}=\text{'N'}$
Q$Q$ is applied to C$C$.
trans = 'T'${\mathbf{trans}}=\text{'T'}$
QT${Q}^{\mathrm{T}}$ is applied to C$C$.
Constraint: trans = 'N'${\mathbf{trans}}=\text{'N'}$ or 'T'$\text{'T'}$.
3:     ilo – int64int32nag_int scalar
4:     ihi – int64int32nag_int scalar
These must be the same parameters ilo and ihi, respectively, as supplied to nag_lapack_dgehrd (f08ne).
Constraints:
• if side = 'L'${\mathbf{side}}=\text{'L'}$ and m > 0${\mathbf{m}}>0$, 1 ilo ihi m $1\le {\mathbf{ilo}}\le {\mathbf{ihi}}\le {\mathbf{m}}$;
• if side = 'L'${\mathbf{side}}=\text{'L'}$ and m = 0${\mathbf{m}}=0$, ilo = 1${\mathbf{ilo}}=1$ and ihi = 0${\mathbf{ihi}}=0$;
• if side = 'R'${\mathbf{side}}=\text{'R'}$ and n > 0${\mathbf{n}}>0$, 1 ilo ihi n $1\le {\mathbf{ilo}}\le {\mathbf{ihi}}\le {\mathbf{n}}$;
• if side = 'R'${\mathbf{side}}=\text{'R'}$ and n = 0${\mathbf{n}}=0$, ilo = 1${\mathbf{ilo}}=1$ and ihi = 0${\mathbf{ihi}}=0$.
5:     a(lda, : $:$) – double array
The first dimension, lda, of the array a must satisfy
• if side = 'L'${\mathbf{side}}=\text{'L'}$, lda max (1,m) $\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if side = 'R'${\mathbf{side}}=\text{'R'}$, lda max (1,n) $\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The second dimension of the array must be at least max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if side = 'L'${\mathbf{side}}=\text{'L'}$ and at least max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if side = 'R'${\mathbf{side}}=\text{'R'}$
Details of the vectors which define the elementary reflectors, as returned by nag_lapack_dgehrd (f08ne).
6:     tau( : $:$) – double array
Note: the dimension of the array tau must be at least max (1,m1)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}-1\right)$ if side = 'L'${\mathbf{side}}=\text{'L'}$ and at least max (1,n1)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$ if side = 'R'${\mathbf{side}}=\text{'R'}$.
Further details of the elementary reflectors, as returned by nag_lapack_dgehrd (f08ne).
7:     c(ldc, : $:$) – double array
The first dimension of the array c must be at least max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\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 m$m$ by n$n$ matrix C$C$.

### Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array c.
m$m$, the number of rows of the matrix C$C$; m$m$ is also the order of Q$Q$ if side = 'L'${\mathbf{side}}=\text{'L'}$.
Constraint: m0${\mathbf{m}}\ge 0$.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array c.
n$n$, the number of columns of the matrix C$C$; n$n$ is also the order of Q$Q$ if side = 'R'${\mathbf{side}}=\text{'R'}$.
Constraint: n0${\mathbf{n}}\ge 0$.

### Input Parameters Omitted from the MATLAB Interface

lda ldc work lwork

### Output Parameters

1:     c(ldc, : $:$) – double array
The first dimension of the array c will be max (1,m)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$
The second dimension of the array will be max (1,n)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
ldcmax (1,m)$\mathit{ldc}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
c stores QC$QC$ or QTC${Q}^{\mathrm{T}}C$ or CQ$CQ$ or CQT$C{Q}^{\mathrm{T}}$ as specified by side and trans.
2:     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: trans, 3: m, 4: n, 5: ilo, 6: ihi, 7: a, 8: lda, 9: tau, 10: c, 11: ldc, 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.

## Accuracy

The computed result differs from the exact result by a matrix E$E$ such that
 ‖E‖2 = O(ε) ‖C‖2 , $‖E‖2 = O(ε) ‖C‖2 ,$
where ε$\epsilon$ is the machine precision.

The total number of floating point operations is approximately 2nq2$2n{q}^{2}$ if side = 'L'${\mathbf{side}}=\text{'L'}$ and 2mq2$2m{q}^{2}$ if side = 'R'${\mathbf{side}}=\text{'R'}$, where q = ihiilo$q={i}_{\mathrm{hi}}-{i}_{\mathrm{lo}}$.
The complex analogue of this function is nag_lapack_zunmhr (f08nu).

## Example

```function nag_lapack_dormhr_example
side = 'Left';
trans = 'No transpose';
ilo = int64(1);
ihi = int64(4);
a = [0.35, -0.1159524296205035, -0.3886010343233214, -0.2941840753473021;
-0.5140038910358558, 0.1224867524602574, 0.1003597896821503, 0.1125618799705319;
-0.7284721282927631, 0.6442636185270625, -0.1357001717571131, -0.09768162270493326;
0.4139046183481608, -0.1665445794905699, 0.4262443722078449, 0.1632134192968561];
tau = [1.175095950769217;
1.946022972139863;
0];
c = [0.388121783771964, 0.05736203016960297, 0.1493218416107921;
-0.01428690112019408, 0.4135233160565419, 0.1179454267523731;
0.8119679816025415, -1.642115525248917e-17, -0.6190595172579693;
-0.3958676674181024, -0.6041323325818976, 1];
[cOut, info] = nag_lapack_dormhr(side, trans, ilo, ihi, a, tau, c)
```
```

cOut =

0.3881    0.0574    0.1493
-0.7107    0.0380    0.3956
-0.3891    0.0778    0.7075
-0.3996   -0.7270    0.8603

info =

0

```
```function f08ng_example
side = 'Left';
trans = 'No transpose';
ilo = int64(1);
ihi = int64(4);
a = [0.35, -0.1159524296205035, -0.3886010343233214, -0.2941840753473021;
-0.5140038910358558, 0.1224867524602574, 0.1003597896821503, 0.1125618799705319;
-0.7284721282927631, 0.6442636185270625, -0.1357001717571131, -0.09768162270493326;
0.4139046183481608, -0.1665445794905699, 0.4262443722078449, 0.1632134192968561];
tau = [1.175095950769217;
1.946022972139863;
0];
c = [0.388121783771964, 0.05736203016960297, 0.1493218416107921;
-0.01428690112019408, 0.4135233160565419, 0.1179454267523731;
0.8119679816025415, -1.642115525248917e-17, -0.6190595172579693;
-0.3958676674181024, -0.6041323325818976, 1];
[cOut, info] = f08ng(side, trans, ilo, ihi, a, tau, c)
```
```

cOut =

0.3881    0.0574    0.1493
-0.7107    0.0380    0.3956
-0.3891    0.0778    0.7075
-0.3996   -0.7270    0.8603

info =

0

```