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
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/common.h
>
16
#include <
shogun/kernel/DotKernel.h
>
17
#include <
shogun/features/DotFeatures.h
>
18
#include <
shogun/machine/KernelMachine.h
>
19
20
namespace
shogun
21
{
22
class
CKernelMachine;
23
class
CDotFeatures;
24
33
class
CLinearKernel
:
public
CDotKernel
34
{
35
public
:
38
CLinearKernel
();
39
45
CLinearKernel
(
CDotFeatures
* l,
CDotFeatures
* r);
46
47
virtual
~CLinearKernel
();
48
55
virtual
bool
init
(
CFeatures
* l,
CFeatures
* r);
56
58
virtual
void
cleanup
();
59
64
virtual
EKernelType
get_kernel_type
() {
return
K_LINEAR
; }
65
70
virtual
const
char
*
get_name
()
const
{
return
"LinearKernel"
; }
71
80
virtual
bool
init_optimization
(
81
int32_t num_suppvec, int32_t* sv_idx,
float64_t
* alphas);
82
86
virtual
bool
init_optimization
(
CKernelMachine
* km);
87
92
virtual
bool
delete_optimization
();
93
99
virtual
float64_t
compute_optimized
(int32_t idx);
100
101
virtual
void
clear_normal
()
102
{
103
normal
=
SGVector<float64_t>
(((
CDotFeatures
*)
lhs
)->get_dim_feature_space());
104
normal
.
zero
();
105
set_is_initialized
(
true
);
106
}
107
113
virtual
void
add_to_normal
(int32_t idx,
float64_t
weight);
114
119
SGVector<float64_t>
get_w
()
const
120
{
121
ASSERT
(
lhs
)
122
return
normal
;
123
}
124
129
void
set_w
(
SGVector<float64_t>
w)
130
{
131
ASSERT
(
lhs
&& w.
size
()==((
CDotFeatures
*)
lhs
)->get_dim_feature_space())
132
this->
normal
= w;
133
}
134
135
protected
:
137
SGVector<float64_t>
normal
;
138
};
139
}
140
#endif
/* _LINEARKERNEL_H__ */
SHOGUN
Machine Learning Toolbox - Documentation