latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 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 .......: ltiLinearKernel.h 00027 * authors ....: Jochen Wickel 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 05.11.2001 00030 * revisions ..: $Id: ltiLinearKernel.h,v 1.6 2006/02/07 18:19:32 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_LINEAR_KERNEL 00034 #define _LTI_LINEAR_KERNEL 00035 00036 #include "ltiKernelFunctor.h" 00037 00038 namespace lti { 00039 00040 /** 00041 * This class defines a linear kernel functor. It is the simplest 00042 * possible kernel, and returns the scalar product of the two 00043 * vectors (i.e. k(x,y) = x.dot(y)). 00044 * 00045 * This mainly serves as a example kernel function. For solving 00046 * really relevant problems, you need more complex functions. 00047 */ 00048 class linearKernel: public kernelFunctor<double> { 00049 00050 public: 00051 /** 00052 * the parameters for the class distanceFunctor 00053 */ 00054 class parameters : public kernelFunctor<double>::parameters { 00055 public: 00056 /** 00057 * default constructor 00058 */ 00059 parameters(); 00060 00061 /** 00062 * copy constructor 00063 * @param other the parameters object to be copied 00064 */ 00065 parameters(const parameters& other); 00066 00067 /** 00068 * returns name of this type 00069 */ 00070 const char* getTypeName() const; 00071 00072 /** 00073 * copy the contents of a parameters object 00074 * @param other the parameters object to be copied 00075 * @return a reference to this parameters object 00076 */ 00077 parameters& copy(const parameters& other); 00078 00079 /** 00080 * returns a pointer to a clone of the parameters 00081 */ 00082 virtual functor::parameters* clone() const; 00083 00084 /** 00085 * write the parameters in the given ioHandler 00086 * @param handler the ioHandler to be used 00087 * @param complete if true (the default) the enclosing begin/end will 00088 * be also written, otherwise only the data block will be written. 00089 * @return true if write was successful 00090 */ 00091 virtual bool write(ioHandler& handler, 00092 const bool complete=true) const; 00093 00094 /** 00095 * read the parameters from the given ioHandler 00096 * @param handler the ioHandler to be used 00097 * @param complete if true (the default) the enclosing begin/end will 00098 * be also written, otherwise only the data block will be written. 00099 * @return true if write was successful 00100 */ 00101 virtual bool read(ioHandler& handler,const bool complete=true); 00102 00103 # ifdef _LTI_MSC_6 00104 /** 00105 * this function is required by MSVC only, as a workaround for a 00106 * very awful bug, which exists since MSVC V.4.0, and still by 00107 * V.6.0 with all bugfixes (so called "service packs") remains 00108 * there... This method is public due to another bug!, so please 00109 * NEVER EVER call this method directly 00110 */ 00111 bool readMS(ioHandler& handler,const bool complete=true); 00112 00113 /** 00114 * this function is required by MSVC only, as a workaround for a 00115 * very awful bug, which exists since MSVC V.4.0, and still by 00116 * V.6.0 with all bugfixes (so called "service packs") remains 00117 * there... This method is public due to another bug!, so please 00118 * NEVER EVER call this method directly 00119 */ 00120 bool writeMS(ioHandler& handler,const bool complete=true) const; 00121 # endif 00122 }; 00123 00124 /** 00125 * default constructor 00126 */ 00127 linearKernel(); 00128 00129 /** 00130 * copy constructor 00131 * @param other the object to be copied 00132 */ 00133 linearKernel(const linearKernel& other); 00134 00135 /** 00136 * returns the name of this type ("linearKernel") 00137 */ 00138 virtual const char* getTypeName() const; 00139 00140 /** 00141 * calculate the distance between the vectors a and b 00142 * @param a the first vector<T> 00143 * @param b the second vector<T> 00144 * @return the kernel function value of the vectors 00145 */ 00146 virtual double apply(const vector<double>& a, 00147 const vector<double>& b) const; 00148 00149 /** 00150 * returns a pointer to a clone of this functor. 00151 */ 00152 virtual functor* clone() const; 00153 00154 /** 00155 * returns used parameters 00156 */ 00157 const parameters& getParameters() const; 00158 }; 00159 00160 } 00161 00162 #endif