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 .......: ltiPolynomialKernel.h 00027 * authors ....: Jochen Wickel 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 05.11.2001 00030 * revisions ..: $Id: ltiPolynomialKernel.h,v 1.7 2006/02/07 18:22:03 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_POLYNOMIAL_KERNEL 00034 #define _LTI_POLYNOMIAL_KERNEL 00035 00036 #include "ltiKernelFunctor.h" 00037 00038 namespace lti { 00039 00040 /** 00041 * This class defines a polynomial kernel functor. It is defined 00042 * as \f$ K(A,B) = \left( 1 + A \cdot B \right)^d\f$ with A and B vectors and 00043 * d an integer given in the parameters. 00044 */ 00045 class polynomialKernel: public kernelFunctor<double> { 00046 00047 public: 00048 /** 00049 * the parameters for the class kernelFunctor 00050 */ 00051 class parameters : public kernelFunctor<double>::parameters { 00052 public: 00053 /** 00054 * default constructor 00055 */ 00056 parameters(); 00057 00058 /** 00059 * construct a parameter object for a polynomial kernel using the 00060 * given degree 00061 */ 00062 parameters(const int degree); 00063 00064 /** 00065 * copy constructor 00066 * @param other the parameters object to be copied 00067 */ 00068 parameters(const parameters& other); 00069 00070 /** 00071 * returns name of this type 00072 */ 00073 const char* getTypeName() const; 00074 00075 /** 00076 * copy the contents of a parameters object 00077 * @param other the parameters object to be copied 00078 * @return a reference to this parameters object 00079 */ 00080 parameters& copy(const parameters& other); 00081 00082 /** 00083 * returns a pointer to a clone of the parameters 00084 */ 00085 virtual functor::parameters* clone() const; 00086 00087 /** 00088 * write the parameters in the given ioHandler 00089 * @param handler the ioHandler to be used 00090 * @param complete if true (the default) the enclosing begin/end will 00091 * be also written, otherwise only the data block will be written. 00092 * @return true if write was successful 00093 */ 00094 virtual bool write(ioHandler& handler, 00095 const bool complete=true) const; 00096 00097 /** 00098 * read the parameters from the given ioHandler 00099 * @param handler the ioHandler to be used 00100 * @param complete if true (the default) the enclosing begin/end will 00101 * be also written, otherwise only the data block will be written. 00102 * @return true if write was successful 00103 */ 00104 virtual bool read(ioHandler& handler,const bool complete=true); 00105 00106 # ifdef _LTI_MSC_6 00107 /** 00108 * this function is required by MSVC only, as a workaround for a 00109 * very awful bug, which exists since MSVC V.4.0, and still by 00110 * V.6.0 with all bugfixes (so called "service packs") remains 00111 * there... This method is public due to another bug!, so please 00112 * NEVER EVER call this method directly 00113 */ 00114 bool readMS(ioHandler& handler,const bool complete=true); 00115 00116 /** 00117 * this function is required by MSVC only, as a workaround for a 00118 * very awful bug, which exists since MSVC V.4.0, and still by 00119 * V.6.0 with all bugfixes (so called "service packs") remains 00120 * there... This method is public due to another bug!, so please 00121 * NEVER EVER call this method directly 00122 */ 00123 bool writeMS(ioHandler& handler,const bool complete=true) const; 00124 # endif 00125 00126 /** Degree of the polynomial kernel 00127 */ 00128 int d; 00129 }; 00130 00131 /** 00132 * default constructor 00133 */ 00134 polynomialKernel(); 00135 00136 /** 00137 * Constructor to create a polynomial kernel of the given degree. 00138 */ 00139 polynomialKernel(const int degree); 00140 00141 00142 /** 00143 * copy constructor 00144 * @param other the object to be copied 00145 */ 00146 polynomialKernel(const polynomialKernel& other); 00147 00148 /** 00149 * returns the name of this type ("polynomialKernel") 00150 */ 00151 virtual const char* getTypeName() const; 00152 00153 /** 00154 * calculate the distance between the vectors a and b 00155 * @param a the first vector<T> 00156 * @param b the second vector<T> 00157 * @return the kernel function value of the vectors 00158 */ 00159 virtual double apply(const vector<double>& a, const vector<double>& b) const; 00160 00161 /** 00162 * returns a pointer to a clone of this functor. 00163 */ 00164 virtual functor* clone() const; 00165 00166 /** 00167 * returns used parameters 00168 */ 00169 const parameters& getParameters() const; 00170 }; 00171 00172 } 00173 00174 #endif