Eigenvalues and Eigenvectors



Eigenvalues and Eigenvectors of a General Square Matrix

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 = Ax0 and sets µ = xTx0. The process is then repeated after setting
    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, x0, and an initial estimate of the eigenvalue, µ = *eigenvalue, the method then normalizes x0, calculates
    µx0T(A - µ I) x0 and solves ( A - µI ) x = x0 for x. The process is then repeated after setting 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, -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 ith eigenvalue being stored in eigen_real[i] and the imaginary part of the ith eigenvalue being stored in 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 ith column being the eigenvector corresponding to the ith eigenvalue if that eigenvalue is real, eigen_real[i] and eigen_imag[i] = 0 and the ith column being the real part of the eigenvector and the i+1st column being the imaginary part of the eigenvector if that eigenvalue is complex with positive imaginary part, 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