Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_zgeequ (f07at)

## Purpose

nag_lapack_zgeequ (f07at) computes real diagonal scaling matrices ${D}_{R}$ and ${D}_{C}$ intended to equilibrate a complex $m$ by $n$ matrix $A$ and reduce its condition number.

## Syntax

[r, c, rowcnd, colcnd, amax, info] = f07at(a, 'm', m, 'n', n)
[r, c, rowcnd, colcnd, amax, info] = nag_lapack_zgeequ(a, 'm', m, 'n', n)

## Description

nag_lapack_zgeequ (f07at) 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=DRADC$
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 nag_machine_real_safe (x02am). Use of these scaling factors is not guaranteed to reduce the condition number of $A$ but works well in practice.

None.

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{a}\left(\mathit{lda},:\right)$ – complex array
The first dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{m}}\right)$.
The second dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
The matrix $A$ whose scaling factors are to be computed.

### Optional Input Parameters

1:     $\mathrm{m}$int64int32nag_int scalar
Default: the first dimension of the array a.
$m$, the number of rows of the matrix $A$.
Constraint: ${\mathbf{m}}\ge 0$.
2:     $\mathrm{n}$int64int32nag_int scalar
Default: the second dimension of the array a.
$n$, the number of columns of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.

### Output Parameters

1:     $\mathrm{r}\left({\mathbf{m}}\right)$ – double array
If ${\mathbf{info}}={\mathbf{0}}$ or ${\mathbf{info}}>\mathbf{m}$, r contains the row scale factors, the diagonal elements of ${D}_{R}$. The elements of r will be positive.
2:     $\mathrm{c}\left({\mathbf{n}}\right)$ – double array
If ${\mathbf{info}}={\mathbf{0}}$, c contains the column scale factors, the diagonal elements of ${D}_{C}$. The elements of c will be positive.
3:     $\mathrm{rowcnd}$ – double scalar
If ${\mathbf{info}}={\mathbf{0}}$ or ${\mathbf{info}}>\mathbf{m}$, rowcnd contains the ratio of the smallest value of ${\mathbf{r}}\left(i\right)$ to the largest value of ${\mathbf{r}}\left(i\right)$. If ${\mathbf{rowcnd}}\ge 0.1$ and amax is neither too large nor too small, it is not worth scaling by ${D}_{R}$.
4:     $\mathrm{colcnd}$ – double scalar
If ${\mathbf{info}}={\mathbf{0}}$, colcnd contains the ratio of the smallest value of ${\mathbf{c}}\left(i\right)$ to the largest value of ${\mathbf{c}}\left(i\right)$.
If ${\mathbf{colcnd}}\ge 0.1$, it is not worth scaling by ${D}_{C}$.
5:     $\mathrm{amax}$ – double scalar
$\mathrm{max}\left|{a}_{ij}\right|$. If amax is very close to overflow or underflow, the matrix $A$ should be scaled.
6:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_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.
W  ${\mathbf{info}}>0 \text{and} {\mathbf{info}}\le {\mathbf{m}}$
Row $_$ of $A$ is exactly zero.
W  ${\mathbf{info}}>{\mathbf{m}}$
Column $_$ of $A$ is exactly zero.

## Accuracy

The computed scale factors will be close to the exact scale factors.

The real analogue of this function is nag_lapack_dgeequ (f07af).

## Example

This example equilibrates the general matrix $A$ given by
 $A = -1.34+2.55i (0.28+3.17i×1010 ((-6.39-2.20i -1.70-1.41i (3.31-0.15i×1010 ((-0.15+1.34i (2.41+0.39i×10-10 -0.56+1.47i (-0.83-0.69i×10-10 .$
Details of the scaling factors, and the scaled matrix are output.
```function f07at_example

fprintf('f07at example results\n\n');

a = [ -1.34     + 2.55i,     2.80e9  + 3.17e10i, -6.39    - 2.2i;
-1.70     - 1.41i,     3.31e10 - 1.50e9i,  -0.15    + 1.34i;
2.41e-10 + 3.9e-11i, -0.56    + 1.47i,    -8.3e-11 - 6.9e-11i];

% Compute row and column scaling factors
thresh = 0.1;
[r, c, rowcnd, colcnd, amax, info] = ...
f07at(a);

% Print rowcnd, colcnd, amax and the scale factors
format shorte;
fprintf('rowcnd = %8.1e colcnd = %8.1e amax = %8.1e\n', rowcnd, colcnd, amax);
fprintf('\nRow scale factors:\n');
disp(r');
fprintf('Column scale factors:\n');
disp(c');

% Compute values close to underflow and overflow
small = x02am/(x02aj*x02bh);
big = 1/small;

if (rowcnd >= thresh) && (amax >= small) && (amax <= big)
if colcnd<thresh
% Just column scale A
as = a*diag(c);
end
elseif colcnd>=thresh
% Just row scale A
as = diag(r)*a;
else
% Row and column scale A
as = diag(r)*a*diag(c);
end

format short
fprintf('Scaled Matrix:\n');
disp(as);

```
```f07at example results

rowcnd =  5.9e-11 colcnd =  1.4e-10 amax =  3.5e+10

Row scale factors:
2.8986e-11   2.8902e-11   4.9261e-01

Column scale factors:
7.2500e+09   1.0000e+00   4.0163e+09

Scaled Matrix:
-0.2816 + 0.5359i   0.0812 + 0.9188i  -0.7439 - 0.2561i
-0.3562 - 0.2954i   0.9566 - 0.0434i  -0.0174 + 0.1555i
0.8607 + 0.1393i  -0.2759 + 0.7241i  -0.1642 - 0.1365i

```