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_zungqr (f08at)

Purpose

nag_lapack_zungqr (f08at) generates all or part of the complex unitary matrix Q$Q$ from a QR$QR$ factorization computed by nag_lapack_zgeqrf (f08as), nag_lapack_zgeqpf (f08bs) or nag_lapack_zgeqp3 (f08bt).

Syntax

[a, info] = f08at(a, tau, 'm', m, 'n', n, 'k', k)
[a, info] = nag_lapack_zungqr(a, tau, 'm', m, 'n', n, 'k', k)

Description

nag_lapack_zungqr (f08at) is intended to be used after a call to nag_lapack_zgeqrf (f08as), nag_lapack_zgeqpf (f08bs) or nag_lapack_zgeqp3 (f08bt), which perform a QR$QR$ factorization of a complex matrix A$A$. The unitary matrix Q$Q$ is represented as a product of elementary reflectors.
This function may be used to generate Q$Q$ explicitly as a square matrix, or to form only its leading columns.
Usually Q$Q$ is determined from the QR$QR$ factorization of an m$m$ by p$p$ matrix A$A$ with mp$m\ge p$. The whole of Q$Q$ may be computed by:
```[a, info] = f08at(a, tau);
```
(note that the array a must have m$m$ columns) or its leading p$p$ columns by:
```[a, info] = f08at(a(1:p,:), tau);
```
The columns of Q$Q$ returned by the last call form an orthonormal basis for the space spanned by the columns of A$A$; thus nag_lapack_zgeqrf (f08as) followed by nag_lapack_zungqr (f08at) can be used to orthogonalize the columns of A$A$.
The information returned by the QR$QR$ factorization functions also yields the QR$QR$ factorization of the leading k$k$ columns of A$A$, where k < p$k. The unitary matrix arising from this factorization can be computed by:
```[a, info] = f08at(a, tau);
```
or its leading k$k$ columns by:
```[a, info] = f08at(a(:,1:k), tau);
```

References

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

Parameters

Compulsory Input Parameters

1:     a(lda, : $:$) – complex array
The first dimension of the array a 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)$
Details of the vectors which define the elementary reflectors, as returned by nag_lapack_zgeqrf (f08as), nag_lapack_zgeqpf (f08bs) or nag_lapack_zgeqp3 (f08bt).
2:     tau( : $:$) – complex array
Note: the dimension of the array tau must be at least max (1,k)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\right)$.
Further details of the elementary reflectors, as returned by nag_lapack_zgeqrf (f08as), nag_lapack_zgeqpf (f08bs) or nag_lapack_zgeqp3 (f08bt).

Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array a.
m$m$, the order of the unitary matrix Q$Q$.
Constraint: m0${\mathbf{m}}\ge 0$.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array a.
n$n$, the number of columns of the matrix Q$Q$.
Constraint: mn0${\mathbf{m}}\ge {\mathbf{n}}\ge 0$.
3:     k – int64int32nag_int scalar
Default: The dimension of the array tau.
k$k$, the number of elementary reflectors whose product defines the matrix Q$Q$.
Constraint: nk0${\mathbf{n}}\ge {\mathbf{k}}\ge 0$.

lda work lwork

Output Parameters

1:     a(lda, : $:$) – complex array
The first dimension of the array a 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)$
ldamax (1,m)$\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
The m$m$ by n$n$ 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: m, 2: n, 3: k, 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 16mnk8 (m + n) k2 + (16/3) k3 $16mnk-8\left(m+n\right){k}^{2}+\frac{16}{3}{k}^{3}$; when n = k$n=k$, the number is approximately (8/3) n2 (3mn) $\frac{8}{3}{n}^{2}\left(3m-n\right)$.
The real analogue of this function is nag_lapack_dorgqr (f08af).

Example

