f08 Chapter Contents
f08 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_dgbbrd (f08lec)

## 1  Purpose

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

## 2  Specification

 #include #include
 void nag_dgbbrd (Nag_OrderType order, Nag_VectType vect, Integer m, Integer n, Integer ncc, Integer kl, Integer ku, double ab[], Integer pdab, double d[], double e[], double q[], Integer pdq, double pt[], Integer pdpt, double c[], Integer pdc, NagError *fail)

## 3  Description

nag_dgbbrd (f08lec) 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 function if required. A matrix $C$ may also be updated to give $\stackrel{~}{C}={Q}^{\mathrm{T}}C$.
The function uses a vectorizable form of the reduction.

None.

## 5  Arguments

1:     orderNag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or Nag_ColMajor.
2:     vectNag_VectTypeInput
On entry: indicates whether the matrices $Q$ and/or ${P}^{\mathrm{T}}$ are generated.
${\mathbf{vect}}=\mathrm{Nag_DoNotForm}$
Neither $Q$ nor ${P}^{\mathrm{T}}$ is generated.
${\mathbf{vect}}=\mathrm{Nag_FormQ}$
$Q$ is generated.
${\mathbf{vect}}=\mathrm{Nag_FormP}$
${P}^{\mathrm{T}}$ is generated.
${\mathbf{vect}}=\mathrm{Nag_FormBoth}$
Both $Q$ and ${P}^{\mathrm{T}}$ are generated.
Constraint: ${\mathbf{vect}}=\mathrm{Nag_DoNotForm}$, $\mathrm{Nag_FormQ}$, $\mathrm{Nag_FormP}$ or $\mathrm{Nag_FormBoth}$.
3:     mIntegerInput
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{m}}\ge 0$.
4:     nIntegerInput
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
5:     nccIntegerInput
On entry: ${n}_{C}$, the number of columns of the matrix $C$.
Constraint: ${\mathbf{ncc}}\ge 0$.
6:     klIntegerInput
On entry: the number of subdiagonals, ${k}_{l}$, within the band of $A$.
Constraint: ${\mathbf{kl}}\ge 0$.
7:     kuIntegerInput
On entry: the number of superdiagonals, ${k}_{u}$, within the band of $A$.
Constraint: ${\mathbf{ku}}\ge 0$.
8:     ab[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array ab must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdab}}×{\mathbf{n}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}×{\mathbf{pdab}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On entry: the original $m$ by $n$ band matrix $A$.
This is stored as a notional two-dimensional array with row elements or column elements stored contiguously. The storage of elements ${A}_{ij}$, for row $i=1,\dots ,m$ and column $j=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,i-{k}_{l}\right),\dots ,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(n,i+{k}_{u}\right)$, depends on the order argument as follows:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${A}_{ij}$ is stored as ${\mathbf{ab}}\left[\left(j-1\right)×{\mathbf{pdab}}+{\mathbf{ku}}+i-j\right]$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${A}_{ij}$ is stored as ${\mathbf{ab}}\left[\left(i-1\right)×{\mathbf{pdab}}+{\mathbf{kl}}+j-i\right]$.
On exit: ab is overwritten by values generated during the reduction.
9:     pdabIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) of the matrix $A$ in the array ab.
Constraint: ${\mathbf{pdab}}\ge {\mathbf{kl}}+{\mathbf{ku}}+1$.
10:   d[$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)$]doubleOutput
On exit: the diagonal elements of the bidiagonal matrix $B$.
11:   e[$\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)-1$]doubleOutput
On exit: the superdiagonal elements of the bidiagonal matrix $B$.
12:   q[$\mathit{dim}$]doubleOutput
Note: the dimension, dim, of the array q must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdq}}×{\mathbf{m}}\right)$ when ${\mathbf{vect}}=\mathrm{Nag_FormQ}$ or $\mathrm{Nag_FormBoth}$;
• $1$ otherwise.
The $\left(i,j\right)$th element of the matrix $Q$ is stored in
• ${\mathbf{q}}\left[\left(j-1\right)×{\mathbf{pdq}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{q}}\left[\left(i-1\right)×{\mathbf{pdq}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: if ${\mathbf{vect}}=\mathrm{Nag_FormQ}$ or $\mathrm{Nag_FormBoth}$, contains the $m$ by $m$ orthogonal matrix $Q$.
If ${\mathbf{vect}}=\mathrm{Nag_DoNotForm}$ or $\mathrm{Nag_FormP}$, q is not referenced.
13:   pdqIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array q.
Constraints:
• if ${\mathbf{vect}}=\mathrm{Nag_FormQ}$ or $\mathrm{Nag_FormBoth}$, ${\mathbf{pdq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• otherwise ${\mathbf{pdq}}\ge 1$.
14:   pt[$\mathit{dim}$]doubleOutput
Note: the dimension, dim, of the array pt must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdpt}}×{\mathbf{n}}\right)$ when ${\mathbf{vect}}=\mathrm{Nag_FormP}$ or $\mathrm{Nag_FormBoth}$;
• $1$ otherwise.
The $\left(i,j\right)$th element of the matrix is stored in
• ${\mathbf{pt}}\left[\left(j-1\right)×{\mathbf{pdpt}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{pt}}\left[\left(i-1\right)×{\mathbf{pdpt}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: the $n$ by $n$ orthogonal matrix ${P}^{\mathrm{T}}$, if ${\mathbf{vect}}=\mathrm{Nag_FormP}$ or $\mathrm{Nag_FormBoth}$. If ${\mathbf{vect}}=\mathrm{Nag_DoNotForm}$ or $\mathrm{Nag_FormQ}$, pt is not referenced.
15:   pdptIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array pt.
Constraints:
• if ${\mathbf{vect}}=\mathrm{Nag_FormP}$ or $\mathrm{Nag_FormBoth}$, ${\mathbf{pdpt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• otherwise ${\mathbf{pdpt}}\ge 1$.
16:   c[$\mathit{dim}$]doubleInput/Output
Note: the dimension, dim, of the array c must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdc}}×{\mathbf{ncc}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}×{\mathbf{pdc}}\right)$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
The $\left(i,j\right)$th element of the matrix $C$ is stored in
• ${\mathbf{c}}\left[\left(j-1\right)×{\mathbf{pdc}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{c}}\left[\left(i-1\right)×{\mathbf{pdc}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
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.
17:   pdcIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array c.
Constraints:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$,
• if ${\mathbf{ncc}}>0$, ${\mathbf{pdc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
• if ${\mathbf{ncc}}=0$, ${\mathbf{pdc}}\ge 1$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${\mathbf{pdc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ncc}}\right)$.
18:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_ENUM_INT_2
On entry, ${\mathbf{vect}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdpt}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{vect}}=\mathrm{Nag_FormP}$ or $\mathrm{Nag_FormBoth}$, ${\mathbf{pdpt}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
otherwise ${\mathbf{pdpt}}\ge 1$.
On entry, ${\mathbf{vect}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdq}}=〈\mathit{\text{value}}〉$ and ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{vect}}=\mathrm{Nag_FormQ}$ or $\mathrm{Nag_FormBoth}$, ${\mathbf{pdq}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
otherwise ${\mathbf{pdq}}\ge 1$.
NE_INT
On entry, ${\mathbf{kl}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{kl}}\ge 0$.
On entry, ${\mathbf{ku}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ku}}\ge 0$.
On entry, ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{m}}\ge 0$.
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{ncc}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{ncc}}\ge 0$.
On entry, ${\mathbf{pdab}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdab}}>0$.
On entry, ${\mathbf{pdc}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdc}}>0$.
On entry, ${\mathbf{pdpt}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdpt}}>0$.
On entry, ${\mathbf{pdq}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdq}}>0$.
NE_INT_2
On entry, ${\mathbf{pdc}}=〈\mathit{\text{value}}〉$ and ${\mathbf{ncc}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{ncc}}\right)$.
NE_INT_3
On entry, ${\mathbf{ncc}}=〈\mathit{\text{value}}〉$, ${\mathbf{pdc}}=〈\mathit{\text{value}}〉$ and ${\mathbf{m}}=〈\mathit{\text{value}}〉$.
Constraint: if ${\mathbf{ncc}}>0$, ${\mathbf{pdc}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$;
if ${\mathbf{ncc}}=0$, ${\mathbf{pdc}}\ge 1$.
On entry, ${\mathbf{pdab}}=〈\mathit{\text{value}}〉$, ${\mathbf{kl}}=〈\mathit{\text{value}}〉$ and ${\mathbf{ku}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdab}}\ge {\mathbf{kl}}+{\mathbf{ku}}+1$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.

## 7  Accuracy

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}}$.

The total number of real floating point operations is approximately the sum of:
• $6{n}^{2}k$, if ${\mathbf{vect}}=\mathrm{Nag_DoNotForm}$ 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 function is nag_zgbbrd (f08lsc).

## 9  Example

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

### 9.1  Program Text

Program Text (f08lece.c)

### 9.2  Program Data

Program Data (f08lece.d)

### 9.3  Program Results

Program Results (f08lece.r)