eig_gen

   more...
Computes the eigenexpansion of a real matrix A.
Synopsis
#include <imsl.h>
f_complex *imsl_f_eig_gen (int n, float *a, …, 0)
The type d_complex function is imsl_d_eig_gen.
Required Arguments
int n (Input)
Number of rows and columns in the matrix.
float *a (Input)
An array of size n × n containing the matrix.
Return Value
A pointer to the n complex eigenvalues of the 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>
f_complex *imsl_f_eig_gen (int n, float *a,
IMSL_VECTORS, f_complex **evec,
IMSL_VECTORS_USER, f_complex evecu[],
IMSL_RETURN_USER, f_complex evalu[],
IMSL_A_COL_DIM, int a_col_dim,
IMSL_EVECU_COL_DIM, int evecu_col_dim,
0)
Optional Arguments
IMSL_VECTORS, f_complex **evec (Output)
The address of a pointer to an array of size n × n containing eigenvectors of the matrix. On return, the necessary space is allocated by the function. Typically, f_complex *evec is declared, and &evec is used as an argument.
IMSL_VECTORS_USER, f_complex evecu[] (Output)
Compute eigenvectors of the matrix. An array of size n × ncontaining the matrix of eigenvectors is returned in the space evecu.
IMSL_RETURN_USER, f_complex evalu[] (Output)
Store the neigenvalues in the space evalu.
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
Description
Function imsl_f_eig_gen 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
 
#include <imsl.h>
 
int main()
{
int n = 3;
float a[] = {8.0, -1.0, -5.0,
-4.0, 4.0, -2.0,
18.0, -5.0, -7.0};
f_complex *eval;
/* Compute eigenvalues of A */
eval = imsl_f_eig_gen (n, a, 0);
/* Print eigenvalues */
imsl_c_write_matrix ("Eigenvalues", 1, n, eval, 0);
}
Output
 
Eigenvalues
1 2 3
( 2, 4) ( 2, -4) ( 1, 0)
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[] = {8.0, -1.0, -5.0,
-4.0, 4.0, -2.0,
18.0, -5.0, -7.0};
f_complex *eval;
f_complex *evec;
/* Compute eigenvalues of A */
eval = imsl_f_eig_gen (n, a,
IMSL_VECTORS, &evec,
0);
/* Print eigenvalues and eigenvectors */
imsl_c_write_matrix ("Eigenvalues", 1, n, eval, 0);
imsl_c_write_matrix ("Eigenvectors", n, n, evec, 0);
}
Output
 
Eigenvalues
1 2 3
( 2, 4) ( 2, -4) ( 1, 0)
 
Eigenvectors
1 2 3
1 ( 0.3162, 0.3162) ( 0.3162, -0.3162) ( 0.4082, 0.0000)
2 ( 0.0000, 0.6325) ( 0.0000, -0.6325) ( 0.8165, 0.0000)
3 ( 0.6325, 0.0000) ( 0.6325, 0.0000) ( 0.4082, 0.0000)
Warning Errors
IMSL_SLOW_CONVERGENCE_GEN
The iteration for an eigenvalue did not converge after # iterations.