# NAG Library Routine Document

## 1Purpose

f08lef (dgbbrd) reduces a real $m$ by $n$ band matrix to upper bidiagonal form.

## 2Specification

Fortran Interface
 Subroutine f08lef ( vect, m, n, ncc, kl, ku, ab, ldab, d, e, q, ldq, pt, ldpt, c, ldc, work, info)
 Integer, Intent (In) :: m, n, ncc, kl, ku, ldab, ldq, ldpt, ldc Integer, Intent (Out) :: info Real (Kind=nag_wp), Intent (Inout) :: ab(ldab,*), q(ldq,*), pt(ldpt,*), c(ldc,*) Real (Kind=nag_wp), Intent (Out) :: d(min(m,n)), e(min(m,n)-1), work(2*max(m,n)) Character (1), Intent (In) :: vect
C Header Interface
#include <nagmk26.h>
 void f08lef_ (const char *vect, const Integer *m, const Integer *n, const Integer *ncc, const Integer *kl, const Integer *ku, double ab[], const Integer *ldab, double d[], double e[], double q[], const Integer *ldq, double pt[], const Integer *ldpt, double c[], const Integer *ldc, double work[], Integer *info, const Charlen length_vect)
The routine may be called by its LAPACK name dgbbrd.

## 3Description

f08lef (dgbbrd) reduces a real $m$ by $n$ band matrix to upper bidiagonal form $B$ by an orthogonal transformation: $A=QB{P}^{\mathrm{T}}$. The orthogonal matrices $Q$ and ${P}^{\mathrm{T}}$, of order $m$ and $n$ respectively, are determined as a product of Givens rotation matrices, and may be formed explicitly by the routine if required. A matrix $C$ may also be updated to give $\stackrel{~}{C}={Q}^{\mathrm{T}}C$.
The routine uses a vectorizable form of the reduction.

None.

## 5Arguments

1:     $\mathbf{vect}$ – Character(1)Input
On entry: indicates whether the matrices $Q$ and/or ${P}^{\mathrm{T}}$ are generated.
${\mathbf{vect}}=\text{'N'}$
Neither $Q$ nor ${P}^{\mathrm{T}}$ is generated.
${\mathbf{vect}}=\text{'Q'}$
$Q$ is generated.
${\mathbf{vect}}=\text{'P'}$
${P}^{\mathrm{T}}$ is generated.
${\mathbf{vect}}=\text{'B'}$
Both $Q$ and ${P}^{\mathrm{T}}$ are generated.
Constraint: ${\mathbf{vect}}=\text{'N'}$, $\text{'Q'}$, $\text{'P'}$ or $\text{'B'}$.
2:     $\mathbf{m}$ – IntegerInput
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{m}}\ge 0$.
3:     $\mathbf{n}$ – IntegerInput
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
4:     $\mathbf{ncc}$ – IntegerInput
On entry: ${n}_{C}$, the number of columns of the matrix $C$.
Constraint: ${\mathbf{ncc}}\ge 0$.
5:     $\mathbf{kl}$ – IntegerInput
On entry: the number of subdiagonals, ${k}_{l}$, within the band of $A$.
Constraint: ${\mathbf{kl}}\ge 0$.
6:     $\mathbf{ku}$ – IntegerInput
On entry: the number of superdiagonals, ${k}_{u}$, within the band of $A$.
Constraint: ${\mathbf{ku}}\ge 0$.
7:     $\mathbf{ab}\left({\mathbf{ldab}},*\right)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array ab must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the original $m$ by $n$ band matrix $A$.
The matrix is stored in rows $1$ to ${k}_{l}+{k}_{u}+1$, more precisely, the element ${A}_{ij}$ must be stored in
 $abku+1+i-jj for ​max1,j-ku≤i≤minm,j+kl.$
