hide long namesshow long names
hide short namesshow short names
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_dgeequ (f07af)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_lapack_dgeequ (f07af) computes diagonal scaling matrices DR  and DC  intended to equilibrate a real m  by n  matrix A  and reduce its condition number.

Syntax

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

Description

nag_lapack_dgeequ (f07af) 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 DR  and DC  are restricted to lie in the safe range δ,1/δ , where δ  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.

References

None.

Parameters

Compulsory Input Parameters

1:     alda: – double array
The first dimension of the array a must be at least max1,m.
The second dimension of the array a must be at least max1,n.
The matrix 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, the number of rows of the matrix A.
Constraint: m0.
2:     n int64int32nag_int scalar
Default: the second dimension of the array a.
n, the number of columns of the matrix A.
Constraint: n0.

Output Parameters

1:     rm – double array
If info=0 or info>m, r contains the row scale factors, the diagonal elements of DR. The elements of r will be positive.
2:     cn – double array
If info=0, c contains the column scale factors, the diagonal elements of DC. The elements of c will be positive.
3:     rowcnd – double scalar
If info=0 or info>m, rowcnd contains the ratio of the smallest value of ri to the largest value of ri. If rowcnd0.1 and amax is neither too large nor too small, it is not worth scaling by DR.
4:     colcnd – double scalar
If info=0, colcnd contains the ratio of the smallest value of ci to the largest value of ci.
If colcnd0.1, it is not worth scaling by DC.
5:     amax – double scalar
maxaij. If amax is very close to overflow or underflow, the matrix A should be scaled.
6:     info int64int32nag_int scalar
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.

   info<0
If info=-i, argument i had an illegal value. An explanatory message is output, and execution of the program is terminated.
W  info>0andinfom
Row _ of A is exactly zero.
W  info>m
Column _ of A is exactly zero.

Accuracy

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

Further Comments

The complex analogue of this function is nag_lapack_zgeequ (f07at).

Example

This example equilibrates the general matrix A  given by
A = -1.80×1010 -2.88×1010 -2.05 -8.90×109 -5.25 -2.95 -9.50×10-9 -3.80 -1.58 -2.69 -2.90×10-10 -1.04 -1.11 -0.66 -5.90×10-11 -0.80 .  
Details of the scaling factors, and the scaled matrix are output.
function f07af_example


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

a = [ 1.8e10, 2.88e10, 2.05,    -8.9e09;
      5.25,  -2.95,   -9.5e-09, -3.8;
      1.58,  -2.69,   -2.9e-10, -1.04;
     -1.11,  -0.66,   -5.9e-11,  0.8];

% Compute row and column scaling factors
thresh = 0.1;
[r, c, rowcnd, colcnd, amax, info] = ...
  f07af(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);


f07af example results

rowcnd =  3.9e-11 colcnd =  1.8e-09 amax =  2.9e+10

Row scale factors:
   3.4722e-11   1.9048e-01   3.7175e-01   9.0090e-01

Column scale factors:
   1.0000e+00   1.0000e+00   5.5263e+08   1.3816e+00

Scaled Matrix:
    0.6250    1.0000    0.0393   -0.4269
    1.0000   -0.5619   -1.0000   -1.0000
    0.5874   -1.0000   -0.0596   -0.5341
   -1.0000   -0.5946   -0.0294    0.9957


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–2015