eigGen¶
Computes the eigenexpansion of a real matrix A.
Synopsis¶
eigGen (a)
Required Arguments¶
- float
a[[]]
(Input) - An array of size
n
×n
containing the matrix.
Return Value¶
The n
complex eigenvalues of the matrix. If no value can be computed,
then None
is returned.
Optional Arguments¶
vectors
(Output)- An array of size
n
×n
containing eigenvectors of the matrix.
Description¶
Function eigGen
computes the eigenvalues of a real matrix by a two-phase
process. The matrix is reduced to upper Hessenberg form by elementary
orthogonal or Gauss similarity transformations. Then, eigenvalues are
computed using a QR or combined LR-QR algorithm (Golub and Van Loan
1989, pp. 373 - 382, and Watkins and Elsner 1990). The combined LR-QR
algorithm is based on an implementation by Jeff Haag and David Watkins.
Eigenvectors are then calculated as required. When eigenvectors are
computed, the QR algorithm is used to compute the eigenexpansion. When
only eigenvalues are required, the combined LR-QR algorithm is used.
Examples¶
Example 1¶
from numpy import *
from pyimsl.math.eigGen import eigGen
from pyimsl.math.writeMatrixComplex import writeMatrixComplex
a = [[8., -1., -5.],
[-4., 4., -2.],
[18., -5., -7.]]
# Compute eigenvalues of A
eval = eigGen(a)
# Print eigenvalues
writeMatrixComplex("Eigenvalues", eval)
Output¶
Eigenvalues
1 2
( 2, 4) ( 2, -4)
3
( 1, 0)
Example 2¶
This example is a variation of the first example. Here, the eigenvectors are computed as well as the eigenvalues.
from numpy import *
from pyimsl.math.eigGen import eigGen
from pyimsl.math.writeMatrixComplex import writeMatrixComplex
a = [[8., -1., -5.],
[-4., 4., -2.],
[18., -5., -7.]]
evec = []
# Compute eigenvalues of A
eval = eigGen(a, vectors=evec)
# Print eigenvalues and eigenvectors
writeMatrixComplex("Eigenvalues", eval)
writeMatrixComplex("Eigenvectors", evec)
Output¶
Eigenvalues
1 2
( 2, 4) ( 2, -4)
3
( 1, 0)
Eigenvectors
1 2
1 ( 0.3162, -0.3162) ( 0.3162, 0.3162)
2 ( 0.6325, 0.0000) ( 0.6325, 0.0000)
3 ( 0.0000, -0.6325) ( 0.0000, 0.6325)
3
1 ( 0.4082, 0.0000)
2 ( 0.8165, 0.0000)
3 ( 0.4082, 0.0000)
Warning Errors¶
IMSL_SLOW_CONVERGENCE_GEN |
The iteration for an eigenvalue did not converge after # iterations. |