SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparseDistance.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2007-2009 Soeren Sonnenburg
8  * Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _SPARSEDISTANCE_H___
12 #define _SPARSEDISTANCE_H___
13 
16 
17 namespace shogun
18 {
20 template <class ST> class CSparseDistance : public CDistance
21 {
22  public:
25 
32  virtual bool init(CFeatures* l, CFeatures* r)
33  {
34  CDistance::init(l,r);
35 
40 
41  if (((CSparseFeatures<ST>*) lhs)->get_num_features() != ((CSparseFeatures<ST>*) rhs)->get_num_features() )
42  {
43  SG_ERROR("train or test features #dimension mismatch (l:%d vs. r:%d)\n",
44  ((CSparseFeatures<ST>*) lhs)->get_num_features(),((CSparseFeatures<ST>*)rhs)->get_num_features());
45  }
46  return true;
47  }
48 
54 
60 
66  virtual const char* get_name() const {
67  return "SparseDistance"; }
68 
73  virtual void cleanup()=0;
74 
81  virtual EDistanceType get_distance_type()=0;
82 };
83 
89 
95 
101 
107 
113 
119 
125 } // namespace shogun
126 #endif

SHOGUN Machine Learning Toolbox - Documentation