CNLMath : Eigensystem Analysis : eig_gen (complex)
eig_gen (complex)

   more...
Computes the eigenexpansion of a complex matrix A.
Synopsis
#include <imsl.h>
f_complex *imsl_c_eig_gen (int n, f_complex *a, , 0)
The type d_complex procedure is imsl_z_eig_gen.
Required Arguments
int n (Input)
Number of rows and columns in the matrix.
f_complex *a (Input)
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_c_eig_gen (int n, f_complex *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 *evecu is declared, and &evecu is used as an argument.
IMSL_VECTORS_USER, f_complex evecu[] (Output)
Compute eigenvectors of the matrix. An array of size n × n containing the matrix of eigenvectors is returned in the space evecu.
IMSL_RETURN_USER, f_complex evalu[] (Output)
Store the n eigenvalues 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
The function imsl_c_eig_gen computes the eigenvalues of a complex matrix by a two-phase process. The matrix is reduced to upper Hessenberg form by elementary Gauss transformations. Then, the eigenvalues are computed using an explicitly shifted LR algorithm. Eigenvectors are calculated during the iterations for the eigenvalues (Martin and Wilkinson 1971).
Examples
Example 1
 
#include <imsl.h>
 
int main()
{
int n = 4;
f_complex a[] = { {5,9}, {5,5}, {-6,-6}, {-7,-7},
{3,3}, {6,10}, {-5,-5}, {-6,-6},
{2,2}, {3,3}, {-1, 3}, {-5,-5},
{1,1}, {2,2}, {-3,-3}, { 0, 4} };
f_complex *eval;
/* Compute eigenvalues */
eval = imsl_c_eig_gen (n, a, 0);
/* Print eigenvalues */
imsl_c_write_matrix ("Eigenvalues", 1, n, eval, 0);
}
Output
 
Eigenvalues
1 2 3
( 4, 8) ( 3, 7) ( 2, 6)
 
4
( 1, 5)
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 = 4;
f_complex a[] = { {5,9}, {5,5}, {-6,-6}, {-7,-7},
{3,3}, {6,10}, {-5,-5}, {-6,-6},
{2,2}, {3,3}, {-1, 3}, {-5,-5},
{1,1}, {2,2}, {-3,-3}, { 0, 4} };
f_complex *eval;
f_complex *evec;
/* Compute eigenvalues and eigenvectors */
eval = imsl_c_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
( 4, 8) ( 3, 7) ( 2, 6)
 
4
( 1, 5)
 
Eigenvectors
1 2 3
1 ( 0.5773, -0.0000) ( 0.5774 0.0000) ( 0.3780, -0.0000)
2 ( 0.5773, -0.0000) ( 0.5773, -0.0000) ( 0.7559, 0.0000)
3 ( 0.5774, 0.0000) ( -0.0000, -0.0000) ( 0.3780, 0.0000)
4 ( -0.0000, -0.0000) ( 0.5774, 0.0000) ( 0.3780, -0.0000)
 
4
1 ( 0.7559, 0.0000)
2 ( 0.3780, 0.0000)
3 ( 0.3780, 0.0000)
4 ( 0.3780, 0.0000)
Fatal Errors
IMSL_SLOW_CONVERGENCE_GEN
The iteration for an eigenvalue did not converge after # iterations.