SHOGUN  3.2.1
 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/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__ */

SHOGUN Machine Learning Toolbox - Documentation