SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/kernel/Kernel.h>
16 
17 namespace shogun
18 {
24 template <class ST> class CSparseKernel : public CKernel
25 {
26  public:
31  CSparseKernel(int32_t cachesize) : CKernel(cachesize) {}
32 
39  {
40  init(l, r);
41  }
42 
49  virtual bool init(CFeatures* l, CFeatures* r)
50  {
51  CKernel::init(l,r);
52 
57 
58  if (((CSparseFeatures<ST>*) lhs)->get_num_features() != ((CSparseFeatures<ST>*) rhs)->get_num_features())
59  {
60  SG_ERROR( "train or test features #dimension mismatch (l:%d vs. r:%d)\n",
61  ((CSparseFeatures<ST>*) lhs)->get_num_features(),((CSparseFeatures<ST>*)rhs)->get_num_features());
62  }
63  return true;
64  }
65 
70  inline virtual EFeatureClass get_feature_class() { return C_SPARSE; }
71 
76  inline virtual EFeatureType get_feature_type();
77 
83  virtual const char* get_name() const {
84  return "SparseKernel"; }
85 
93  virtual EKernelType get_kernel_type()=0;
94 };
95 
97 
99 
101 
103 
105 
107 
109 }
110 #endif /* _SPARSEKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation