PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_lapack_zgebal (f08nv)
Purpose
nag_lapack_zgebal (f08nv) balances a complex general matrix in order to improve the accuracy of computed eigenvalues and/or eigenvectors.
Syntax
Description
nag_lapack_zgebal (f08nv) balances a complex general matrix
. The term ‘balancing’ covers two steps, each of which involves a similarity transformation of
. The function can perform either or both of these steps.
1. |
The function 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 function sets and , and is the whole of . |
2. |
The function 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. |
References
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Parameters
Compulsory Input Parameters
- 1:
– string (length ≥ 1)
-
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.
Constraint:
, , or .
- 2:
– complex array
-
The first dimension of the array
a must be at least
.
The second dimension of the array
a must be at least
.
The by matrix .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
a and the second dimension of the array
a.
, the order of the matrix .
Constraint:
.
Output Parameters
- 1:
– complex array
-
The first dimension of the array
a will be
.
The second dimension of the array
a will be
.
a stores the balanced matrix. If
,
a is not referenced.
- 2:
– int64int32nag_int scalar
- 3:
– int64int32nag_int scalar
-
The values
and
such that on exit
is zero if
and
or
.
If or , and .
- 4:
– double array
-
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
and
is the scaling factor used to balance row and column
then
The order in which the interchanges are made is
to
then
to
.
- 5:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
-
If , parameter had an illegal value on entry. The parameters are numbered as follows:
1:
job, 2:
n, 3:
a, 4:
lda, 5:
ilo, 6:
ihi, 7:
scale, 8:
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 with those in subsequent computations.
Further Comments
If the matrix
is balanced by
nag_lapack_zgebal (f08nv), then any eigenvectors computed subsequently are eigenvectors of the matrix
(see
Description) and hence
nag_lapack_zgebak (f08nw)
must then be called to transform them back to eigenvectors of
.
If the Schur vectors of
are required, then this function must
not be called with
or
, because then the balancing transformation is not unitary. If this function is called with
, then any Schur vectors computed subsequently are Schur vectors of the matrix
, and
nag_lapack_zgebak (f08nw) must be called (with
)
to transform them back to Schur vectors of
.
The total number of real floating-point operations is approximately proportional to .
The real analogue of this function is
nag_lapack_dgebal (f08nh).
Example
This example computes all the eigenvalues and right eigenvectors of the matrix
, where
The program first calls
nag_lapack_zgebal (f08nv) 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
nag_lapack_ztrevc (f08qx) to compute the right eigenvectors of the balanced matrix, and finally calls
nag_lapack_zgebak (f08nw) to transform the eigenvectors back to eigenvectors of the original matrix
.
Open in the MATLAB editor:
f08nv_example
function f08nv_example
fprintf('f08nv example results\n\n');
n = int64(4);
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];
job = 'Both';
[a, ilo, ihi, scale, info] = f08nv(job, a);
[H, tau, info] = f08ns(ilo, ihi, a);
[Q, info] = f08nt(ilo, ihi, H, tau);
[H, w, Z, info] = f08ps( ...
'Schur Form', 'Vectors', ilo, ihi, H, Q);
disp('Eigenvalues:');
disp(w);
[select, ~, VR, m, info] = ...
f08qx( ...
'Right', 'Backtransform', false, H, complex(zeros(1)), Z, n);
[VR, info] = f08nw( ...
'Both', 'Right', ilo, ihi, scale, VR);
for i = 1:n
[~,k] = max(abs(real(VR(:,i)))+abs(imag(VR(:,i))));
VR(:,i) = VR(:,i)*conj(VR(k,i))/abs(VR(k,i))/norm(VR(:,i));
end
disp('Eigenvectors:');
disp(VR);
f08nv example results
Eigenvalues:
-1.2500 + 0.7500i
-1.5000 - 0.4975i
-3.5000 - 0.5025i
1.5000 - 2.7500i
Eigenvectors:
0.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i 0.1418 - 0.0407i
0.0000 + 0.0000i -0.1015 + 0.0009i 0.1756 - 0.4131i -0.2711 - 0.1812i
1.0000 + 0.0000i 0.9884 + 0.0000i 0.7420 + 0.0000i 0.8213 + 0.0000i
0.0000 + 0.0000i 0.0941 + 0.0619i 0.4170 - 0.2722i 0.1110 + 0.4303i
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015