NAG Library Routine Document

f08nvf (zgebal)


    1  Purpose
    7  Accuracy


f08nvf (zgebal) balances a complex general matrix in order to improve the accuracy of computed eigenvalues and/or eigenvectors.


Fortran Interface
Subroutine f08nvf ( job, n, a, lda, ilo, ihi, scale, info)
Integer, Intent (In):: n, lda
Integer, Intent (Out):: ilo, ihi, info
Real (Kind=nag_wp), Intent (Out):: scale(n)
Complex (Kind=nag_wp), Intent (Inout):: a(lda,*)
Character (1), Intent (In):: job
C Header Interface
#include nagmk26.h
void  f08nvf_ (const char *job, const Integer *n, Complex a[], const Integer *lda, Integer *ilo, Integer *ihi, double scal[], Integer *info, const Charlen length_job)
The routine may be called by its LAPACK name zgebal.


f08nvf (zgebal) balances a complex general matrix A. The term ‘balancing’ covers two steps, each of which involves a similarity transformation of A. The routine can perform either or both of these steps.
1. The routine first attempts to permute A to block upper triangular form by a similarity transformation:
PAPT = A = A11 A12 A13 0 A22 A23 0 0 A33  
where P is a permutation matrix, and A11 and A33 are upper triangular. Then the diagonal elements of A11 and A33 are eigenvalues of A. The rest of the eigenvalues of A are the eigenvalues of the central diagonal block A22, in rows and columns ilo to ihi. Subsequent operations to compute the eigenvalues of A (or its Schur factorization) need only be applied to these rows and columns; 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 routine sets ilo=1 and ihi=n, and A22 is the whole of A.
2. The routine applies a diagonal similarity transformation to A, to make the rows and columns of A22 as close in norm as possible:
A = DAD-1 = I 0 0 0 D22 0 0 0 I A11 A12 A13 0 A22 A23 0 0 A33 I 0 0 0 D22-1 0 0 0 I .  
This scaling can reduce the norm of the matrix (i.e., A22<A22) and hence reduce the effect of rounding errors on the accuracy of computed eigenvalues and eigenvectors.


Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore


1:     job – Character(1)Input
On entry: indicates whether A is to be permuted and/or scaled (or neither).
A is neither permuted nor scaled (but values are assigned to ilo, ihi and scale).
A is permuted but not scaled.
A is scaled but not permuted.
A is both permuted and scaled.
Constraint: job='N', 'P', 'S' or 'B'.
2:     n – IntegerInput
On entry: n, the order of the matrix A.
Constraint: n0.
3:     alda* – Complex (Kind=nag_wp) arrayInput/Output
Note: the second dimension of the array a must be at least max1,n.
On entry: the n by n matrix A.
On exit: a is overwritten by the balanced matrix. If job='N', a is not referenced.
4:     lda – IntegerInput
On entry: the first dimension of the array a as declared in the (sub)program from which f08nvf (zgebal) is called.
Constraint: ldamax1,n.
5:     ilo – IntegerOutput
6:     ihi – IntegerOutput
On exit: the values ilo and ihi such that on exit aij is zero if i>j and 1j<ilo or ihi<in.
If job='N' or 'S', ilo=1 and ihi=n.
7:     scalen – Real (Kind=nag_wp) arrayOutput
On exit: details of the permutations and scaling factors applied to A. More precisely, if pj is the index of the row and column interchanged with row and column j and dj is the scaling factor used to balance row and column j then
scalej = pj, j=1,2,,ilo-1 dj, j=ilo,ilo+1,,ihi  and pj, j=ihi+1,ihi+2,,n.  
The order in which the interchanges are made is n to ihi+1 then 1 to ilo-1.
8:     info – IntegerOutput
On exit: info=0 unless the routine detects an error (see Section 6).

Error Indicators and Warnings

If info=-i, argument i had an illegal value. An explanatory message is output, and execution of the program is terminated.


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

Parallelism and Performance

f08nvf (zgebal) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

Further Comments

If the matrix A is balanced by f08nvf (zgebal), then any eigenvectors computed subsequently are eigenvectors of the matrix A (see Section 3) and hence f08nwf (zgebak) must then be called to transform them back to eigenvectors of A.
If the Schur vectors of A are required, then this routine must not be called with job='S' or 'B', because then the balancing transformation is not unitary. If this routine is called with job='P', then any Schur vectors computed subsequently are Schur vectors of the matrix A, and f08nwf (zgebak) must be called (with side='R') to transform them back to Schur vectors of A.
The total number of real floating-point operations is approximately proportional to n2.
The real analogue of this routine is f08nhf (dgebal).


This example computes all the eigenvalues and right eigenvectors of the matrix A, where
A = 1.50-2.75i 0.00+0.00i 0.00+0.00i 0.00+0.00i -8.06-1.24i -2.50-0.50i 0.00+0.00i -0.75+0.50i -2.09+7.56i 1.39+3.97i -1.25+0.75i -4.82-5.67i 6.18+9.79i -0.92-0.62i 0.00+0.00i -2.50-0.50i .  
The program first calls f08nvf (zgebal) to balance the matrix; it then computes the Schur factorization of the balanced matrix, by reduction to Hessenberg form and the QR algorithm. Then it calls f08qxf (ztrevc) to compute the right eigenvectors of the balanced matrix, and finally calls f08nwf (zgebak) to transform the eigenvectors back to eigenvectors of the original matrix A.

Program Text

Program Text (f08nvfe.f90)

Program Data

Program Data (f08nvfe.d)

Program Results

Program Results (f08nvfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017