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_zunmbr (f08ku)

## Purpose

nag_lapack_zunmbr (f08ku) multiplies an arbitrary complex $m$ by $n$ matrix $C$ by one of the complex unitary matrices $Q$ or $P$ which were determined by nag_lapack_zgebrd (f08ks) when reducing a complex matrix to bidiagonal form.

## Syntax

[c, info] = f08ku(vect, side, trans, k, a, tau, c, 'm', m, 'n', n)
[c, info] = nag_lapack_zunmbr(vect, side, trans, k, a, tau, c, 'm', m, 'n', n)

## Description

nag_lapack_zunmbr (f08ku) is intended to be used after a call to nag_lapack_zgebrd (f08ks), which reduces a complex rectangular matrix $A$ to real bidiagonal form $B$ by a unitary transformation: $A=QB{P}^{\mathrm{H}}$. nag_lapack_zgebrd (f08ks) represents the matrices $Q$ and ${P}^{\mathrm{H}}$ as products of elementary reflectors.
This function may be used to form one of the matrix products
 $QC , QHC , CQ , CQH , PC , PHC , CP ​ or ​ CPH ,$
overwriting the result on $C$ (which may be any complex rectangular matrix).

## References

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

## Parameters

Note: in the descriptions below, $\mathit{r}$ denotes the order of $Q$ or ${P}^{\mathrm{H}}$: if ${\mathbf{side}}=\text{'L'}$, $\mathit{r}={\mathbf{m}}$ and if ${\mathbf{side}}=\text{'R'}$, $\mathit{r}={\mathbf{n}}$.

### Compulsory Input Parameters

1:     $\mathrm{vect}$ – string (length ≥ 1)
Indicates whether $Q$ or ${Q}^{\mathrm{H}}$ or $P$ or ${P}^{\mathrm{H}}$ is to be applied to $C$.
${\mathbf{vect}}=\text{'Q'}$
$Q$ or ${Q}^{\mathrm{H}}$ is applied to $C$.
${\mathbf{vect}}=\text{'P'}$
$P$ or ${P}^{\mathrm{H}}$ is applied to $C$.
Constraint: ${\mathbf{vect}}=\text{'Q'}$ or $\text{'P'}$.
2:     $\mathrm{side}$ – string (length ≥ 1)
Indicates how $Q$ or ${Q}^{\mathrm{H}}$ or $P$ or ${P}^{\mathrm{H}}$ is to be applied to $C$.
${\mathbf{side}}=\text{'L'}$
$Q$ or ${Q}^{\mathrm{H}}$ or $P$ or ${P}^{\mathrm{H}}$ is applied to $C$ from the left.
${\mathbf{side}}=\text{'R'}$
$Q$ or ${Q}^{\mathrm{H}}$ or $P$ or ${P}^{\mathrm{H}}$ is applied to $C$ from the right.
Constraint: ${\mathbf{side}}=\text{'L'}$ or $\text{'R'}$.
3:     $\mathrm{trans}$ – string (length ≥ 1)
Indicates whether $Q$ or $P$ or ${Q}^{\mathrm{H}}$ or ${P}^{\mathrm{H}}$ is to be applied to $C$.
${\mathbf{trans}}=\text{'N'}$
$Q$ or $P$ is applied to $C$.
${\mathbf{trans}}=\text{'C'}$
${Q}^{\mathrm{H}}$ or ${P}^{\mathrm{H}}$ is applied to $C$.
Constraint: ${\mathbf{trans}}=\text{'N'}$ or $\text{'C'}$.
4:     $\mathrm{k}$int64int32nag_int scalar
If ${\mathbf{vect}}=\text{'Q'}$, the number of columns in the original matrix $A$.
If ${\mathbf{vect}}=\text{'P'}$, the number of rows in the original matrix $A$.
Constraint: ${\mathbf{k}}\ge 0$.
5:     $\mathrm{a}\left(\mathit{lda},:\right)$ – complex array
The first dimension, $\mathit{lda}$, of the array a must satisfy
• if ${\mathbf{vect}}=\text{'Q'}$, $\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathit{r}\right)$;
• if ${\mathbf{vect}}=\text{'P'}$, $\mathit{lda}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(\mathit{r},{\mathbf{k}}\right)\right)$.
The second dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(\mathit{r},{\mathbf{k}}\right)\right)$ if ${\mathbf{vect}}=\text{'Q'}$ and at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathit{r}\right)$ if ${\mathbf{vect}}=\text{'P'}$.
Details of the vectors which define the elementary reflectors, as returned by nag_lapack_zgebrd (f08ks).
6:     $\mathrm{tau}\left(:\right)$ – complex array
The dimension of the array tau must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(\mathit{r},{\mathbf{k}}\right)\right)$
Further details of the elementary reflectors, as returned by nag_lapack_zgebrd (f08ks) in its argument tauq if ${\mathbf{vect}}=\text{'Q'}$, or in its argument taup if ${\mathbf{vect}}=\text{'P'}$.
7:     $\mathrm{c}\left(\mathit{ldc},:\right)$ – complex array
The first dimension of the array c must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
The second dimension of the array c must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The matrix $C$.

