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_dggbal (f08wh)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_lapack_dggbal (f08wh) balances a pair of real square matrices A,B of order n. Balancing usually improves the accuracy of computed generalized eigenvalues and eigenvectors.

Syntax

[a, b, ilo, ihi, lscale, rscale, info] = f08wh(job, a, b, 'n', n)
[a, b, ilo, ihi, lscale, rscale, info] = nag_lapack_dggbal(job, a, b, 'n', n)

Description

Balancing may reduce the 1-norms of the matrices and improve the accuracy of the computed eigenvalues and eigenvectors in the real generalized eigenvalue problem
Ax=λBx.  
nag_lapack_dggbal (f08wh) is usually the first step in the solution of the above generalized eigenvalue problem. Balancing is optional but it is highly recommended.
The term ‘balancing’ covers two steps, each of which involves similarity transformations on A and B. The function can perform either or both of these steps. Both steps are optional.
1. The function first attempts to permute A and B to block upper triangular form by a similarity transformation:
PAPT=F= F11 F12 F13 F22 F23 F33  
PBPT=G= G11 G12 G13 G22 G23 G33  
where P is a permutation matrix, F11, F33, G11 and G33 are upper triangular. Then the diagonal elements of the matrix pairs F11,G11 and F33,G33 are generalized eigenvalues of A,B. The rest of the generalized eigenvalues are given by the matrix pair F22,G22 which are in rows and columns ilo to ihi. Subsequent operations to compute the generalized eigenvalues of A,B need only be applied to the matrix pair F22,G22; this can save a significant amount of work if ilo>1 and ihi<n. If no suitable permutation exists (as is often the case), the function sets ilo=1 and ihi=n.
2. The function applies a diagonal similarity transformation to F,G, to make the rows and columns of F22,G22 as close in norm as possible:
DFD^= I 0 0 0 D22 0 0 0 I F11 F12 F13 F22 F23 F33 I 0 0 0 D^22 0 0 0 I  
DGD^= I 0 0 0 D22 0 0 0 I G11 G12 G13 G22 G23 G33 I 0 0 0 D^22 0 0 0 I  
This transformation usually improves the accuracy of computed generalized eigenvalues and eigenvectors.

References

Ward R C (1981) Balancing the generalized eigenvalue problem SIAM J. Sci. Stat. Comp. 2 141–152

Parameters

Compulsory Input Parameters

1:     job – string (length ≥ 1)
Specifies the operations to be performed on matrices A and B.
job='N'
No balancing is done. Initialize ilo=1, ihi=n, lscalei=1.0 and rscalei=1.0, for i=1,2,,n.
job='P'
Only permutations are used in balancing.
job='S'
Only scalings are are used in balancing.
job='B'
Both permutations and scalings are used in balancing.
Constraint: job='N', 'P', 'S' or 'B'.
2:     alda: – double array
The first dimension of the array a must be at least max1,n.
The second dimension of the array a must be at least max1,n.
The n by n matrix A.
3:     bldb: – double array
The first dimension of the array b must be at least max1,n.
The second dimension of the array b must be at least max1,n.
The n by n matrix B.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the first dimension of the arrays a, b and the second dimension of the arrays a, b.
n, the order of the matrices A and B.
Constraint: n0.

Output Parameters

1:     alda: – double array
The first dimension of the array a will be max1,n.
The second dimension of the array a will be max1,n.
a stores the balanced matrix. If job='N', a is not referenced.
2:     bldb: – double array
The first dimension of the array b will be max1,n.
The second dimension of the array b will be max1,n.
b stores the balanced matrix. If job='N', b is not referenced.
3:     ilo int64int32nag_int scalar
4:     ihi int64int32nag_int scalar
ilo and ihi are set such that aij=0 and bij=0 if i>j and 1j<ilo or ihi<in.
If job='N' or 'S', ilo=1 and ihi=n.
5:     lscalen – double array
Details of the permutations and scaling factors applied to the left side of the matrices A and B. If Pi is the index of the row interchanged with row i and di is the scaling factor applied to row i, then
  • lscalei=Pi, for i=1,2,,ilo-1;
  • lscalei=di, for i=ilo,,ihi;
  • lscalei=Pi, for i=ihi+1,,n.
