eig_sym
Computes the eigenexpansion of a real symmetric matrix A.
Synopsis
#include <imsl.h>
float *imsl_f_eig_sym (int n, float *a, …, 0)
The type double procedure is imsl_d_eig_sym.
Required Arguments
int n (Input)
Number of rows and columns in the matrix.
float *a (Input)
Array of size n × n containing the symmetric matrix.
Return Value
A pointer to the n eigenvalues of the symmetric matrix. To release this space, use imsl_free. If no value can be computed, then NULL is returned.
Synopsis with Optional Arguments
#include <imsl.h>
float *imsl_f_eig_sym (int n, float *a,
IMSL_VECTORS, float **evec,
IMSL_VECTORS_USER, float evecu[],
IMSL_RETURN_USER, float evalu[],
IMSL_RANGE, float elow, float ehigh,
IMSL_A_COL_DIM, int a_col_dim,
IMSL_EVECU_COL_DIM, int evecu_col_dim,
IMSL_RETURN_NUMBER, int *n_eval,
0)
Optional Arguments
IMSL_VECTORS, float **evec (Output)
The address of a pointer to an array of size n × n containing the eigenvectors of the matrix. On return, the necessary space is allocated by the function. Typically, float *evec is declared, and &evec is used as an argument.
IMSL_VECTORS_USER, float evecu[] (Output)
Compute eigenvectors of the matrix. An array of size n × n containing the orthogonal matrix of eigenvectors is returned in the space evecu.
IMSL_RETURN_USER, float evalu[] (Output)
Store the n eigenvalues in the space evalu.
IMSL_RANGE, float elow, float ehigh (Input)
Return eigenvalues and optionally eigenvectors that lie in the interval with lower limit elow and upper limit ehigh.
Default: (elow, ehigh) = (−∞, +∞)
IMSL_A_COL_DIM, int a_col_dim (Input)
The column dimension of a.
Default: a_col_dim = n
IMSL_EVECU_COL_DIM, int evecu_col_dim (Input)
The column dimension of evecu.
Default: evecu_col_dim = n
IMSL_RETURN_NUMBER, int *n_eval (Output)
The number of output eigenvalues and eigenvectors in the range elow, ehigh.
Description
The function imsl_f_eig_sym 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).
Example 1
#include <imsl.h>
int main()
{
int n = 3;
float a[] = {7.0, -8.0, -8.0,
-8.0, -16.0, -18.0,
-8.0, -18.0, 13.0};
float *eval;
/* Compute eigenvalues */
eval = imsl_f_eig_sym(n, a, 0);
/* Print eigenvalues */
imsl_f_write_matrix ("Eigenvalues", 1, 3, eval, 0);
}
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.
#include <imsl.h>
int main()
{
int n = 3;
float a[] = {7.0, -8.0, -8.0,
-8.0, -16.0, -18.0,
-8.0, -18.0, 13.0};
float *eval;
float *evec;
/* Compute eigenvalues and eigenvectors */
eval = imsl_f_eig_sym(n, a,
IMSL_VECTORS, &evec,
0);
/* Print eigenvalues and eigenvectors */
imsl_f_write_matrix ("Eigenvalues", 1, n, eval, 0);
imsl_f_write_matrix ("Eigenvectors", n, n, evec, 0);
}
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 n_eval contains the number of eigenvalues in the interval. No eigenvalues will be returned. |