00001 #ifndef vnl_complex_eigensystem_h_ 00002 #define vnl_complex_eigensystem_h_ 00003 //: 00004 // \file 00005 // \brief Calculates eigenvalues and eigenvectors of a square complex matrix 00006 // \author fsm 00007 // 00008 // \verbatim 00009 // Modifications 00010 // dac (Manchester) 26/03/2001: tidied up documentation 00011 // \endverbatim 00012 00013 #include <vcl_complex.h> 00014 #include <vnl/vnl_vector.h> 00015 #include <vnl/vnl_matrix.h> 00016 00017 //: Calculates eigenvalues and eigenvectors of a square complex matrix 00018 // 00019 // Class to compute and hold the eigenvalues and (optionally) eigenvectors 00020 // of a square complex matrix, using the LAPACK routine zgeev. 00021 // 00022 // Default behaviour is to compute the eigenvalues and the right 00023 // eigenvectors. 00024 // 00025 // The input NxN matrix A is passed into the constructor. The flags 00026 // right,left request the calculation of right and left eigenvectors 00027 // respectively. The compute eigenvalues are stored in the member 'W'. 00028 // 00029 // Computed right eigenvectors are stored in the **ROWS** of the 00030 // member 'R' and computed left eigenvectors are stored in the **ROWS** 00031 // of the member 'L'. When eigenvectors are not requested, the 00032 // corresponding matrices L and R will be empty. 00033 // 00034 // The ith right eigenvector v satisfies A*v = W[i]*v \n 00035 // The ith left eigenvector u satisfies u*A = W[i]*u (no conjugation) 00036 00037 class vnl_complex_eigensystem 00038 { 00039 public: 00040 // please do not add underscores to my members - they are publicly accessible 00041 unsigned int const N; 00042 vnl_matrix<vcl_complex<double> > L; // left evecs 00043 vnl_matrix<vcl_complex<double> > R; // right evecs 00044 vnl_vector<vcl_complex<double> > W; // evals 00045 00046 // constructors 00047 vnl_complex_eigensystem(vnl_matrix<double> const& A_real, 00048 vnl_matrix<double> const& A_imag, 00049 bool right=true, bool left=false); 00050 00051 vnl_complex_eigensystem(vnl_matrix<vcl_complex<double> > const& A, 00052 bool right=true, bool left=false); 00053 00054 // convenience methods 00055 vcl_complex<double> eigen_value(unsigned i) const { return W[i]; } 00056 vnl_vector<vcl_complex<double> > left_eigen_vector(unsigned i) 00057 const { return L.get_row(i); } 00058 vnl_vector<vcl_complex<double> > right_eigen_vector(unsigned i) 00059 const { return R.get_row(i); } 00060 00061 private: 00062 void compute(vnl_matrix<vcl_complex<double> > const&,bool,bool); 00063 }; 00064 00065 #endif // vnl_complex_eigensystem_h_