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_zunmqr (f08au)

## Purpose

nag_lapack_zunmqr (f08au) multiplies an arbitrary complex matrix C$C$ by 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

[c, info] = f08au(side, trans, a, tau, c, 'm', m, 'n', n, 'k', k)
[c, info] = nag_lapack_zunmqr(side, trans, a, tau, c, 'm', m, 'n', n, 'k', k)

## Description

nag_lapack_zunmqr (f08au) 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 form one of the matrix products
 QC , QHC , CQ ​ or ​ CQH , $QC , QHC , CQ ​ or ​ CQH ,$
overwriting the result on c${\mathbf{c}}$ (which may be any complex rectangular matrix).
A common application of this function is in solving linear least squares problems, as described in the F08 Chapter Introduction and illustrated in Section [Example] in (f08as).

## 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 QH${Q}^{\mathrm{H}}$ is to be applied to C$C$.
side = 'L'${\mathbf{side}}=\text{'L'}$
Q$Q$ or QH${Q}^{\mathrm{H}}$ is applied to C$C$ from the left.
side = 'R'${\mathbf{side}}=\text{'R'}$
Q$Q$ or QH${Q}^{\mathrm{H}}$ 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 QH${Q}^{\mathrm{H}}$ is to be applied to C$C$.
trans = 'N'${\mathbf{trans}}=\text{'N'}$
Q$Q$ is applied to C$C$.
trans = 'C'${\mathbf{trans}}=\text{'C'}$
QH${Q}^{\mathrm{H}}$ is applied to C$C$.
Constraint: trans = 'N'${\mathbf{trans}}=\text{'N'}$ or 'C'$\text{'C'}$.
3:     a(lda, : $:$) – complex 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,k)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{k}}\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).
4:     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).
5:     c(ldc, : $:$) – complex 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$.
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$.
Constraint: n0${\mathbf{n}}\ge 0$.
3:     k – int64int32nag_int scalar
Default: The second dimension of the arrays a, tau.
k$k$, the number of elementary reflectors whose product defines the matrix Q$Q$.
Constraints:
• if side = 'L'${\mathbf{side}}=\text{'L'}$, m k 0 ${\mathbf{m}}\ge {\mathbf{k}}\ge 0$;
• if side = 'R'${\mathbf{side}}=\text{'R'}$, n k 0 ${\mathbf{n}}\ge {\mathbf{k}}\ge 0$.

### Input Parameters Omitted from the MATLAB Interface

lda ldc work lwork

### Output Parameters

1:     c(ldc, : $:$) – complex 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 QHC${Q}^{\mathrm{H}}C$ or CQ$CQ$ or CQH$C{Q}^{\mathrm{H}}$ 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: k, 6: a, 7: lda, 8: tau, 9: c, 10: ldc, 11: work, 12: lwork, 13: 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 real floating point operations is approximately 8nk (2mk) $8nk\left(2m-k\right)$ if side = 'L'${\mathbf{side}}=\text{'L'}$ and 8mk (2nk) $8mk\left(2n-k\right)$ if side = 'R'${\mathbf{side}}=\text{'R'}$.
The real analogue of this function is nag_lapack_dormqr (f08ag).

## Example

```function nag_lapack_zunmqr_example
side = 'Left';
trans = 'Conjugate transpose';
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];
c = [ -2.09 + 1.93i,  3.26 - 2.7i;
3.34 - 3.53i,  -6.22 + 1.16i;
-4.94 - 2.04i,  7.94 - 3.13i;
0.17 + 4.23i,  1.04 - 4.26i;
-5.19 + 3.63i,  -2.31 - 2.12i;
0.98 + 2.53i,  -1.39 - 4.05i];
[cOut, info] = nag_lapack_zunmqr(side, trans, a, tau, c)
```
```

cOut =

5.3510 - 0.1638i  -4.7626 - 2.8427i
-5.7559 - 0.2004i   6.3325 - 2.7406i
-2.5366 + 4.0215i   6.4835 - 3.8629i
-1.0677 - 6.3316i   6.4968 - 0.7809i
-0.0381 - 0.0273i  -0.1320 - 0.0612i
-0.0144 + 0.0483i   0.0906 - 0.0740i

info =

0

```
```function f08au_example
side = 'Left';
trans = 'Conjugate transpose';
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];
c = [ -2.09 + 1.93i,  3.26 - 2.7i;
3.34 - 3.53i,  -6.22 + 1.16i;
-4.94 - 2.04i,  7.94 - 3.13i;
0.17 + 4.23i,  1.04 - 4.26i;
-5.19 + 3.63i,  -2.31 - 2.12i;
0.98 + 2.53i,  -1.39 - 4.05i];
[cOut, info] = f08au(side, trans, a, tau, c)
```
```

cOut =

5.3510 - 0.1638i  -4.7626 - 2.8427i
-5.7559 - 0.2004i   6.3325 - 2.7406i
-2.5366 + 4.0215i   6.4835 - 3.8629i
-1.0677 - 6.3316i   6.4968 - 0.7809i
-0.0381 - 0.0273i  -0.1320 - 0.0612i
-0.0144 + 0.0483i   0.0906 - 0.0740i

info =

0

```