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_dorghr (f08nf)

## Purpose

nag_lapack_dorghr (f08nf) generates the real orthogonal matrix Q$Q$ which was determined by nag_lapack_dgehrd (f08ne) when reducing a real general matrix A$A$ to Hessenberg form.

## Syntax

[a, info] = f08nf(ilo, ihi, a, tau, 'n', n)
[a, info] = nag_lapack_dorghr(ilo, ihi, a, tau, 'n', n)

## Description

nag_lapack_dorghr (f08nf) 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 generate Q$Q$ explicitly as a square matrix. Q$Q$ has the structure:
Q =
 I 0 0 0 Q22 0 0 0 I
$Q = I 0 0 0 Q22 0 0 0 I$
where Q22${Q}_{22}$ occupies rows and columns ilo${i}_{\mathrm{lo}}$ to ihi${i}_{\mathrm{hi}}$.

## References

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

## Parameters

### Compulsory Input Parameters

1:     ilo – int64int32nag_int scalar
2:     ihi – int64int32nag_int scalar
These must be the same parameters ilo and ihi, respectively, as supplied to nag_lapack_dgehrd (f08ne).
Constraints:
• if n > 0${\mathbf{n}}>0$, 1 ilo ihi n $1\le {\mathbf{ilo}}\le {\mathbf{ihi}}\le {\mathbf{n}}$;
• if n = 0${\mathbf{n}}=0$, ilo = 1${\mathbf{ilo}}=1$ and ihi = 0${\mathbf{ihi}}=0$.
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)$
Details of the vectors which define the elementary reflectors, as returned by nag_lapack_dgehrd (f08ne).
4:     tau( : $:$) – double array
Note: the dimension of the array tau must be at least max (1,n1)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$.
Further details of the elementary reflectors, as returned by nag_lapack_dgehrd (f08ne).

### Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array a The second dimension of the array a.
n$n$, the order of the matrix Q$Q$.
Constraint: n0${\mathbf{n}}\ge 0$.

lda 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)$
ldamax (1,n)$\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The n$n$ by n$n$ orthogonal matrix Q$Q$.
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: n, 2: ilo, 3: ihi, 4: a, 5: lda, 6: tau, 7: work, 8: lwork, 9: 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 matrix Q$Q$ differs from an exactly orthogonal matrix by a matrix E$E$ such that
 ‖E‖2 = O(ε) , $‖E‖2 = O(ε) ,$
where ε$\epsilon$ is the machine precision.

The total number of floating point operations is approximately (4/3)q3$\frac{4}{3}{q}^{3}$, where q = ihiilo$q={i}_{\mathrm{hi}}-{i}_{\mathrm{lo}}$.
The complex analogue of this function is nag_lapack_zunghr (f08nt).

## Example

```function nag_lapack_dorghr_example
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];
[aOut, info] = nag_lapack_dorghr(ilo, ihi, a, tau)
```
```

aOut =

1.0000         0         0         0
0   -0.1751   -0.9675   -0.1827
0    0.8560   -0.2413    0.4572
0   -0.4864   -0.0763    0.8704

info =

0

```
```function f08nf_example
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];
[aOut, info] = f08nf(ilo, ihi, a, tau)
```
```

aOut =

1.0000         0         0         0
0   -0.1751   -0.9675   -0.1827
0    0.8560   -0.2413    0.4572
0   -0.4864   -0.0763    0.8704

info =

0

```