latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiGenEigVectors.h 00027 * authors ....: Xin Gu 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 16.06.99 00030 * revisions ..: $Id: ltiGenEigVectors.h,v 1.6 2006/09/11 17:04:04 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_GENERAL_EIGEN_VECTORS_H_ 00034 #define _LTI_GENERAL_EIGEN_VECTORS_H_ 00035 00036 #include "ltiLapackInterface.h" 00037 00038 #ifdef HAVE_LAPACK 00039 00040 #include "ltiEigenSystem.h" 00041 00042 namespace lti { 00043 /** 00044 * Generic eigenvalues and eigenvectors computations. 00045 * 00046 * Use LAPack functions to compute the eigenvalues and eigenvectors of 00047 * a matrix. 00048 * 00049 * @ingroup lapack 00050 * 00051 * @see \ref lapack 00052 */ 00053 template<class T> 00054 class generalEigenVectors : public eigenSystem<T>, lapackInterface { 00055 public: 00056 /** 00057 * eigenSystem parameter class 00058 */ 00059 class parameters : public eigenSystem<T>::parameters { 00060 public: 00061 /** 00062 * default constructor 00063 */ 00064 parameters() 00065 : eigenSystem<T>::parameters(),leftVector(false) { 00066 }; 00067 00068 /** 00069 * copy constructor 00070 */ 00071 parameters(const parameters& other) { 00072 copy(other); 00073 }; 00074 00075 /** 00076 * computing the left eigenvectors of the matrix. Default is 00077 * false, meaning that right eigenvectors are computed. 00078 */ 00079 bool leftVector; 00080 00081 /** 00082 * returns the name of this type 00083 */ 00084 virtual const char* getTypeName() const { 00085 return "generalEigenVectors::parameters"; 00086 }; 00087 00088 /** 00089 * copy member. 00090 */ 00091 parameters& copy(const parameters& other) { 00092 #ifndef _LTI_MSC_6 00093 // MS Visual C++ 6 is not able to compile this... 00094 eigenSystem<T>::parameters::copy(other); 00095 #else 00096 // ...so we have to use this workaround. 00097 // Conditional on that, copy may not be virtual. 00098 eigenSystem<T>::parameters& 00099 (eigenSystem<T>::parameters::* p_copy)(const eigenSystem<T>::parameters&) = 00100 eigenSystem<T>::parameters::copy; 00101 (this->*p_copy)(other); 00102 #endif 00103 leftVector=other.leftVector; 00104 00105 return (*this); 00106 }; 00107 00108 /** 00109 * returns a pointer to a clone of the parameters. 00110 */ 00111 virtual functor::parameters* clone() const { 00112 return (new parameters(*this)); 00113 }; 00114 }; 00115 00116 /** 00117 * default constructor 00118 */ 00119 generalEigenVectors(); 00120 00121 /** 00122 * constructor, sets the parameters 00123 */ 00124 generalEigenVectors(const parameters& theParams); 00125 00126 /** 00127 * constructor, sets the parameters 00128 */ 00129 generalEigenVectors(const bool left); 00130 00131 /** 00132 * destructor 00133 */ 00134 virtual ~generalEigenVectors(); 00135 00136 /** 00137 * returns the current parameters. 00138 */ 00139 const parameters& getParameters() const; 00140 00141 /** 00142 * clone this functor 00143 */ 00144 virtual functor* clone() const; 00145 00146 /** 00147 * Computes left or right eigenvalues and eigenvectors of the 00148 * given matrix. Which kind will be computed depends on the 00149 * value of getParameters().leftVector. 00150 * @param theMatrix matrix whose eigenvectors are to be computed 00151 * @param eigenvalues elements will contain the eigenvalues 00152 * @param iEigenvalues elements will contain the imaginary part of 00153 * the eigenvalues 00154 * @param eigenvectors columns will contain the eigenvectors 00155 * corresponding to the eigenvalues 00156 * @return false if \a theMatrix contains illegal values like NaN. 00157 * All return arguments are cleared. See lti::validator. 00158 */ 00159 virtual bool apply(const matrix<T>& theMatrix, 00160 vector<T>& eigenvalues, 00161 vector<T>& iEigenvalues, 00162 matrix<T>& eigenvectors) const; 00163 00164 /** 00165 * Computes left or right eigenvalues and eigenvectors of the 00166 * given matrix. Which kind will be computed depends on the 00167 * value of getParameters().leftVector. WARNING: This apply method 00168 * ignores imaginary parts of the eigenvalues. So if the eigenvalues 00169 * are in fact complex, you get wrong results. 00170 * @param theMatrix matrix whose eigenvectors are to be computed 00171 * @param eigenvalues elements will contain the eigenvalues 00172 * @param eigenvectors columns will contain the eigenvectors 00173 * corresponding to the eigenvalues 00174 * @return false if \a theMatrix contains illegal values like NaN. 00175 * All return arguments are cleared. See lti::validator. 00176 */ 00177 virtual bool apply(const matrix<T>& theMatrix, 00178 vector<T>& eigenvalues, 00179 matrix<T>& eigenvectors) const; 00180 00181 /** 00182 * Computes left eigenvalues and eigenvectors of the 00183 * given matrix. "Left" means that eigenvalues e and eigenvectors v 00184 * will obey the following law: v'A = ev' (v' meaning transpose of v) 00185 * @param theMatrix matrix whose eigenvectors are to be computed 00186 * @param eigenvalues elements will contain the eigenvalues 00187 * @param iEigenvalues elements will contain the imaginary part of 00188 * the eigenvalues 00189 * @param eigenvectors columns will contain the eigenvectors 00190 * corresponding to the eigenvalues 00191 * @return false if \a theMatrix contains illegal values like NaN. 00192 * All return arguments are cleared. See lti::validator. 00193 */ 00194 bool leftEigenVectors(const matrix<T>& theMatrix, 00195 vector<T>& eigenvalues, 00196 vector<T>& iEigenvalues, 00197 matrix<T>& eigenvectors) const; 00198 00199 /** 00200 * Computes right eigenvalues and eigenvectors of the 00201 * given matrix. "Right" means that eigenvalues e and eigenvectors v 00202 * will obey the following law: Av = ev 00203 * @param theMatrix matrix whose eigenvectors are to be computed 00204 * @param eigenvalues elements will contain the eigenvalues 00205 * @param iEigenvalues elements will contain the imaginary part of 00206 * the eigenvalues 00207 * @param eigenvectors columns will contain the eigenvectors 00208 * corresponding to the eigenvalues 00209 * @return false if \a theMatrix contains illegal values like NaN. 00210 * All return arguments are cleared. See lti::validator. 00211 */ 00212 bool rightEigenVectors(const matrix<T>& theMatrix, 00213 vector<T>& eigenvalues, 00214 vector<T>& iEigenvalues, 00215 matrix<T>& eigenvectors) const; 00216 00217 /** 00218 * returns the name of this type 00219 */ 00220 virtual const char* getTypeName() const { 00221 return "generalEigenVectors"; 00222 }; 00223 00224 private: 00225 // lapack routine in template form 00226 int geev(char *, char *, integer *, T *, integer *, T*, T*, T*, 00227 integer*, T*, integer*, T*, integer*, integer*) const; 00228 00229 }; 00230 00231 } 00232 00233 #endif 00234 #endif