SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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
Class Distance, a base class for all the distances used in the Shogun toolbox.
Definition: Distance.h:87
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:129
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
virtual bool init(CFeatures *l, CFeatures *r)
#define ASSERT(x)
Definition: SGIO.h:201
EDistanceType
Definition: Distance.h:32
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:19
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
CFeatures * lhs
feature vectors to occur on the left hand side
Definition: Distance.h:381
The class Features is the base class of all feature objects.
Definition: Features.h:68
CFeatures * rhs
feature vectors to occur on the right hand side
Definition: Distance.h:383
virtual void cleanup()=0
virtual EFeatureType get_feature_type() const =0

SHOGUN Machine Learning Toolbox - Documentation