SHOGUN  3.2.1
 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 
14 #include <shogun/lib/config.h>
15 
18 
19 namespace shogun
20 {
22 template <class ST> class CSparseDistance : public CDistance
23 {
24  public:
27 
34  virtual bool init(CFeatures* l, CFeatures* r)
35  {
36  CDistance::init(l,r);
37 
42 
43  if (((CSparseFeatures<ST>*) lhs)->get_num_features() != ((CSparseFeatures<ST>*) rhs)->get_num_features() )
44  {
45  SG_ERROR("train or test features #dimension mismatch (l:%d vs. r:%d)\n",
46  ((CSparseFeatures<ST>*) lhs)->get_num_features(),((CSparseFeatures<ST>*)rhs)->get_num_features());
47  }
48  return true;
49  }
50 
56 
62 
68  virtual const char* get_name() const {
69  return "SparseDistance"; }
70 
75  virtual void cleanup()=0;
76 
83  virtual EDistanceType get_distance_type()=0;
84 };
85 
91 
97 
103 
109 
115 
121 
127 } // namespace shogun
128 #endif

SHOGUN Machine Learning Toolbox - Documentation