### Optional Input Parameters

1:     $\mathrm{m}$int64int32nag_int scalar
Default: the first dimension of the array c.
$m$, the number of rows of the matrix $C$.
Constraint: ${\mathbf{m}}\ge 0$.
2:     $\mathrm{n}$int64int32nag_int scalar
Default: the second dimension of the array c.
$n$, the number of columns of the matrix $C$.
Constraint: ${\mathbf{n}}\ge 0$.

### Output Parameters

1:     $\mathrm{c}\left(\mathit{ldc},:\right)$ – complex array
The first dimension of the array c will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
The second dimension of the array c will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
c stores $QC$ or ${Q}^{\mathrm{H}}C$ or $CQ$ or ${C}^{\mathrm{H}}Q$ or $PC$ or ${P}^{\mathrm{H}}C$ or $CP$ or ${C}^{\mathrm{H}}P$ as specified by vect, side and trans.
2:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

${\mathbf{info}}=-i$
If ${\mathbf{info}}=-i$, parameter $i$ had an illegal value on entry. The parameters are numbered as follows:
1: vect, 2: side, 3: trans, 4: m, 5: n, 6: k, 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$ such that
 $E2 = Oε C2 ,$
where $\epsilon$ is the machine precision.

The total number of real floating-point operations is approximately
• if ${\mathbf{side}}=\text{'L'}$ and $m\ge k$, $8nk\left(2m-k\right)$;
• if ${\mathbf{side}}=\text{'R'}$ and $n\ge k$, $8mk\left(2n-k\right)$;
• if ${\mathbf{side}}=\text{'L'}$ and $m, $8{m}^{2}n$;
• if ${\mathbf{side}}=\text{'R'}$ and $n, $8m{n}^{2}$,
where $k$ is the value of the argument k
The real analogue of this function is nag_lapack_dormbr (f08kg).

## Example

For this function two examples are presented. Both illustrate how the reduction to bidiagonal form of a matrix $A$ may be preceded by a $QR$ or $LQ$ factorization of $A$.
In the first example, $m>n$, and
 $A = 0.96-0.81i -0.03+0.96i -0.91+2.06i -0.05+0.41i -0.98+1.98i -1.20+0.19i -0.66+0.42i -0.81+0.56i 0.62-0.46i 1.01+0.02i 0.63-0.17i -1.11+0.60i -0.37+0.38i 0.19-0.54i -0.98-0.36i 0.22-0.20i 0.83+0.51i 0.20+0.01i -0.17-0.46i 1.47+1.59i 1.08-0.28i 0.20-0.12i -0.07+1.23i 0.26+0.26i .$
The function first performs a $QR$ factorization of $A$ as $A={Q}_{a}R$ and then reduces the factor $R$ to bidiagonal form $B$: $R={Q}_{b}B{P}^{\mathrm{H}}$. Finally it forms ${Q}_{a}$ and calls nag_lapack_zunmbr (f08ku) to form $Q={Q}_{a}{Q}_{b}$.
In the second example, $m, and
 $A = 0.28-0.36i 0.50-0.86i -0.77-0.48i 1.58+0.66i -0.50-1.10i -1.21+0.76i -0.32-0.24i -0.27-1.15i 0.36-0.51i -0.07+1.33i -0.75+0.47i -0.08+1.01i .$
