## General Square Matrices

For a real square matrix the eigenvalues are not necessarily real. If it is known that the dominant eigenvalue is real and unique, then the power method can be used to estimate it. In general, the matrix can be reduced to a similar upper Hessenberg matrix, and then the routine QR_Hessenberg_Matrix to calculate all the eigenvalues, real and complex, and the corresponding eigenvectors.### Function List

- int Eigenvalue_Power_Method( double *A, int n, double *eigenvalue, double x[ ], double x0[ ], double tolerance, int max_tries )

The power method can be used for estimating the dominant eigenvalue of a real square matrix, providing that the eigenvalue is real. The process may not converge if the dominant eigenvalue is not unique. If the dominant eigenvalue is complex, then for a real matrix the complex conjugate is also an eigenvalue. Given the*n×n*real matrix**A**and an initial estimate of the eigenvector,*x0*, the method then normalizes*x0*, calculates*x*=**A***x0*and sets*µ*=*x*. The process is then repeated after setting^{T}x0

*x0*=*x*until the relative absolute change in*µ*is less than the preassigned*tolerance*at which time the process terminates successfully or until the number of attempts exceeds*max_tries*at which time the process terminates unsuccessfully.

The function returns the number of iterations performed if successful and -1 if more than max_tries iterations are necessary, -2 if the initial vector or subsequent vector is 0 and -3 if the estimate for the dominant eigenvalue is 0.

- int Eigenvalue_Inverse_Power_Method( double *A, int n, double *eigenvalue, double x0[ ], double tolerance, int max_tries )

The inverse power method can be used for estimating the eigenvalue of a matrix nearest a preassigned target providing that the eigenvalue is real. Given the*n×n*real matrix**A**, an initial estimate of the eigenvector,*x*, and an initial estimate of the eigenvalue, µ =_{0}**eigenvalue*, the method then normalizes*x*, calculates_{0}*µ*←*x*(_{0}^{T}**A**- µ**I**)*x*and solves (_{0}**A**-*µ***I**)*x*=*x*for_{0}*x*. The process is then repeated after setting*x*=_{0}*x*until the relative absolute change in*µ*is less than the preassigned*tolerance*at which time the process terminates successfully or until the number of attempts exceeds*max_tries*at which time the process terminates unsuccessfully.

The function returns the number of iterations performed if successful and -1 if more than max_tries iterations are necessary, -2 if the initial vector or subsequent vector is 0, -3 if the estimate for the dominant eigenvalue is 0 and -4 if there is not enough memory available for working storage.

- int QR_Hessenberg_Matrix( double* H, double *S, double eigen_real, double eigen_imag, int n, int max_iteration_count )

Given the*n×n*real upper Hessenberg matrix**H**, the routine QR_Hessenberg_Matrix uses Francis's double QR algorithm with implicit shifts of the origin to estimate the eigenvalues and eigenvectors. The eigenvalues are returned in the arrays*eigen_real*and*eigen_imag*with the real part of the*i*eigenvalue being stored in^{th}*eigen_real[i]*and the imaginary part of the*i*eigenvalue being stored in^{th}*eigen_imag[i]*. The*n×n*matrix**S**should be set to the transformation matrix if the original matrix was reduced to upper Hessenberg form or set to the identity matrix if the original matrix is upper Hessenberg. Upon return,**S**contains the eigenvectors of the original matrix, the*i*column being the eigenvector corresponding to the^{th}*i*eigenvalue if that eigenvalue is real,^{th}*eigen_real[i]*and*eigen_imag[i]*= 0 and the*i*column being the real part of the eigenvector and the^{th}*i+1*column being the imaginary part of the eigenvector if that eigenvalue is complex with positive imaginary part,^{st}*eigen_real[i]*and*eigen_imag[i]*> 0. The eigenvector corresponding to the eigenvalue with negative imaginary part is the complex conjugate of the eigenvector corresponding to the complex conjugate of the eigenvalue. The function returns a 0 if successful and a -1 if the process failed to converge within*max_iteration_count*iterations.

*C* Source Code

- The file, eigen_power_method.c, contains the routine Eigenvalue_Power_Method( ).

- The file, inverse_power_method.c, contains the routine Eigenvalue_Inverse_Power_Method( ).

- The file, qr_hessenberg_matrix.c, contains the routine QR_Hessenberg_Matrix( ).