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 .......: ltiMinimizeBasis.h 00027 * authors ....: Thomas Rusert 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 09.06.99 00030 * revisions ..: $Id: ltiMinimizeBasis.h,v 1.7 2006/09/01 22:15:22 alvarado Exp $ 00031 */ 00032 00033 #ifndef _LTI_MINIMIZE_BASIS_H_ 00034 #define _LTI_MINIMIZE_BASIS_H_ 00035 00036 #include "ltiLinearAlgebraFunctor.h" 00037 #include "ltiMatrix.h" 00038 #include "ltiVector.h" 00039 00040 namespace lti { 00041 /** 00042 * minimizeBasis functor. 00043 * 00044 * This functor generates a minimum number of basis vectors to approximate 00045 * a given set of vectors within a given deviation. 00046 * 00047 * There is a Fast and an Exact method of computing the minimized 00048 * basis. Normally the Exact method should be used, because it does 00049 * not only compute the exact solution and the smallest basis, but 00050 * may even be faster than the "Fast" method. The "Fast" method is 00051 * not exact and may return a basis which is larger than 00052 * necessary. 00053 * 00054 * @ingroup gLinearAlgebra 00055 */ 00056 template<class T> 00057 class minimizeBasis : public linearAlgebraFunctor { 00058 public: 00059 /// minimizeBasis parameter class 00060 class parameters : public linearAlgebraFunctor::parameters { 00061 public: 00062 enum eMethod {Fast,Exact}; 00063 enum eDeviationType {Element,Vector,Matrix}; 00064 /// default constructor 00065 parameters() : linearAlgebraFunctor::parameters(), 00066 deviationType(Element), 00067 maxDeviation(0),method(Exact) {}; 00068 /// copy constructor 00069 parameters(const parameters& other) 00070 : linearAlgebraFunctor::parameters() {copy(other);}; 00071 /** deviation type. Check for 00072 <ul> 00073 <li>Element: the elements of the approximating vectors must not 00074 deviate more than maxDeviation from their approximated 00075 vectors 00076 <li>Vector: the l2VectorNorm of the deviation vector between the 00077 approximating and the approximated vector must not be 00078 be larger than maxDeviation 00079 <li>Matrix: the l2MatrixNorm of the difference matrix between the 00080 approximating and the approximated set of vectors must 00081 not be larger than maxDeviation 00082 </ul>*/ 00083 eDeviationType deviationType; 00084 /// maximal deviation 00085 double maxDeviation; 00086 /// apply method 00087 eMethod method; 00088 /// returns the name of this type 00089 virtual const char* getTypeName() const { 00090 return "minimizeBasis::parameters"; 00091 }; 00092 00093 /// copy member. 00094 parameters& copy(const parameters& other) { 00095 # ifndef _LTI_MSC_6 00096 // MS Visual C++ 6 is not able to compile this... 00097 linearAlgebraFunctor::parameters::copy(other); 00098 # else 00099 // ...so we have to use this workaround. 00100 // Conditional on that, copy may not be virtual. 00101 functor::parameters& 00102 (functor::parameters::* p_copy) 00103 (const functor::parameters&) = 00104 functor::parameters::copy; 00105 (this->*p_copy)(other); 00106 # endif 00107 00108 deviationType = other.deviationType; 00109 maxDeviation = other.maxDeviation; 00110 method = other.method; 00111 00112 return (*this); 00113 }; 00114 /// returns a pointer to a clone of the parameters. 00115 virtual functor::parameters* clone() const { 00116 return (new parameters(*this)); 00117 }; 00118 }; 00119 /// default constructor 00120 minimizeBasis() 00121 : linearAlgebraFunctor() {}; 00122 /// constructor, sets the parameters 00123 minimizeBasis(const parameters& theParams); 00124 /// destructor 00125 virtual ~minimizeBasis() {}; 00126 00127 /// returns the current parameters. 00128 const parameters& getParameters() const; 00129 00130 /** onCopy version of apply. 00131 * testVectors' rows should contain the vectors to be approximated. 00132 * newBasis' columns will contain the new basis vectors. 00133 * factors' rows will contain the factors to mulitply the new basis 00134 * vectors by to approximate the testVectors. 00135 */ 00136 void apply(const matrix<T>& testVectors, 00137 matrix<T>& newBasis, 00138 matrix<T>& factors); 00139 00140 /// returns a pointer to a clone of the functor. 00141 virtual functor* clone() const { 00142 return (new minimizeBasis<T>(*this)); 00143 }; 00144 00145 /// returns the name of this type 00146 virtual const char* getTypeName() const { 00147 return "minimizeBasis"; 00148 }; 00149 }; 00150 } 00151 00152 #include "ltiMinimizeBasis_template.h" 00153 00154 #endif