NAG Library Routine Document
F08NHF (DGEBAL) balances a real general matrix in order to improve the accuracy of computed eigenvalues and/or eigenvectors.
||N, LDA, ILO, IHI, INFO
The routine may be called by its
F08NHF (DGEBAL) balances a real general matrix
. The term ‘balancing’ covers two steps, each of which involves a similarity transformation of
. The routine can perform either or both of these steps.
- The routine first attempts to permute to block upper triangular form by a similarity transformation:
where is a permutation matrix, and and are upper triangular. Then the diagonal elements of and are eigenvalues of . The rest of the eigenvalues of are the eigenvalues of the central diagonal block , in rows and columns to . Subsequent operations to compute the eigenvalues of (or its Schur factorization) need only be applied to these rows and columns; this can save a significant amount of work if and . If no suitable permutation exists (as is often the case), the routine sets and , and is the whole of .
- The routine applies a diagonal similarity transformation to , to make the rows and columns of as close in norm as possible:
This scaling can reduce the norm of the matrix (i.e., ) 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
: indicates whether
is to be permuted and/or scaled (or neither).
- is neither permuted nor scaled (but values are assigned to ILO, IHI and SCALE).
- is permuted but not scaled.
- is scaled but not permuted.
- is both permuted and scaled.
, , or .
- 2: N – INTEGERInput
On entry: , the order of the matrix .
- 3: A(LDA,) – REAL (KIND=nag_wp) arrayInput/Output
the second dimension of the array A
must be at least
On entry: the by matrix .
is overwritten by the balanced matrix. If
is not referenced.
- 4: LDA – INTEGERInput
: the first dimension of the array A
as declared in the (sub)program from which F08NHF (DGEBAL) is called.
- 5: ILO – INTEGEROutput
- 6: IHI – INTEGEROutput
: the values
such that on exit
is zero if
If or , and .
- 7: SCALE(N) – REAL (KIND=nag_wp) arrayOutput
: details of the permutations and scaling factors applied to
. More precisely, if
is the index of the row and column interchanged with row and column
is the scaling factor used to balance row and column
The order in which the interchanges are made is
- 8: INFO – INTEGEROutput
unless the routine detects an error (see Section 6
6 Error Indicators and Warnings
Errors or warnings detected by the routine:
If , argument had an illegal value. An explanatory message is output, and execution of the program is terminated.
The errors are negligible.
If the matrix
is balanced by F08NHF (DGEBAL), then any eigenvectors computed subsequently are eigenvectors of the matrix
(see Section 3
) and hence F08NJF (DGEBAK)
then be called to transform them back to eigenvectors of
If the Schur vectors of
are required, then this routine must not
be called with
, because then the balancing transformation is not orthogonal. If this routine is called with
, then any Schur vectors computed subsequently are Schur vectors of the matrix
, and F08NJF (DGEBAK) must
be called (with
to transform them back to Schur vectors of
The total number of floating point operations is approximately proportional to .
The complex analogue of this routine is F08NVF (ZGEBAL)
This example computes all the eigenvalues and right eigenvectors of the matrix
The program first calls F08NHF (DGEBAL) to balance the matrix; it then computes the Schur factorization of the balanced matrix, by reduction to Hessenberg form and the
algorithm. Then it calls F08QKF (DTREVC)
to compute the right eigenvectors of the balanced matrix, and finally calls F08NJF (DGEBAK)
to transform the eigenvectors back to eigenvectors of the original matrix
9.1 Program Text
Program Text (f08nhfe.f90)
9.2 Program Data
Program Data (f08nhfe.d)
9.3 Program Results
Program Results (f08nhfe.r)