SHOGUN  v3.2.0
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
Class Distance, a base class for all the distances used in the Shogun toolbox.
Definition: Distance.h:80
template class SparseDistance
virtual EFeatureClass get_feature_class()
Template class SparseFeatures implements sparse matrices.
virtual const char * get_name() const
#define SG_ERROR(...)
Definition: SGIO.h:131
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:35
virtual bool init(CFeatures *l, CFeatures *r)
#define ASSERT(x)
Definition: SGIO.h:203
EDistanceType
Definition: Distance.h:31
virtual EFeatureType get_feature_type()
virtual EFeatureClass get_feature_class() const =0
virtual EDistanceType get_distance_type()=0
EFeatureType
shogun feature type
Definition: FeatureTypes.h:16
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:16
CFeatures * lhs
feature vectors to occur on the left hand side
Definition: Distance.h:342
The class Features is the base class of all feature objects.
Definition: Features.h:62
CFeatures * rhs
feature vectors to occur on the right hand side
Definition: Distance.h:344
virtual void cleanup()=0
virtual EFeatureType get_feature_type() const =0

SHOGUN Machine Learning Toolbox - Documentation