F08 Chapter Contents
F08 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF08KGF (DORMBR)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F08KGF (DORMBR) multiplies an arbitrary real $m$ by $n$ matrix $C$ by one of the real orthogonal matrices $Q$ or $P$ which were determined by F08KEF (DGEBRD) when reducing a real matrix to bidiagonal form.

## 2  Specification

 SUBROUTINE F08KGF ( VECT, SIDE, TRANS, M, N, K, A, LDA, TAU, C, LDC, WORK, LWORK, INFO)
 INTEGER M, N, K, LDA, LDC, LWORK, INFO REAL (KIND=nag_wp) A(LDA,*), TAU(*), C(LDC,*), WORK(max(1,LWORK)) CHARACTER(1) VECT, SIDE, TRANS
The routine may be called by its LAPACK name dormbr.

## 3  Description

F08KGF (DORMBR) is intended to be used after a call to F08KEF (DGEBRD), which reduces a real rectangular matrix $A$ to bidiagonal form $B$ by an orthogonal transformation: $A=QB{P}^{\mathrm{T}}$. F08KEF (DGEBRD) represents the matrices $Q$ and ${P}^{\mathrm{T}}$ as products of elementary reflectors.
This routine may be used to form one of the matrix products
 $QC , QTC , CQ , CQT , PC , PTC , CP ​ or ​ CPT ,$
overwriting the result on $C$ (which may be any real rectangular matrix).

## 4  References

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

## 5  Parameters

Note: in the descriptions below, $\mathit{r}$ denotes the order of $Q$ or ${P}^{\mathrm{T}}$: if ${\mathbf{SIDE}}=\text{'L'}$, $\mathit{r}={\mathbf{M}}$ and if ${\mathbf{SIDE}}=\text{'R'}$, $\mathit{r}={\mathbf{N}}$.
1:     VECT – CHARACTER(1)Input
On entry: indicates whether $Q$ or ${Q}^{\mathrm{T}}$ or $P$ or ${P}^{\mathrm{T}}$ is to be applied to $C$.
${\mathbf{VECT}}=\text{'Q'}$
$Q$ or ${Q}^{\mathrm{T}}$ is applied to $C$.
${\mathbf{VECT}}=\text{'P'}$
$P$ or ${P}^{\mathrm{T}}$ is applied to $C$.
Constraint: ${\mathbf{VECT}}=\text{'Q'}$ or $\text{'P'}$.
2:     SIDE – CHARACTER(1)Input
On entry: indicates how $Q$ or ${Q}^{\mathrm{T}}$ or $P$ or ${P}^{\mathrm{T}}$ is to be applied to $C$.
${\mathbf{SIDE}}=\text{'L'}$
$Q$ or ${Q}^{\mathrm{T}}$ or $P$ or ${P}^{\mathrm{T}}$ is applied to $C$ from the left.
${\mathbf{SIDE}}=\text{'R'}$
$Q$ or ${Q}^{\mathrm{T}}$ or $P$ or ${P}^{\mathrm{T}}$ is applied to $C$ from the right.
Constraint: ${\mathbf{SIDE}}=\text{'L'}$ or $\text{'R'}$.
3:     TRANS – CHARACTER(1)Input
On entry: indicates whether $Q$ or $P$ or ${Q}^{\mathrm{T}}$ or ${P}^{\mathrm{T}}$ is to be applied to $C$.
${\mathbf{TRANS}}=\text{'N'}$
$Q$ or $P$ is applied to $C$.
${\mathbf{TRANS}}=\text{'T'}$
${Q}^{\mathrm{T}}$ or ${P}^{\mathrm{T}}$ is applied to $C$.
Constraint: ${\mathbf{TRANS}}=\text{'N'}$ or $\text{'T'}$.
4:     M – INTEGERInput
On entry: $m$, the number of rows of the matrix $C$.
Constraint: ${\mathbf{M}}\ge 0$.
5:     N – INTEGERInput
On entry: $n$, the number of columns of the matrix $C$.
Constraint: ${\mathbf{N}}\ge 0$.
6:     K – INTEGERInput
On entry: 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$.
7:     A(LDA,$*$) – REAL (KIND=nag_wp) arrayInput
Note: 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'}$.
On entry: details of the vectors which define the elementary reflectors, as returned by F08KEF (DGEBRD).
8:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which F08KGF (DORMBR) is called.
Constraints:
• if ${\mathbf{VECT}}=\text{'Q'}$, ${\mathbf{LDA}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,\mathit{r}\right)$;
• if ${\mathbf{VECT}}=\text{'P'}$, ${\mathbf{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)$.
9:     TAU($*$) – REAL (KIND=nag_wp) arrayInput
Note: 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)$.
On entry: further details of the elementary reflectors, as returned by F08KEF (DGEBRD) in its parameter TAUQ if ${\mathbf{VECT}}=\text{'Q'}$, or in its parameter TAUP if ${\mathbf{VECT}}=\text{'P'}$.
10:   C(LDC,$*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array C must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the matrix $C$.
On exit: C is overwritten by $QC$ or ${Q}^{\mathrm{T}}C$ or $CQ$ or ${C}^{\mathrm{T}}Q$ or $PC$ or ${P}^{\mathrm{T}}C$ or $CP$ or ${C}^{\mathrm{T}}P$ as specified by VECT, SIDE and TRANS.
11:   LDC – INTEGERInput
On entry: the first dimension of the array C as declared in the (sub)program from which F08KGF (DORMBR) is called.
Constraint: ${\mathbf{LDC}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}}\right)$.
12:   WORK($\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LWORK}}\right)$) – REAL (KIND=nag_wp) arrayWorkspace
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$, ${\mathbf{WORK}}\left(1\right)$ contains the minimum value of LWORK required for optimal performance.
13:   LWORK – INTEGERInput
On entry: the dimension of the array WORK as declared in the (sub)program from which F08KGF (DORMBR) is called.
If ${\mathbf{LWORK}}=-1$, a workspace query is assumed; the routine only calculates the optimal size of the WORK array, returns this value as the first entry of the WORK array, and no error message related to LWORK is issued.
Suggested value: for optimal performance, ${\mathbf{LWORK}}\ge {\mathbf{N}}×\mathit{nb}$ if ${\mathbf{SIDE}}=\text{'L'}$ and at least ${\mathbf{M}}×\mathit{nb}$ if ${\mathbf{SIDE}}=\text{'R'}$, where $\mathit{nb}$ is the optimal block size.
Constraints:
• if ${\mathbf{SIDE}}=\text{'L'}$, ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$ or ${\mathbf{LWORK}}=-1$;
• if ${\mathbf{SIDE}}=\text{'R'}$, ${\mathbf{LWORK}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{M}}\right)$ or ${\mathbf{LWORK}}=-1$.
14:   INFO – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

