SHOGUN  4.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LinearARDKernel.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  * (W) 2015 Wu Lin
8  * (W) 2012 Jacob Walker
9  *
10  * Adapted from WeightedDegreeRBFKernel.h
11  */
12 
13 #ifndef LINEARARDKERNEL_H
14 #define LINEARARDKERNEL_H
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
19 
20 namespace shogun
21 {
22 
24 {
26  KT_DIAG=20,
28 };
29 
67 {
68 public:
71 
72  virtual ~CLinearARDKernel();
73 
78  virtual EKernelType get_kernel_type() { return K_LINEARARD; }
79 
84  virtual const char* get_name() const { return "LinearARDKernel"; }
85 
90  virtual EFeatureClass get_feature_class() { return C_DENSE; }
91 
96  virtual EFeatureType get_feature_type() { return F_DREAL; }
97 
98 private:
99  void initialize();
100 
101 protected:
104 
107 
108 #ifdef HAVE_LINALG_LIB
109 public:
114  CLinearARDKernel(int32_t size);
115 
123  int32_t size=10);
124 
125 
132  virtual bool init(CFeatures* l, CFeatures* r);
133 
134 
141  virtual SGMatrix<float64_t> get_weights();
142 
153  index_t index=-1);
154 
158  virtual void set_scalar_weights(float64_t weight);
159 
163  virtual void set_vector_weights(SGVector<float64_t> weights);
164 
168  virtual void set_matrix_weights(SGMatrix<float64_t> weights);
169 
170 protected:
171 
179  virtual void set_weights(SGMatrix<float64_t> weights);
180 
189  virtual float64_t compute(int32_t idx_a, int32_t idx_b);
190 
197  virtual float64_t compute_helper(SGVector<float64_t> avec,
198  SGVector<float64_t>bvec);
199 
209  virtual float64_t compute_gradient_helper(SGVector<float64_t> avec, SGVector<float64_t> bvec,
210  float64_t scale, index_t index);
211 
220  virtual SGMatrix<float64_t> compute_right_product(SGVector<float64_t>right_vec, float64_t & scalar_weight);
221 
222 #endif /* HAVE_LINALG_LIB */
223 };
224 }
225 #endif /* _LINEARARDKERNEL_H_ */

SHOGUN Machine Learning Toolbox - Documentation