# NAG C Library Function Document

## 1Purpose

nag_zgbbrd (f08lsc) reduces a complex $m$ by $n$ band matrix to real upper bidiagonal form.

## 2Specification

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

## 3Description

nag_zgbbrd (f08lsc) reduces a complex $m$ by $n$ band matrix to real upper bidiagonal form $B$ by a unitary transformation: $A=QB{P}^{\mathrm{H}}$. The unitary matrices $Q$ and ${P}^{\mathrm{H}}$, 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{H}}C$.
The function uses a vectorizable form of the reduction.
None.

## 5Arguments

1:    $\mathbf{order}$Nag_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.3.1.3 in How to Use the NAG Library and its Documentation 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_VectTypeInput
On entry: indicates whether the matrices $Q$ and/or ${P}^{\mathrm{H}}$ are generated.
${\mathbf{vect}}=\mathrm{Nag_DoNotForm}$
Neither $Q$ nor ${P}^{\mathrm{H}}$ is generated.
${\mathbf{vect}}=\mathrm{Nag_FormQ}$
$Q$ is generated.
${\mathbf{vect}}=\mathrm{Nag_FormP}$
${P}^{\mathrm{H}}$ is generated.
${\mathbf{vect}}=\mathrm{Nag_FormBoth}$
Both $Q$ and ${P}^{\mathrm{H}}$ are generated.
Constraint: ${\mathbf{vect}}=\mathrm{Nag_DoNotForm}$, $\mathrm{Nag_FormQ}$, $\mathrm{Nag_FormP}$ or $\mathrm{Nag_FormBoth}$.
3:    $\mathbf{m}$IntegerInput
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{m}}\ge 0$.
4:    $\mathbf{n}$IntegerInput
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
5:    $\mathbf{ncc}$IntegerInput
On entry: ${n}_{C}$, the number of columns of the matrix $C$.
Constraint: ${\mathbf{ncc}}\ge 0$.
6:    $\mathbf{kl}$IntegerInput
On entry: the number of subdiagonals, ${k}_{l}$, within the band of $A$.
Constraint: ${\mathbf{kl}}\ge 0$.
7:    $\mathbf{ku}$IntegerInput
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]$ComplexInput/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}$IntegerInput
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]$doubleOutput
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]$doubleOutput
On exit: the superdiagonal elements of the bidiagonal matrix $B$.
12:  $\mathbf{q}\left[\mathit{dim}\right]$ComplexOutput
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$ unitary matrix $Q$.
If ${\mathbf{vect}}=\mathrm{Nag_DoNotForm}$ or $\mathrm{Nag_FormP}$, q is not referenced.
13:  $\mathbf{pdq}$IntegerInput
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]$ComplexOutput
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$ unitary matrix ${P}^{\mathrm{H}}$, 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}$IntegerInput
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]$ComplexInput/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{H}}C$. If ${\mathbf{ncc}}=0$, c is not referenced.
17:  $\mathbf{pdc}$IntegerInput
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 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
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 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

The computed bidiagonal form $B$ satisfies $QB{P}^{\mathrm{H}}=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 unitary matrix by a matrix $F$ such that
 $F2 = Oε .$
A similar statement holds for the computed matrix ${P}^{\mathrm{H}}$.

## 8Parallelism and Performance

nag_zgbbrd (f08lsc) 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.

## 9Further Comments

The total number of real floating-point operations is approximately the sum of:
• $20{n}^{2}k$, if ${\mathbf{vect}}=\mathrm{Nag_DoNotForm}$ and ${\mathbf{ncc}}=0$, and
• $10{n}^{2}{n}_{C}\left(k-1\right)/k$, if $C$ is updated, and
• $10{n}^{3}\left(k-1\right)/k$, if either $Q$ or ${P}^{\mathrm{H}}$ 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 real analogue of this function is nag_dgbbrd (f08lec).

## 10Example

This example reduces the matrix $A$ to upper bidiagonal form, where
 $A = 0.96-0.81i -0.03+0.96i 0.00+0.00i 0.00+0.00i -0.98+1.98i -1.20+0.19i -0.66+0.42i 0.00+0.00i 0.62-0.46i 1.01+0.02i 0.63-0.17i -1.11+0.60i 0.00+0.00i 0.19-0.54i -0.98-0.36i 0.22-0.20i 0.00+0.00i 0.00+0.00i -0.17-0.46i 1.47+1.59i 0.00+0.00i 0.00+0.00i 0.00+0.00i 0.26+0.26i .$

### 10.1Program Text

Program Text (f08lsce.c)

### 10.2Program Data

Program Data (f08lsce.d)

### 10.3Program Results

Program Results (f08lsce.r)