SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LinearKernel.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-2010 Soeren Sonnenburg
8  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  * Copyright (C) 2010 Berlin Institute of Technology
10  */
11 
12 #ifndef _LINEARKERNEL_H___
13 #define _LINEARKERNEL_H___
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
21 
22 namespace shogun
23 {
24  class CKernelMachine;
25  class CDotFeatures;
26 
36 {
37  public:
40  CLinearKernel();
41 
48 
49  virtual ~CLinearKernel();
50 
57  virtual bool init(CFeatures* l, CFeatures* r);
58 
60  virtual void cleanup();
61 
66  virtual EKernelType get_kernel_type() { return K_LINEAR; }
67 
72  virtual const char* get_name() const { return "LinearKernel"; }
73 
82  virtual bool init_optimization(
83  int32_t num_suppvec, int32_t* sv_idx, float64_t* alphas);
84 
88  virtual bool init_optimization(CKernelMachine* km);
89 
94  virtual bool delete_optimization();
95 
101  virtual float64_t compute_optimized(int32_t idx);
102 
103  virtual void clear_normal()
104  {
105  normal = SGVector<float64_t>(((CDotFeatures*)lhs)->get_dim_feature_space());
106  normal.zero();
107  set_is_initialized(true);
108  }
109 
115  virtual void add_to_normal(int32_t idx, float64_t weight);
116 
122  {
123  ASSERT(lhs)
124  return normal;
125  }
126 
132  {
133  ASSERT(lhs && w.size()==((CDotFeatures*) lhs)->get_dim_feature_space())
134  this->normal = w;
135  }
136 
137  protected:
140 };
141 }
142 #endif /* _LINEARKERNEL_H__ */

SHOGUN Machine Learning Toolbox - Documentation