eigSym¶
Computes the eigenexpansion of a real symmetric matrix A.
Synopsis¶
eigSym (a)
Required Arguments¶
- float
a[[]]
(Input) - Array of size
n
×n
containing the symmetric matrix.
Return Value¶
The n
eigenvalues of the symmetric matrix. If no value can be computed,
then None
is returned.
Optional Arguments¶
vectors
(Output)- An array of size
n
×n
containing the eigenvectors of the matrix. range
, floatelow
, floatehigh
(Input)Return eigenvalues and optionally eigenvectors that lie in the interval with lower limit
elow
and upper limitehigh
.Default: (
elow
,ehigh
) = (−∞, +∞)returnNumber
(Output)- The number of output eigenvalues and eigenvectors in the range
elow
,ehigh
.
Description¶
The function eigSym
computes the eigenvalues of a symmetric real matrix
by a two-phase process. The matrix is reduced to tridiagonal form by
elementary orthogonal similarity transformations. Then, the eigenvalues are
computed using a rational QR or bisection algorithm. Eigenvectors are
calculated as required (Parlett 1980, pp. 169 - 173).
Examples¶
Example 1¶
from numpy import *
from pyimsl.math.eigSym import eigSym
from pyimsl.math.writeMatrix import writeMatrix
a = [[7., -8., -8.],
[-8., -16., -18.],
[-8., -18., 13.]]
# Compute eigenvalues
eval = eigSym(a)
# Print eigenvalues
writeMatrix("Eigenvalues", eval)
Output¶
Eigenvalues
1 2 3
-27.90 22.68 9.22
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.eigSym import eigSym
from pyimsl.math.writeMatrix import writeMatrix
a = [[7., -8., -8.],
[-8., -16., -18.],
[-8., -18., 13.]]
vectors = []
returnNumber = []
# Compute eigenvalues and eigenvectors
eval = eigSym(a, vectors=vectors, returnNumber=returnNumber)
# Print eigenvalues and eigenvectors
writeMatrix("Eigenvalues", eval)
writeMatrix("Eigenvectors", vectors)
Output¶
Eigenvalues
1 2 3
-27.90 22.68 9.22
Eigenvectors
1 2 3
1 0.2945 -0.2722 0.9161
2 0.8521 -0.3591 -0.3806
3 0.4326 0.8927 0.1262
Warning Errors¶
IMSL_SLOW_CONVERGENCE_SYM |
The iteration for the eigenvalue failed to converge in 100 iterations before deflating. |
IMSL_SLOW_CONVERGENCE_2 |
Inverse iteration did not converge. Eigenvector is not correct for the specified eigenvalue. |
IMSL_LOST_ORTHOGONALITY_2 |
The eigenvectors have lost orthogonality. |
IMSL_NO_EIGENVALUES_RETURNED |
The number of eigenvalues in the
specified interval exceeds
mxeval . The argument
returnNumber contains the
number of eigenvalues in the
interval. No eigenvalues will be
returned. |