SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
SparseKernel.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) 1999-2009 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _SPARSEKERNEL_H___
12 #define _SPARSEKERNEL_H___
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/kernel/Kernel.h>
18 
19 namespace shogun
20 {
26 template <class ST> class CSparseKernel : public CKernel
27 {
28  public:
33  CSparseKernel(int32_t cachesize) : CKernel(cachesize) {}
34 
41  {
42  init(l, r);
43  }
44 
51  virtual bool init(CFeatures* l, CFeatures* r)
52  {
53  CKernel::init(l,r);
54 
59 
60  if (((CSparseFeatures<ST>*) lhs)->get_num_features() != ((CSparseFeatures<ST>*) rhs)->get_num_features())
61  {
62  SG_ERROR("train or test features #dimension mismatch (l:%d vs. r:%d)\n",
63  ((CSparseFeatures<ST>*) lhs)->get_num_features(),((CSparseFeatures<ST>*)rhs)->get_num_features());
64  }
65  return true;
66  }
67 
73 
79 
85  virtual const char* get_name() const {
86  return "SparseKernel"; }
87 
95  virtual EKernelType get_kernel_type()=0;
96 };
97 
99 
101 
103 
105 
107 
109 
111 }
112 #endif /* _SPARSEKERNEL_H__ */
EKernelType
Definition: Kernel.h:57
virtual EKernelType get_kernel_type()=0
virtual bool init(CFeatures *l, CFeatures *r)
Definition: SparseKernel.h:51
Template class SparseFeatures implements sparse matrices.
#define SG_ERROR(...)
Definition: SGIO.h:129
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
CSparseKernel(CFeatures *l, CFeatures *r)
Definition: SparseKernel.h:40
#define ASSERT(x)
Definition: SGIO.h:201
virtual EFeatureClass get_feature_class() const =0
virtual EFeatureClass get_feature_class()
Definition: SparseKernel.h:72
virtual EFeatureType get_feature_type()
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
Template class SparseKernel, is the base class of kernels working on sparse features.
Definition: SparseKernel.h:26
CFeatures * rhs
feature vectors to occur on right hand side
Definition: Kernel.h:1062
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
CFeatures * lhs
feature vectors to occur on left hand side
Definition: Kernel.h:1060
The class Features is the base class of all feature objects.
Definition: Features.h:68
The Kernel base class.
Definition: Kernel.h:159
CSparseKernel(int32_t cachesize)
Definition: SparseKernel.h:33
virtual EFeatureType get_feature_type() const =0
virtual const char * get_name() const
Definition: SparseKernel.h:85

SHOGUN Machine Learning Toolbox - Documentation