SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GaussianCompactKernel.cpp
Go to the documentation of this file.
3 
4 using namespace shogun;
5 
7 {
8 }
9 
11  : CGaussianKernel(size, width)
12 {
13 }
14 
16  float64_t width, int32_t size)
17  : CGaussianKernel(l, r,
18  width, size)
19 {
20 }
21 
23 {
24 }
25 
26 float64_t CGaussianCompactKernel::compute(int32_t idx_a, int32_t idx_b)
27 {
28  int32_t len_features, power;
29  len_features=((CDotFeatures*) lhs)->get_dim_feature_space();
30  power=(len_features%2==0) ? (len_features+1):len_features;
31 
32  float64_t result=distance(idx_a,idx_b);
33  float64_t result_multiplier=1-(CMath::sqrt(result))/3;
34 
35  if(result_multiplier<=0)
36  return 0;
37 
38  return CMath::pow(result_multiplier, power)*CMath::exp(-result);
39 }
Features that support dot products among other operations.
Definition: DotFeatures.h:44
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
double float64_t
Definition: common.h:50
The well known Gaussian kernel (swiss army knife for SVMs) computed on CDotFeatures.
virtual float64_t distance(int32_t idx_a, int32_t idx_b) const
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
static float64_t exp(float64_t x)
Definition: Math.h:621
static float32_t sqrt(float32_t x)
Definition: Math.h:459
static int32_t pow(bool x, int32_t n)
Definition: Math.h:535

SHOGUN Machine Learning Toolbox - Documentation