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