Errors or warnings detected by the routine:
${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, argument $i$ had an illegal value. An explanatory message is output, and execution of the program is terminated.

## 7  Accuracy

The computed result differs from the exact result by a matrix $E$ such that
 $E2 = Oε C2 ,$
where $\epsilon$ is the machine precision.

## 8  Further Comments

The total number of floating point operations is approximately
• if ${\mathbf{SIDE}}=\text{'L'}$ and $m\ge k$, $2nk\left(2m-k\right)$;
• if ${\mathbf{SIDE}}=\text{'R'}$ and $n\ge k$, $2mk\left(2n-k\right)$;
• if ${\mathbf{SIDE}}=\text{'L'}$ and $m, $2{m}^{2}n$;
• if ${\mathbf{SIDE}}=\text{'R'}$ and $n, $2m{n}^{2}$,
where $k$ is the value of the parameter K.
The complex analogue of this routine is F08KUF (ZUNMBR).

## 9  Example

For this routine 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.57 -1.28 -0.39 0.25 -1.93 1.08 -0.31 -2.14 2.30 0.24 0.40 -0.35 -1.93 0.64 -0.66 0.08 0.15 0.30 0.15 -2.13 -0.02 1.03 -1.43 0.50 .$
The routine 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{T}}$. Finally it forms ${Q}_{a}$ and calls F08KGF (DORMBR) to form $Q={Q}_{a}{Q}_{b}$.
In the second example, $m, and
 $A = -5.42 3.28 -3.68 0.27 2.06 0.46 -1.65 -3.40 -3.20 -1.03 -4.06 -0.01 -0.37 2.35 1.90 4.31 -1.76 1.13 -3.15 -0.11 1.99 -2.70 0.26 4.50 .$
The routine first performs an $LQ$ factorization of $A$ as $A=L{P}_{a}^{\mathrm{T}}$ and then reduces the factor $L$ to bidiagonal form $B$: $L=QB{P}_{b}^{\mathrm{T}}$. Finally it forms ${P}_{b}^{\mathrm{T}}$ and calls F08KGF (DORMBR) to form ${P}^{\mathrm{T}}={P}_{b}^{\mathrm{T}}{P}_{a}^{\mathrm{T}}$.

### 9.1  Program Text

Program Text (f08kgfe.f90)

### 9.2  Program Data

Program Data (f08kgfe.d)

### 9.3  Program Results

Program Results (f08kgfe.r)