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)

Purpose

nag_lapack_dgeequ (f07af) computes diagonal scaling matrices DR DR  and DC DC  intended to equilibrate a real m m  by n n  matrix A 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 B  given by
B = DRADC
B=DRADC
have absolute value 11. The diagonal elements of DR DR  and DC DC  are restricted to lie in the safe range (δ,1 / δ) (δ,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 A  but works well in practice.

References

None.

Parameters

Compulsory Input Parameters

1:     a(lda, : :) – double array
The first dimension of the array a must be at least max (1,m)max(1,m)
The second dimension of the array must be at least max (1,n)max(1,n)
The matrix AA whose scaling factors are to be computed.

Optional Input Parameters

1:     m – int64int32nag_int scalar
Default: The first dimension of the array a.
mm, the number of rows of the matrix AA.
Constraint: m0m0.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array a.
nn, the number of columns of the matrix AA.
Constraint: n0n0.

Input Parameters Omitted from the MATLAB Interface

lda

Output Parameters

1:     r(m) – double array
If INFO = 0INFO=0 or INFO > mINFO>m, r contains the row scale factors, the diagonal elements of DRDR. The elements of r will be positive.
2:     c(n) – double array
If INFO = 0INFO=0, c contains the column scale factors, the diagonal elements of DCDC. The elements of c will be positive.
3:     rowcnd – double scalar
If INFO = 0INFO=0 or INFO > mINFO>m, rowcnd contains the ratio of the smallest value of r(i)ri to the largest value of r(i)ri. If rowcnd0.1rowcnd0.1 and amax is neither too large nor too small, it is not worth scaling by DRDR.
4:     colcnd – double scalar
If INFO = 0INFO=0, colcnd contains the ratio of the smallest value of c(i)ci to the largest value of c(i)ci.
If colcnd0.1colcnd0.1, it is not worth scaling by DCDC.
5:     amax – double scalar
max|aij|max|aij|. If amax is very close to overflow or underflow, the matrix AA should be scaled.
6:     info – int64int32nag_int scalar
info = 0info=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 = iinfo=-i
If info = iinfo=-i, parameter ii 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 > 0andINFOMINFO>0andINFOM
If info = iinfo=i, the iith row of AA is exactly zero.
W INFO > MINFO>M
If info = iinfo=i, the (im)(i-m)th column of AA 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

function nag_lapack_dgeequ_example
n = 4;
a = [18000000000, 28800000000, 2.05, -8900000000;
     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];
thresh = 0.1;


% Compute row and column scaling factors
[r, c, rowcnd, colcnd, amax, info] = nag_lapack_dgeequ(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 =  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


function f07af_example
n = 4;
a = [18000000000, 28800000000, 2.05, -8900000000;
     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];
thresh = 0.1;


% Compute row and column scaling factors
[r, c, rowcnd, colcnd, amax, info] = f07af(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 =  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–2013