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_dorgbr (f08kf)

## Purpose

nag_lapack_dorgbr (f08kf) generates one of the real orthogonal matrices Q$Q$ or PT${P}^{\mathrm{T}}$ which were determined by nag_lapack_dgebrd (f08ke) when reducing a real matrix to bidiagonal form.

## Syntax

[a, info] = f08kf(vect, k, a, tau, 'm', m, 'n', n)
[a, info] = nag_lapack_dorgbr(vect, k, a, tau, 'm', m, 'n', n)

## Description

nag_lapack_dorgbr (f08kf) is intended to be used after a call to nag_lapack_dgebrd (f08ke), which reduces a real rectangular matrix A$A$ to bidiagonal form B$B$ by an orthogonal transformation: A = QBPT$A=QB{P}^{\mathrm{T}}$. nag_lapack_dgebrd (f08ke) represents the matrices Q$Q$ and PT${P}^{\mathrm{T}}$ as products of elementary reflectors.
This function may be used to generate Q$Q$ or PT${P}^{\mathrm{T}}$ explicitly as square matrices, or in some cases just the leading columns of Q$Q$ or the leading rows of PT${P}^{\mathrm{T}}$.
The various possibilities are specified by the parameters vect, m, n and k. The appropriate values to cover the most likely cases are as follows (assuming that A$A$ was an m$m$ by n$n$ matrix):
1. To form the full m$m$ by m$m$ matrix Q$Q$:
```[a, info] = f08kf('Q', n, a, tau);
```
(note that the array a must have at least m$m$ columns).
2. If m > n$m>n$, to form the n$n$ leading columns of Q$Q$:
```[a, info] = f08kf('Q', n, a, tau);
```
3. To form the full n$n$ by n$n$ matrix PT${P}^{\mathrm{T}}$:
```[a, info] = f08kf('P', m, a, tau);
```
(note that the array a must have at least n$n$ rows).
4. If m < n$m, to form the m$m$ leading rows of PT${P}^{\mathrm{T}}$:
```[a, info] = f08kf('P', m, a, 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:     vect – string (length ≥ 1)
Indicates whether the orthogonal matrix Q$Q$ or PT${P}^{\mathrm{T}}$ is generated.
vect = 'Q'${\mathbf{vect}}=\text{'Q'}$
Q$Q$ is generated.
vect = 'P'${\mathbf{vect}}=\text{'P'}$
PT${P}^{\mathrm{T}}$ is generated.
Constraint: vect = 'Q'${\mathbf{vect}}=\text{'Q'}$ or 'P'$\text{'P'}$.
2:     k – int64int32nag_int scalar
If vect = 'Q'${\mathbf{vect}}=\text{'Q'}$, the number of columns in the original matrix A$A$.
If vect = 'P'${\mathbf{vect}}=\text{'P'}$, the number of rows in the original matrix A$A$.
Constraint: k0${\mathbf{k}}\ge 0$.
3:     a(lda, : $:$) – double 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_dgebrd (f08ke).
4:     tau( : $:$) – double array
Note: the dimension of the array tau must be at least max (1,min (m,k))$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{k}}\right)\right)$ if vect = 'Q'${\mathbf{vect}}=\text{'Q'}$ and at least max (1,min (n,k))$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{n}},{\mathbf{k}}\right)\right)$ if vect = 'P'${\mathbf{vect}}=\text{'P'}$.
Further details of the elementary reflectors, as returned by nag_lapack_dgebrd (f08ke) in its parameter tauq if vect = 'Q'${\mathbf{vect}}=\text{'Q'}$, or in its parameter taup if vect = 'P'${\mathbf{vect}}=\text{'P'}$.

### Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array a.
m$m$, the number of rows of the orthogonal matrix Q$Q$ or PT${P}^{\mathrm{T}}$ to be returned.
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 orthogonal matrix Q$Q$ or PT${P}^{\mathrm{T}}$ to be returned.
Constraints:
• n0${\mathbf{n}}\ge 0$;
• if vect = 'Q'${\mathbf{vect}}=\text{'Q'}$ and m > k${\mathbf{m}}>{\mathbf{k}}$, mnk${\mathbf{m}}\ge {\mathbf{n}}\ge {\mathbf{k}}$;
• if vect = 'Q'${\mathbf{vect}}=\text{'Q'}$ and mk${\mathbf{m}}\le {\mathbf{k}}$, m = n${\mathbf{m}}={\mathbf{n}}$;
• if vect = 'P'${\mathbf{vect}}=\text{'P'}$ and n > k${\mathbf{n}}>{\mathbf{k}}$, nmk${\mathbf{n}}\ge {\mathbf{m}}\ge {\mathbf{k}}$;
• if vect = 'P'${\mathbf{vect}}=\text{'P'}$ and nk${\mathbf{n}}\le {\mathbf{k}}$, n = m${\mathbf{n}}={\mathbf{m}}$.

lda work lwork

### Output Parameters

1:     a(lda, : $:$) – double 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 orthogonal matrix Q$Q$ or PT${P}^{\mathrm{T}}$, or the leading rows or columns thereof, as specified by vect, m and n.
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: vect, 2: m, 3: n, 4: k, 5: a, 6: lda, 7: tau, 8: work, 9: lwork, 10: 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. A similar statement holds for the computed matrix PT${P}^{\mathrm{T}}$.

The total number of floating point operations for the cases listed in Section [Description] are approximately as follows:
1. To form the whole of Q$Q$:
• (4/3)n(3m23mn + n2)$\frac{4}{3}n\left(3{m}^{2}-3mn+{n}^{2}\right)$ if m > n$m>n$,
• (4/3)m3$\frac{4}{3}{m}^{3}$ if mn$m\le n$;
2. To form the n$n$ leading columns of Q$Q$ when m > n$m>n$:
• (2/3) n2 (3mn) $\frac{2}{3}{n}^{2}\left(3m-n\right)$;
3. To form the whole of PT${P}^{\mathrm{T}}$:
• (4/3)n3$\frac{4}{3}{n}^{3}$ if mn$m\ge n$,
• (4/3)m(3n23mn + m2)$\frac{4}{3}m\left(3{n}^{2}-3mn+{m}^{2}\right)$ if m < n$m;
4. To form the m$m$ leading rows of PT${P}^{\mathrm{T}}$ when m < n$m:
• (2/3) m2 (3nm) $\frac{2}{3}{m}^{2}\left(3n-m\right)$.
The complex analogue of this function is nag_lapack_zungbr (f08kt).

## Example

```function nag_lapack_dorgbr_example
vect = 'P';
k = int64(6);
a = [-0.57, -1.28, -0.39,  0.25;
-1.93,  1.08, -0.31, -2.14;
2.3,   0.24,  0.4,  -0.35;
-1.93,  0.64, -0.66,  0.08;
0.15,  0.3,   0.15, -2.13;
-0.02,  1.03, -1.43,  0.5];
tau = [1.442198259457561;
1.915944323746201;
0;
0];
[a, d, e, tauq, taup, info] = nag_lapack_dgebrd(a);
[aOut, info] = nag_lapack_dorgbr(vect, k, a(1:4, :), taup)
```
```

aOut =

1.0000         0         0         0
0   -0.4422    0.6732    0.5927
0   -0.3788   -0.7391    0.5570
0    0.8130    0.0218    0.5818

info =

0

```
```function f08kf_example
vect = 'P';
k = int64(6);
a = [-0.57, -1.28, -0.39,  0.25;
-1.93,  1.08, -0.31, -2.14;
2.3,   0.24,  0.4,  -0.35;
-1.93,  0.64, -0.66,  0.08;
0.15,  0.3,   0.15, -2.13;
-0.02,  1.03, -1.43,  0.5];
tau = [1.442198259457561;
1.915944323746201;
0;
0];
[a, d, e, tauq, taup, info] = f08ke(a);
[aOut, info] = f08kf(vect, k, a(1:4, :), taup)
```
```

aOut =

1.0000         0         0         0
0   -0.4422    0.6732    0.5927
0   -0.3788   -0.7391    0.5570
0    0.8130    0.0218    0.5818

info =

0

```