On exit: ab is overwritten by values generated during the reduction.
8:     $\mathbf{ldab}$ – IntegerInput
On entry: the first dimension of the array ab as declared in the (sub)program from which f08lef (dgbbrd) is called.
Constraint: ${\mathbf{ldab}}\ge {\mathbf{kl}}+{\mathbf{ku}}+1$.
9:     $\mathbf{d}\left(\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the diagonal elements of the bidiagonal matrix $B$.
10:   $\mathbf{e}\left(\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)-1\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the superdiagonal elements of the bidiagonal matrix $B$.
11:   $\mathbf{q}\left({\mathbf{ldq}},*\right)$ – Real (Kind=nag_wp) arrayOutput
Note: the second dimension of the array q must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$ if ${\mathbf{vect}}=\text{'Q'}$ or $\text{'B'}$, and at least $1$ otherwise.
On exit: if ${\mathbf{vect}}=\text{'Q'}$ or $\text{'B'}$, contains the $m$ by $m$ orthogonal matrix $Q$.
If ${\mathbf{vect}}=\text{'N'}$ or $\text{'P'}$, q is not referenced.
12:   $\mathbf{ldq}$ – IntegerInput
On entry: the first dimension of the array q as declared in the (sub)program from which f08lef (dgbbrd) is called.
Constraints:
• if ${\mathbf{vect}}=\text{'Q'}$ or $\text{'B'}$, ${\mathbf{ldq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• otherwise ${\mathbf{ldq}}\ge 1$.
13:   $\mathbf{pt}\left({\mathbf{ldpt}},*\right)$ – Real (Kind=nag_wp) arrayOutput
Note: the second dimension of the array pt must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if ${\mathbf{vect}}=\text{'P'}$ or $\text{'B'}$, and at least $1$ otherwise.
On exit: the $n$ by $n$ orthogonal matrix ${P}^{\mathrm{T}}$, if ${\mathbf{vect}}=\text{'P'}$ or $\text{'B'}$. If ${\mathbf{vect}}=\text{'N'}$ or $\text{'Q'}$, pt is not referenced.
14:   $\mathbf{ldpt}$ – IntegerInput
On entry: the first dimension of the array pt as declared in the (sub)program from which f08lef (dgbbrd) is called.
Constraints:
• if ${\mathbf{vect}}=\text{'P'}$ or $\text{'B'}$, ${\mathbf{ldpt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ${\mathbf{ldpt}}\ge 1$.
15:   $\mathbf{c}\left({\mathbf{ldc}},*\right)$ – 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{ncc}}\right)$.
On entry: an $m$ by ${n}_{C}$ matrix $C$.
On exit: c is overwritten by ${Q}^{\mathrm{T}}C$. If ${\mathbf{ncc}}=0$, c is not referenced.
16:   $\mathbf{ldc}$ – IntegerInput
On entry: the first dimension of the array c as declared in the (sub)program from which f08lef (dgbbrd) is called.
Constraints:
• if ${\mathbf{ncc}}>0$, ${\mathbf{ldc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if ${\mathbf{ncc}}=0$, ${\mathbf{ldc}}\ge 1$.
17:   $\mathbf{work}\left(2×\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)\right)$ – Real (Kind=nag_wp) arrayWorkspace
18:   $\mathbf{info}$ – IntegerOutput
On exit: ${\mathbf{info}}=0$ unless the routine detects an error (see Section 6).

## 6Error Indicators and Warnings

${\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.

## 7Accuracy

The computed bidiagonal form $B$ satisfies $QB{P}^{\mathrm{T}}=A+E$, where
 $E2 ≤ c n ε A2 ,$
$c\left(n\right)$ is a modestly increasing function of $n$, and $\epsilon$ is the machine precision.
The elements of $B$ themselves may be sensitive to small perturbations in $A$ or to rounding errors in the computation, but this does not affect the stability of the singular values and vectors.
The computed matrix $Q$ differs from an exactly orthogonal matrix by a matrix $F$ such that
 $F2 = Oε .$
A similar statement holds for the computed matrix ${P}^{\mathrm{T}}$.

## 8Parallelism and Performance

f08lef (dgbbrd) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

## 9Further Comments

The total number of real floating-point operations is approximately the sum of:
• $6{n}^{2}k$, if ${\mathbf{vect}}=\text{'N'}$ and ${\mathbf{ncc}}=0$, and
• $3{n}^{2}{n}_{C}\left(k-1\right)/k$, if $C$ is updated, and
• $3{n}^{3}\left(k-1\right)/k$, if either $Q$ or ${P}^{\mathrm{T}}$ is generated (double this if both),
where $k={k}_{l}+{k}_{u}$, assuming $n\gg k$. For this section we assume that $m=n$.
The complex analogue of this routine is f08lsf (zgbbrd).

## 10Example

This example reduces the matrix $A$ to upper bidiagonal form, where
 $A = -0.57 -1.28 0.00 0.00 -1.93 1.08 -0.31 0.00 2.30 0.24 0.40 -0.35 0.00 0.64 -0.66 0.08 0.00 0.00 0.15 -2.13 -0.00 0.00 0.00 0.50 .$

### 10.1Program Text

Program Text (f08lefe.f90)

### 10.2Program Data

Program Data (f08lefe.d)

### 10.3Program Results

Program Results (f08lefe.r)