# NAG CL Interfacef08lec (dgbbrd)

## 1Purpose

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

## 2Specification

 #include
 void f08lec (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)
The function may be called by the names: f08lec, nag_lapackeig_dgbbrd or nag_dgbbrd.

## 3Description

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.

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
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.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{vect}$Nag_VectType Input
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: $\mathbf{m}$Integer Input
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{m}}\ge 0$.
4: $\mathbf{n}$Integer Input
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
5: $\mathbf{ncc}$Integer Input
On entry: ${n}_{C}$, the number of columns of the matrix $C$.
Constraint: ${\mathbf{ncc}}\ge 0$.
6: $\mathbf{kl}$Integer Input
On entry: the number of subdiagonals, ${k}_{l}$, within the band of $A$.
Constraint: ${\mathbf{kl}}\ge 0$.
7: $\mathbf{ku}$Integer Input
On entry: the number of superdiagonals, ${k}_{u}$, within the band of $A$.
Constraint: ${\mathbf{ku}}\ge 0$.
8: $\mathbf{ab}\left[\mathit{dim}\right]$double Input/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: $\mathbf{pdab}$Integer Input
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: $\mathbf{d}\left[\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)\right]$double Output
On exit: the diagonal elements of the bidiagonal matrix $B$.
11: $\mathbf{e}\left[\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left({\mathbf{m}},{\mathbf{n}}\right)-1\right]$double Output
On exit: the superdiagonal elements of the bidiagonal matrix $B$.
12: $\mathbf{q}\left[\mathit{dim}\right]$double Output
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: $\mathbf{pdq}$Integer Input
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: $\mathbf{pt}\left[\mathit{dim}\right]$double Output
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: $\mathbf{pdpt}$Integer Input
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: $\mathbf{c}\left[\mathit{dim}\right]$double Input/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: $\mathbf{pdc}$Integer Input
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: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

## 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

f08lec 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 function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

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

## 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 (f08lece.c)

### 10.2Program Data

Program Data (f08lece.d)

### 10.3Program Results

Program Results (f08lece.r)