SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
kernel
GaussianKernel.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
* Written (W) 2011 Abhinav Maurya
9
* Written (W) 2012 Heiko Strathmann
10
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
11
* Copyright (C) 2010 Berlin Institute of Technology
12
*/
13
14
#ifndef _GAUSSIANKERNEL_H___
15
#define _GAUSSIANKERNEL_H___
16
17
#include <
shogun/lib/common.h
>
18
#include <
shogun/kernel/Kernel.h
>
19
#include <
shogun/kernel/DotKernel.h
>
20
#include <
shogun/features/DotFeatures.h
>
21
22
namespace
shogun
23
{
24
class
CDotFeatures;
46
class
CGaussianKernel
:
public
CDotKernel
47
{
48
public
:
50
CGaussianKernel
();
51
57
CGaussianKernel
(int32_t size,
float64_t
width
);
58
66
CGaussianKernel
(
CDotFeatures
* l,
CDotFeatures
* r,
67
float64_t
width, int32_t size=10);
68
69
virtual
~CGaussianKernel
();
70
75
static
CGaussianKernel
*
obtain_from_generic
(
CKernel
*
kernel
);
76
78
virtual
CSGObject
*
shallow_copy
()
const
;
79
86
virtual
bool
init
(
CFeatures
* l,
CFeatures
* r);
87
89
virtual
void
cleanup
();
90
95
virtual
EKernelType
get_kernel_type
() {
return
K_GAUSSIAN
; }
96
101
virtual
const
char
*
get_name
()
const
{
return
"GaussianKernel"
; }
102
107
virtual
void
set_width
(
float64_t
w) { width=w; }
108
113
virtual
float64_t
get_width
()
const
{
return
width
; }
114
119
inline
void
set_compact_enabled
(
bool
compact) {
m_compact
=compact; }
120
125
inline
bool
get_compact_enabled
() {
return
m_compact
; }
126
134
virtual
SGMatrix<float64_t>
get_parameter_gradient
(
135
const
TParameter
* param,
index_t
index=-1);
136
137
protected
:
146
virtual
float64_t
compute
(int32_t idx_a, int32_t idx_b);
147
154
virtual
void
load_serializable_post
() throw (
ShogunException
);
155
156
private:
160
void
precompute_squared();
161
168
void
precompute_squared_helper(
float64_t
* &buf,
CDotFeatures
* df);
169
170
void
init();
171
172
protected:
174
float64_t
width;
176
float64_t
*
sq_lhs
;
178
float64_t
*
sq_rhs
;
180
bool
m_compact
;
181
};
182
}
183
#endif
/* _GAUSSIANKERNEL_H__ */
SHOGUN
Machine Learning Toolbox - Documentation