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

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_zgeequ (f07at)

## Purpose

nag_lapack_zgeequ (f07at) computes real diagonal scaling matrices DR ${D}_{R}$ and DC ${D}_{C}$ intended to equilibrate a complex m $m$ by n $n$ matrix A $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 $B$ given by
 B = DRADC $B=DRADC$
have absolute value 1$1$. The diagonal elements of DR ${D}_{R}$ and DC ${D}_{C}$ are restricted to lie in the safe range (δ,1 / δ) $\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 $A$ but works well in practice.

None.

## Parameters

### Compulsory Input Parameters

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

### Optional Input Parameters

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

lda

### Output Parameters

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

info = i${\mathbf{info}}=-i$
If info = i${\mathbf{info}}=-i$, parameter i$i$ had an illegal value on entry. The parameters are numbered as follows:
1: m, 2: n, 3: a, 4: lda, 5: r, 6: c, 7: rowcnd, 8: colcnd, 9: amax, 10: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.
W INFO > 0andINFOM${\mathbf{INFO}}>0 \text{and} {\mathbf{INFO}}\le {\mathbf{M}}$
If info = i${\mathbf{info}}=i$, the i$i$th row of A$A$ is exactly zero.
W ${\mathbf{INFO}}>{\mathbf{M}}$
If info = i${\mathbf{info}}=i$, the (im)$\left(i-{\mathbf{m}}\right)$th column of A$A$ is exactly zero.

## Accuracy

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

## Further Comments

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

## Example

```function nag_lapack_zgeequ_example
n = 3;
a = [ -1.34 + 2.55i,  2800000000 + 31700000000i,  -6.39 - 2.2i;
-1.7 - 1.41i,  33100000000 - 1500000000i,  -0.15 + 1.34i;
2.41e-10 + 3.9e-11i,  -0.56 + 1.47i,  -8.3e-11 - 6.9e-11i];
thresh = 0.1;
% Compute row and column scaling factors
[r, c, rowcnd, colcnd, amax, info] = nag_lapack_zgeequ(a);

if info > 0
if info <= n
error('Row %d of A is exactly zero', info);
else
error('Column %d of A is exactly zero', info - n);
end
end

% Print ROWCND, COLCND, AMAX and the scale factors
format shorte
fprintf('\nROWCND = %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 = nag_machine_real_safe/(nag_machine_precision*nag_machine_model_base);
big = 1/small;

if (rowcnd >= thresh) && (amax >= small) && (amax <= big)
if (colcnd<thresh)
% Just column scale A
for j = 1:n
a(:, j) = c(j)* a(:, j);
end
end
elseif (colcnd>=thresh)
% Just row scale A
for j = 1:n
a(j, :) = r(j)* a(j, :);
end
else
% Row and column scale A
for j = 1:n
a(:, j) = c(j)* a(:, j);
a(j, :) = r(j)* a(j, :);
end
end

format short
fprintf('\nScaled Matrix:\n');
disp(a);
```
```

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

```
```function f07at_example
n = 3;
a = [ -1.34 + 2.55i,  2800000000 + 31700000000i,  -6.39 - 2.2i;
-1.7 - 1.41i,  33100000000 - 1500000000i,  -0.15 + 1.34i;
2.41e-10 + 3.9e-11i,  -0.56 + 1.47i,  -8.3e-11 - 6.9e-11i];
thresh = 0.1;
% Compute row and column scaling factors
[r, c, rowcnd, colcnd, amax, info] = f07at(a);

if info > 0
if info <= n
error('Row %d of A is exactly zero', info);
else
error('Column %d of A is exactly zero', info - n);
end
end

% Print ROWCND, COLCND, AMAX and the scale factors
format shorte
fprintf('\nROWCND = %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
for j = 1:n
a(:, j) = c(j)* a(:, j);
end
end
elseif (colcnd>=thresh)
% Just row scale A
for j = 1:n
a(j, :) = r(j)* a(j, :);
end
else
% Row and column scale A
for j = 1:n
a(:, j) = c(j)* a(:, j);
a(j, :) = r(j)* a(j, :);
end
end

format short
fprintf('\nScaled Matrix:\n');
disp(a);
```
```

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

```

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013