iRoCS Toolbox  1.1.0
Kernel_EDsqr.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2004-2015 Olaf Ronneberger, Florian Pigorsch, Jörg Mechnich,
4  * Thorsten Falk
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title: Squared Euclidean Distance
26 ** $RCSfile$
27 ** $Revision: 739 $$Name$
28 ** $Date: 2005-07-19 15:06:38 +0200 (Tue, 19 Jul 2005) $
29 ** Copyright: LGPL $Author: haasdonk $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.1 2005/07/19 13:06:38 haasdonk
38 ** initial revision
39 **
40 **
41 **************************************************************************/
42 
43 #ifndef KERNEL_EDSQR_HH
44 #define KERNEL_EDSQR_HH
45 
46 #ifdef HAVE_CONFIG_H
47 #include <config.hh>
48 #endif
49 
50 // std includes
51 #include <cmath>
52 #include <map>
53 #include <set>
54 #include <string>
55 
56 // libsvmtl includes
57 #include "ProgressReporter.hh"
58 
59 // requirements of template parameters
61 
62 namespace svt
63 {
64  /*======================================================================*/
72  /*======================================================================*/
74  {
75  public:
77  {};
78 
80  {};
81 
82  template< typename ForwardIter, typename Accessor>
83  void updateCache( const ForwardIter& fvBegin,
84  const ForwardIter& fvEnd,
85  Accessor accessor,
86  ProgressReporter* pr = 0) const
87  {
88  // nothing to do here
89  }
90 
91  // new updateCache-Syntax:
92  template< typename ForwardIter1, typename Accessor1,
93  typename ForwardIter2, typename Accessor2 >
94  void updateCache( const ForwardIter1& fvBegin1,
95  const ForwardIter1& fvEnd1,
96  Accessor1 accessor1,
97  const ForwardIter2& fvBegin2,
98  const ForwardIter2& fvEnd2,
99  Accessor2 accessor2,
100  ProgressReporter* pr = 0) const
101  {
102  // nothing to do here
103  }
104 
105  void clearCache() const
106  {
107  // nothing to do here
108  }
109 
110  template< typename FV>
111  double k_function( const FV& x, const FV& y) const
112  {
113  return x.square() - 2*x.dotProduct(y) + y.square();
114  };
115 
116  template<typename STDATA>
117  void loadParameters( STDATA& stData)
118  {
120  };
121 
122  template<typename STDATA>
123  void saveParameters( STDATA& stData) const
124  {
126  stData.setValue( "kernel_type", name());
127  };
128 
129  static const char* name()
130  {
131  return "edsqr";
132  }
133 
134  static const char* description()
135  {
136  return "squared Euclidean distance function: |u-v|^2";
137  }
138 
139  /*======================================================================*/
148  /*======================================================================*/
149  static void getParamInfos( std::vector<ParamInfo>& p)
150  {
151  }
152  };
153 }
154 
155 #endif
156 
157 
158 
159 
160 
161 
#define CHECK_MEMBER_TEMPLATE(c)
void saveParameters(STDATA &stData) const
void updateCache(const ForwardIter &fvBegin, const ForwardIter &fvEnd, Accessor accessor, ProgressReporter *pr=0) const
Definition: Kernel_EDsqr.hh:83
double k_function(const FV &x, const FV &y) const
static const char * description()
void updateCache(const ForwardIter1 &fvBegin1, const ForwardIter1 &fvEnd1, Accessor1 accessor1, const ForwardIter2 &fvBegin2, const ForwardIter2 &fvEnd2, Accessor2 accessor2, ProgressReporter *pr=0) const
Definition: Kernel_EDsqr.hh:94
The Kernel_EDsqr class specifies a Euclidean distance kernel |u-v|^2 to be used in the distance subst...
Definition: Kernel_EDsqr.hh:73
void loadParameters(STDATA &stData)
void clearCache() const
static const char * name()
static void getParamInfos(std::vector< ParamInfo > &p)
get information about the parameters, that are used in loadParameters() and saveParameters().