The order in which the interchanges are made is n to ihi+1, then 1 to ilo-1.
6:     rscalen – double array
Details of the permutations and scaling factors applied to the right side of the matrices A and B.
If Pj is the index of the column interchanged with column j and d^j is the scaling factor applied to column j, then
  • rscalej=Pj, for j=1,2,,ilo-1;
  • rscalej=d^j, for j=ilo,,ihi;
  • rscalej=Pj, for j=ihi+1,,n.
The order in which the interchanges are made is n to ihi+1, then 1 to ilo-1.
7:     info int64int32nag_int scalar
info=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

   info=-i
If info=-i, parameter i had an illegal value on entry. The parameters are numbered as follows:
1: job, 2: n, 3: a, 4: lda, 5: b, 6: ldb, 7: ilo, 8: ihi, 9: lscale, 10: rscale, 11: work, 12: 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.

Accuracy

The errors are negligible, compared to those in subsequent computations.

Further Comments

nag_lapack_dggbal (f08wh) is usually the first step in computing the real generalized eigenvalue problem but it is an optional step. The matrix B is reduced to the upper triangular form using the QR factorization function nag_lapack_dgeqrf (f08ae) and this orthogonal transformation Q is applied to the matrix A by calling nag_lapack_dormqr (f08ag). This is followed by nag_lapack_dgghrd (f08we) which reduces the matrix pair into the generalized Hessenberg form.
If the matrix pair A,B is balanced by this function, then any generalized eigenvectors computed subsequently are eigenvectors of the balanced matrix pair. In that case, to compute the generalized eigenvectors of the original matrix, nag_lapack_dggbak (f08wj) must be called.
The total number of floating-point operations is approximately proportional to n2.
The complex analogue of this function is nag_lapack_zggbal (f08wv).

Example

See Example in nag_lapack_dhgeqz (f08xe) and nag_lapack_dtgevc (f08yk).
function f08wh_example


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

a = [1,  1,   1,    1,    1;
     2,  4,   8,   16,   32;
     3,  9,  27,   81,  243;
     4, 16,  64,  256, 1024;
     5, 25, 125,  625, 3125];
b = [1,  2,   3,    4,    5;
     1,  4,   9,   16,   25;
     1,  8,  27,   64,  125;
     1, 16,  81,  256,  625;
     1, 32, 243, 1024, 3125];

% Balance matrix pair (A,B)
job = 'Balance';
[a, b, ilo, ihi, lscale, rscale, info] = ...
  f08wh(job, a, b);

fprintf('Lower index for permuted central block matrix pair = %d\n', ilo);
fprintf('Upper index for permuted central block matrix pair = %d\n', ihi);
disp('Contents of left scaling vector:');
disp(lscale');
disp('Contents of right scaling vector:');
disp(rscale');
disp('Balanced matrix A');
disp(a);
disp('Balanced matrix B');
disp(b);




f08wh example results

Lower index for permuted central block matrix pair = 1
Upper index for permuted central block matrix pair = 5
Contents of left scaling vector:
    1.0000    1.0000    0.1000    0.1000    0.1000

Contents of right scaling vector:
    1.0000    1.0000    0.1000    0.1000    0.1000

Balanced matrix A
    1.0000    1.0000    0.1000    0.1000    0.1000
    2.0000    4.0000    0.8000    1.6000    3.2000
    0.3000    0.9000    0.2700    0.8100    2.4300
    0.4000    1.6000    0.6400    2.5600   10.2400
    0.5000    2.5000    1.2500    6.2500   31.2500

Balanced matrix B
    1.0000    2.0000    0.3000    0.4000    0.5000
    1.0000    4.0000    0.9000    1.6000    2.5000
    0.1000    0.8000    0.2700    0.6400    1.2500
    0.1000    1.6000    0.8100    2.5600    6.2500
    0.1000    3.2000    2.4300   10.2400   31.2500


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