LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiKernelFunctor.h

00001 /*
00002  * Copyright (C) 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 .......: ltiKernelFunctor.h
00027  * authors ....: Jochen Wickel
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 28.6.2000
00030  * revisions ..: $Id: ltiKernelFunctor.h,v 1.6 2006/02/07 18:19:07 ltilib Exp $
00031  */
00032 
00033 #ifndef _LTI_KERNEL_FUNCTOR
00034 #define _LTI_KERNEL_FUNCTOR
00035 
00036 #include "ltiFunctor.h"
00037 #include "ltiVector.h"
00038 
00039 namespace lti {
00040 
00041   /**
00042    * This class defines a kernel functor. A kernel is sort of an
00043    * inner product, but needs not be linear. It takes two vectors
00044    * and returns a scalar. The most simple kernel is the canonical
00045    * scalar product.
00046    *
00047    * @see linearKernel, sigmoidKernel, radialKernel, polynomialKernel
00048    *
00049    * For more information on kernel machines see
00050    * <A HREF="http://www.kernel-machines.org">here</A>.
00051    */
00052   template <class T>
00053   class kernelFunctor: public functor {
00054 
00055   public:
00056     /**
00057      * the parameters for the class distanceFunctor
00058      */
00059     class parameters : public functor::parameters {
00060     public:
00061 
00062       /**
00063        * default constructor
00064        */
00065       parameters() : functor::parameters() {
00066       };
00067 
00068       /**
00069        * copy constructor
00070        * @param other the parameters object to be copied
00071        */
00072       parameters(const parameters& other) 
00073         : functor::parameters() {
00074         copy(other);
00075       };
00076 
00077       /**
00078        * destructor
00079        */
00080       ~parameters() {
00081       };
00082 
00083       /**
00084        * returns name of this type
00085        */
00086       const char* getTypeName() const {
00087         return "kernelFunctor::parameters";
00088       };
00089 
00090       /**
00091        * copy the contents of a parameters object
00092        * @param other the parameters object to be copied
00093        * @return a reference to this parameters object
00094        */
00095       parameters& copy(const parameters& other) {
00096 # ifndef _LTI_MSC_6
00097        // MS Visual C++ 6 is not able to compile this...
00098         functor::parameters::copy(other);
00099 # else
00100        // ...so we have to use this workaround.
00101        // Conditional on that, copy may not be virtual.
00102        functor::parameters&
00103          (functor::parameters::* p_copy)
00104          (const functor::parameters&) =
00105          functor::parameters::copy;
00106        (this->*p_copy)(other);
00107 # endif
00108        return *this;
00109       };
00110 
00111       /**
00112        * returns a pointer to a clone of the parameters
00113        */
00114       virtual functor::parameters* clone() const {
00115         return new parameters(*this);
00116       };
00117     };
00118 
00119     /**
00120      * default constructor
00121      */
00122     kernelFunctor();
00123 
00124     /**
00125      * copy constructor
00126      * @param other the object to be copied
00127      */
00128     kernelFunctor(const kernelFunctor<T>& other);
00129 
00130     /**
00131      * destructor
00132      */
00133     virtual ~kernelFunctor();
00134 
00135     /**
00136      * returns the name of this type ("kernelFunctor")
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 T apply(const vector<T>& a, const vector<T>& b) const=0;
00147 
00148     /**
00149      * copy data of "other" functor.
00150      * @param other the functor to be copied
00151      * @return a reference to this functor object
00152      */
00153     kernelFunctor<T>& copy(const kernelFunctor<T>& other);
00154 
00155     /**
00156      * returns a pointer to a clone of this functor.
00157      */
00158     virtual functor* clone() const;
00159 
00160     /**
00161      * returns used parameters
00162      */
00163     const parameters& getParameters() const;
00164   };
00165 
00166 }
00167 
00168 #include "ltiKernelFunctor_template.h"
00169 
00170 #endif

Generated on Sat Apr 10 15:25:41 2010 for LTI-Lib by Doxygen 1.6.1