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_zunghr (f08nt)

## Purpose

nag_lapack_zunghr (f08nt) generates the complex unitary matrix Q$Q$ which was determined by nag_lapack_zgehrd (f08ns) when reducing a complex general matrix A$A$ to Hessenberg form.

## Syntax

[a, info] = f08nt(ilo, ihi, a, tau, 'n', n)
[a, info] = nag_lapack_zunghr(ilo, ihi, a, tau, 'n', n)

## Description

nag_lapack_zunghr (f08nt) is intended to be used following a call to nag_lapack_zgehrd (f08ns), which reduces a complex general matrix A$A$ to upper Hessenberg form H$H$ by a unitary similarity transformation: A = QHQH$A=QH{Q}^{\mathrm{H}}$. nag_lapack_zgehrd (f08ns) 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_zgebal (f08nv) 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_zgehrd (f08ns).
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, : $:$) – 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)$
Details of the vectors which define the elementary reflectors, as returned by nag_lapack_zgehrd (f08ns).
4:     tau( : $:$) – complex 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_zgehrd (f08ns).

### 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, : $:$) – complex 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$ unitary 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 unitary matrix by a matrix E$E$ such that
 ‖E‖2 = O(ε) , $‖E‖2 = O(ε) ,$
where ε$\epsilon$ is the machine precision.

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

## Example

```function nag_lapack_zunghr_example
ilo = int64(1);
ihi = int64(4);
a = [ -3.97 - 5.04i, -1.131805187339771 - 2.56930489882744i, ...
-4.602742437533554 - 0.142631904083292i, -1.424912289366528 + 1.732983703342187i;
-5.479653273702635 + 0i, 1.858472820765587 - 1.55018070644029i, ...
4.414465526917012 - 0.7638237115550983i, -0.4805261336990153 - 1.197599997332747i;
0.6932222118146283 - 0.4828752762602551i, ...
6.267276818064224 + 0i, -0.4503809403345012 - 0.02898183259817966i, ...
-1.346684450078734 + 1.65792489538873i;
-0.2112946907920694 + 0.0864412259893682i, ...
0.1242146188766495 - 0.2289276049796828i, -3.499985837393258 + 0i, ...
2.561908119568915 - 3.370837460961531i];
tau = [ 1.062047721455606 - 0.2737399475982613i;
1.805921371640585 + 0.3479067029848286i;
1.181823471041003 + 0.9833311880432766i];
[aOut, info] = nag_lapack_zunghr(ilo, ihi, a, tau)
```
```

aOut =

1.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i
0.0000 + 0.0000i  -0.0620 + 0.2737i   0.4995 + 0.6440i   0.4237 - 0.2783i
0.0000 + 0.0000i  -0.6041 + 0.7026i  -0.1487 - 0.1427i  -0.2634 - 0.1722i
0.0000 + 0.0000i   0.2007 - 0.1496i  -0.4652 + 0.2773i  -0.2482 - 0.7632i

info =

0

```
```function f08nt_example
ilo = int64(1);
ihi = int64(4);
a = [ -3.97 - 5.04i, -1.131805187339771 - 2.56930489882744i, ...
-4.602742437533554 - 0.142631904083292i, -1.424912289366528 + 1.732983703342187i;
-5.479653273702635 + 0i, 1.858472820765587 - 1.55018070644029i, ...
4.414465526917012 - 0.7638237115550983i, -0.4805261336990153 - 1.197599997332747i;
0.6932222118146283 - 0.4828752762602551i, ...
6.267276818064224 + 0i, -0.4503809403345012 - 0.02898183259817966i, ...
-1.346684450078734 + 1.65792489538873i;
-0.2112946907920694 + 0.0864412259893682i, ...
0.1242146188766495 - 0.2289276049796828i, -3.499985837393258 + 0i, ...
2.561908119568915 - 3.370837460961531i];
tau = [ 1.062047721455606 - 0.2737399475982613i;
1.805921371640585 + 0.3479067029848286i;
1.181823471041003 + 0.9833311880432766i];
[aOut, info] = f08nt(ilo, ihi, a, tau)
```
```

aOut =

1.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i
0.0000 + 0.0000i  -0.0620 + 0.2737i   0.4995 + 0.6440i   0.4237 - 0.2783i
0.0000 + 0.0000i  -0.6041 + 0.7026i  -0.1487 - 0.1427i  -0.2634 - 0.1722i
0.0000 + 0.0000i   0.2007 - 0.1496i  -0.4652 + 0.2773i  -0.2482 - 0.7632i

info =

0

```

Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013