```function nag_lapack_zungqr_example
a = [-3.087005021051958,  -0.4884993674179767 - 1.141689105124614i, ...
0.3773560431732106 - 1.243729755480491i,  -0.8551654376967619 - 0.7073198731811355i;
-0.326978431123342 + 0.4238066080640211i, ...
1.516316047290931 + 0i,  1.373055096626977 - 0.8176293354211591i,  -0.2508627202628476 + 0.8203486040451443i;
0.1691724764304651 - 0.07980476733072399i, ...
-0.4537104861498296 - 0.006491499591352979i,  -2.17134536255717 + 0i,  -0.2272676203283603 - 0.2957314059070643i;
-0.1059736295130279 + 0.0726861860966964i, ...
-0.2734071741396468 + 0.0978078838704349i,  -0.291822737804996 + 0.4888081441553061i,  -2.353376106555421 + 0i;
0.1729396325459321 + 0.1606326404292985i, ...
-0.3236304714632618 + 0.1230007002199739i,  0.2727685061644792 + 0.04697693306903757i, ...
0.7054226886031557 + 0.2515080566109891i;
0.2698996744687472 - 0.01516708364852971i, ...
-0.1645935439354584 + 0.3389007203482612i,  0.5348395253617789 + 0.3988290677840221i, ...
0.2703069905230761 - 0.07268783264065712i];
tau = [ 1.310981029656006 - 0.2623902437722555i;
1.105103989110574 - 0.450362538745018i;
1.040251871615519 + 0.2121758107261096i;
1.18595901116611 + 0.2011836003307436i];
[aOut, info] = nag_lapack_zungqr(a, tau)
```
```

aOut =

-0.3110 + 0.2624i  -0.3175 + 0.4835i   0.4966 - 0.2997i  -0.0072 - 0.3718i
0.3175 - 0.6414i  -0.2062 + 0.1577i  -0.0793 - 0.3094i  -0.0282 - 0.1491i
-0.2008 + 0.1490i   0.4892 - 0.0900i   0.0357 - 0.0219i   0.5625 - 0.0710i
0.1199 - 0.1231i   0.2566 - 0.3055i   0.4489 - 0.2141i  -0.1651 + 0.1800i
-0.2689 - 0.1652i   0.1697 - 0.2491i  -0.0496 + 0.1158i  -0.4885 - 0.4540i
-0.3499 + 0.0907i  -0.0491 - 0.3133i  -0.1256 - 0.5300i   0.1039 + 0.0450i

info =

0

```
```function f08at_example
a = [-3.087005021051958,  -0.4884993674179767 - 1.141689105124614i, ...
0.3773560431732106 - 1.243729755480491i, ...
-0.8551654376967619 - 0.7073198731811355i;
-0.326978431123342 + 0.4238066080640211i, ...
1.516316047290931 + 0i,  1.373055096626977 - 0.8176293354211591i, ...
-0.2508627202628476 + 0.8203486040451443i;
0.1691724764304651 - 0.07980476733072399i, ...
-0.4537104861498296 - 0.006491499591352979i,  -2.17134536255717 + 0i, ...
-0.2272676203283603 - 0.2957314059070643i;
-0.1059736295130279 + 0.0726861860966964i, ...
-0.2734071741396468 + 0.0978078838704349i, ...
-0.291822737804996 + 0.4888081441553061i,  -2.353376106555421 + 0i;
0.1729396325459321 + 0.1606326404292985i, ...
-0.3236304714632618 + 0.1230007002199739i,  ...
0.2727685061644792 + 0.04697693306903757i, ...
0.7054226886031557 + 0.2515080566109891i;
0.2698996744687472 - 0.01516708364852971i, ...
-0.1645935439354584 + 0.3389007203482612i,  ...
0.5348395253617789 + 0.3988290677840221i, ...
0.2703069905230761 - 0.07268783264065712i];
tau = [ 1.310981029656006 - 0.2623902437722555i;
1.105103989110574 - 0.450362538745018i;
1.040251871615519 + 0.2121758107261096i;
1.18595901116611 + 0.2011836003307436i];
[aOut, info] = f08at(a, tau)
```
```

aOut =

-0.3110 + 0.2624i  -0.3175 + 0.4835i   0.4966 - 0.2997i  -0.0072 - 0.3718i
0.3175 - 0.6414i  -0.2062 + 0.1577i  -0.0793 - 0.3094i  -0.0282 - 0.1491i
-0.2008 + 0.1490i   0.4892 - 0.0900i   0.0357 - 0.0219i   0.5625 - 0.0710i
0.1199 - 0.1231i   0.2566 - 0.3055i   0.4489 - 0.2141i  -0.1651 + 0.1800i
-0.2689 - 0.1652i   0.1697 - 0.2491i  -0.0496 + 0.1158i  -0.4885 - 0.4540i
-0.3499 + 0.0907i  -0.0491 - 0.3133i  -0.1256 - 0.5300i   0.1039 + 0.0450i

info =

0

```