NAG Library Function Document
nag_dgebal (f08nhc)
1 Purpose
nag_dgebal (f08nhc) balances a real general matrix in order to improve the accuracy of computed eigenvalues and/or eigenvectors.
2 Specification
#include <nag.h> |
#include <nagf08.h> |
void |
nag_dgebal (Nag_OrderType order,
Nag_JobType job,
Integer n,
double a[],
Integer pda,
Integer *ilo,
Integer *ihi,
double scale[],
NagError *fail) |
|
3 Description
nag_dgebal (f08nhc) balances a real 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. |
4 References
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
5 Arguments
- 1:
– Nag_OrderTypeInput
-
On entry: the
order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by
. See
Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint:
or .
- 2:
– Nag_JobTypeInput
-
On entry: 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 .
- 3:
– IntegerInput
-
On entry: , the order of the matrix .
Constraint:
.
- 4:
– doubleInput/Output
-
Note: the dimension,
dim, of the array
a
must be at least
.
Where
appears in this document, it refers to the array element
- when ;
- when .
On entry: the by matrix .
On exit:
a is overwritten by the balanced matrix. If
,
a is not referenced.
- 5:
– IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
a.
Constraint:
.
- 6:
– Integer *Output
- 7:
– Integer *Output
-
On exit: the values
and
such that on exit
is zero if
and
or
.
If or , and .
- 8:
– doubleOutput
-
On exit: 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
.
- 9:
– NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
6 Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 3.2.1.2 in the Essential Introduction for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_INT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INT_2
-
On entry, and .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
An unexpected error has been triggered by this function. Please contact
NAG.
See
Section 3.6.6 in the Essential Introduction for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 3.6.5 in the Essential Introduction for further information.
7 Accuracy
The errors are negligible.
8 Parallelism and Performance
nag_dgebal (f08nhc) is not threaded by NAG in any implementation.
nag_dgebal (f08nhc) 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 function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
If the matrix
is balanced by nag_dgebal (f08nhc), then any eigenvectors computed subsequently are eigenvectors of the matrix
(see
Section 3) and hence
nag_dgebak (f08njc)
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 orthogonal. If this function is called with
, then any Schur vectors computed subsequently are Schur vectors of the matrix
, and
nag_dgebak (f08njc) 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 function is
nag_zgebal (f08nvc).
10 Example
This example computes all the eigenvalues and right eigenvectors of the matrix
, where
The program first calls nag_dgebal (f08nhc) 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_dtrevc (f08qkc) to compute the right eigenvectors of the balanced matrix, and finally calls
nag_dgebak (f08njc) to transform the eigenvectors back to eigenvectors of the original matrix
.
10.1 Program Text
Program Text (f08nhce.c)
10.2 Program Data
Program Data (f08nhce.d)
10.3 Program Results
Program Results (f08nhce.r)