# NAG CL Interfacef07btc (zgbequ)

## 1Purpose

f07btc computes diagonal scaling matrices ${D}_{R}$ and ${D}_{C}$ intended to equilibrate a complex $m$ by $n$ band matrix $A$ of band width $\left({k}_{l}+{k}_{u}+1\right)$, and reduce its condition number.

## 2Specification

 #include
 void f07btc (Nag_OrderType order, Integer m, Integer n, Integer kl, Integer ku, const Complex ab[], Integer pdab, double r[], double c[], double *rowcnd, double *colcnd, double *amax, NagError *fail)
The function may be called by the names: f07btc, nag_lapacklin_zgbequ or nag_zgbequ.

## 3Description

f07btc computes the diagonal scaling matrices. The diagonal scaling matrices are chosen to try to make the elements of largest absolute value in each row and column of the matrix $B$ given by
 $B = DR A DC$
have absolute value $1$. The diagonal elements of ${D}_{R}$ and ${D}_{C}$ are restricted to lie in the safe range $\left(\delta ,1/\delta \right)$, where $\delta$ is the value returned by function X02AMC. Use of these scaling factors is not guaranteed to reduce the condition number of $A$ but works well in practice.

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{m}$Integer Input
On entry: $m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{m}}\ge 0$.
3: $\mathbf{n}$Integer Input
On entry: $n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
4: $\mathbf{kl}$Integer Input
On entry: ${k}_{l}$, the number of subdiagonals of the matrix $A$.
Constraint: ${\mathbf{kl}}\ge 0$.
5: $\mathbf{ku}$Integer Input
On entry: ${k}_{u}$, the number of superdiagonals of the matrix $A$.
Constraint: ${\mathbf{ku}}\ge 0$.
6: $\mathbf{ab}\left[\mathit{dim}\right]$const Complex Input
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 $m$ by $n$ band matrix $A$ whose scaling factors are to be computed.
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]$.
See Section 9 in f07bnc for further details.
7: $\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$.
8: $\mathbf{r}\left[{\mathbf{m}}\right]$double Output
On exit: if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR or ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_MAT_COL_ZERO, r contains the row scale factors, the diagonal elements of ${D}_{R}$. The elements of r will be positive.
9: $\mathbf{c}\left[{\mathbf{n}}\right]$double Output
On exit: if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, c contains the column scale factors, the diagonal elements of ${D}_{C}$. The elements of c will be positive.
10: $\mathbf{rowcnd}$double * Output
On exit: if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR or ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_MAT_COL_ZERO, rowcnd contains the ratio of the smallest value of ${\mathbf{r}}\left[i-1\right]$ to the largest value of ${\mathbf{r}}\left[i-1\right]$. If ${\mathbf{rowcnd}}\ge 0.1$ and amax is neither too large nor too small, it is not worth scaling by ${D}_{R}$.
11: $\mathbf{colcnd}$double * Output
On exit: if ${\mathbf{fail}}\mathbf{.}\mathbf{code}=$ NE_NOERROR, colcnd contains the ratio of the smallest value of ${\mathbf{c}}\left[i-1\right]$ to the largest value of ${\mathbf{c}}\left[i-1\right]$.
If ${\mathbf{colcnd}}\ge 0.1$, it is not worth scaling by ${D}_{C}$.
12: $\mathbf{amax}$double * Output
On exit: $\mathrm{max}\left|{a}_{ij}\right|$. If amax is very close to overflow or underflow, the matrix $A$ should be scaled.
13: $\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_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{pdab}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pdab}}>0$.
NE_INT_3
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_MAT_COL_ZERO
Column $〈\mathit{\text{value}}〉$ of $A$ is exactly zero.
NE_MAT_ROW_ZERO
Row $〈\mathit{\text{value}}〉$ of $A$ is exactly zero.
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 scale factors will be close to the exact scale factors.

## 8Parallelism and Performance

f07btc 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 real analogue of this function is f07bfc.

## 10Example

This example equilibrates the complex band matrix $A$ given by
 $A = -1.65+2.26i -2.05-0.85i×10-10 -(0.97-2.84i ((0 -0.00+6.30i -1.48-1.75i×10-10 (-3.99+4.01i ((0.59-0.48i -0 (-0.77+2.83i -1.06+1.94i×1010 (3.33-1.04i×1010 -0 -(0 -(0.48-1.09i -0.46-1.72i .$
Details of the scaling factors, and the scaled matrix are output.

### 10.1Program Text

Program Text (f07btce.c)

### 10.2Program Data

Program Data (f07btce.d)

### 10.3Program Results

Program Results (f07btce.r)