The function first performs an $LQ$ factorization of $A$ as $A=L{P}_{a}^{\mathrm{H}}$ and then reduces the factor $L$ to bidiagonal form $B$: $L=QB{P}_{b}^{\mathrm{H}}$. Finally it forms ${P}_{b}^{\mathrm{H}}$ and calls nag_lapack_zunmbr (f08ku) to form ${P}^{\mathrm{H}}={P}_{b}^{\mathrm{H}}{P}_{a}^{\mathrm{H}}$.
```function f08ku_example

fprintf('f08ku example results\n\n');

% Two cases of preceding reduction to bidiagonal form by QR or LQ
% Case 1: m > n, precede by QR
ex1;
% Case 2: m < n, precede by LQ
ex2;

function ex1
m = int64(6);
n = int64(4);
a = [ 0.96 - 0.81i, -0.03 + 0.96i, -0.91 + 2.06i, -0.05 + 0.41i;
-0.98 + 1.98i, -1.20 + 0.19i, -0.66 + 0.42i, -0.81 + 0.56i;
0.62 - 0.46i,  1.01 + 0.02i,  0.63 - 0.17i, -1.11 + 0.60i;
-0.37 + 0.38i,  0.19 - 0.54i, -0.98 - 0.36i,  0.22 - 0.20i;
0.83 + 0.51i,  0.20 + 0.01i, -0.17 - 0.46i,  1.47 + 1.59i;
1.08 - 0.28i,  0.20 - 0.12i, -0.07 + 1.23i,  0.26 + 0.26i];

% Factorize A = QR
[QR, tau, info] = f08as(a);

% Generate Q from QR
[Q, info] = f08at(QR, tau);

% Extract R from QR
R = triu(QR(1:n,1:n));

% Bidiagonalize R = Q1 B P^H
[B, d, e, tauq, taup, info] = ...
f08ks(R);

% Update Q: Q2 = Q*Q1 (so A = QR = Q2 B P^H)
vect = 'Q';
side = 'Right';
trans = 'No transpose';
[Q2, info] = f08ku( ...
vect, side, trans, n, B, tauq, Q);

fprintf('Example 1: bidiagonal matrix B\n   Main diagonal  ');
fprintf(' %7.3f',d);
fprintf('\n   super-diagonal ');
fprintf(' %7.3f',e);
fprintf('\n\n');
disp('Example 1: Orthogonal matrix Q');
disp(Q2);

function ex2
m = int64(3);
n = int64(4);
a = [0.28 - 0.36i  0.50 - 0.86i -0.77 - 0.48i  1.58 + 0.66i;
-0.50 - 1.10i -1.21 + 0.76i -0.32 - 0.24i -0.27 - 1.15i;
0.36 - 0.51i -0.07 + 1.33i -0.75 + 0.47i -0.08 + 1.01i];

% Factorize A = LQ
[LQ, tau, info] = f08av(a);

% Generate Q from LQ
[Q, info] = f08aw(LQ, tau);

% Extract L from LQ
L = tril(LQ(1:m,1:m));

% Bidiagonalize L = Q1 B P^H
[B, d, e, tauq, taup, info] = ...
f08ks(L);

% Update Q: P2 = P^H*Q (so A = LQ = Q1 B P2)
vect = 'P';
side = 'Left';
trans = 'Conjugate Transpose';
[P2, info] = f08ku( ...
vect, side, trans, n, B, taup, Q);

fprintf('Example 2: bidiagonal matrix B\n   Main diagonal  ');
fprintf(' %7.3f',d);
fprintf('\n   super-diagonal ');
fprintf(' %7.3f',e);
fprintf('\n\n');
disp('Example 2: Orthogonal matrix P^H');
disp(P2);
```
```f08ku example results

Example 1: bidiagonal matrix B
Main diagonal    -3.087  -2.066  -1.873  -2.002
super-diagonal    2.113  -1.263   1.613

Example 1: Orthogonal matrix Q
-0.3110 + 0.2624i   0.6521 + 0.5532i   0.0427 + 0.0361i  -0.2634 - 0.0741i
0.3175 - 0.6414i   0.3488 + 0.0721i   0.2287 + 0.0069i   0.1101 - 0.0326i
-0.2008 + 0.1490i  -0.3103 + 0.0230i   0.1855 - 0.1817i  -0.2956 + 0.5648i
0.1199 - 0.1231i  -0.0046 - 0.0005i  -0.3305 + 0.4821i  -0.0675 + 0.3464i
-0.2689 - 0.1652i   0.1794 - 0.0586i  -0.5235 - 0.2580i   0.3927 + 0.1450i
-0.3499 + 0.0907i   0.0829 - 0.0506i   0.3202 + 0.3038i   0.3174 + 0.3241i

Example 2: bidiagonal matrix B
Main diagonal     2.761   1.630  -1.327
super-diagonal   -0.950  -1.018

Example 2: Orthogonal matrix P^H
-0.1258 + 0.1618i  -0.2247 + 0.3864i   0.3460 + 0.2157i  -0.7099 - 0.2966i
0.4148 + 0.1795i   0.1368 - 0.3976i   0.6885 + 0.3386i   0.1667 - 0.0494i
0.4575 - 0.4807i  -0.2733 + 0.4981i  -0.0230 + 0.3861i   0.1730 + 0.2395i

```