SHOGUN
3.2.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
kernel
DotKernel.h
浏览该文件的文档.
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) 2009 Soeren Sonnenburg
8
* Copyright (C) 2010 Berlin Institute of Technology
9
*/
10
11
#ifndef _DOTKERNEL_H___
12
#define _DOTKERNEL_H___
13
14
#include <
shogun/kernel/Kernel.h
>
15
#include <
shogun/features/DotFeatures.h
>
16
#include <
shogun/io/SGIO.h
>
17
18
namespace
shogun
19
{
29
class
CDotKernel
:
public
CKernel
30
{
31
public
:
35
CDotKernel
() :
CKernel
() {}
36
41
CDotKernel
(int32_t cachesize) :
CKernel
(cachesize) {}
42
48
CDotKernel
(
CFeatures
* l,
CFeatures
* r) :
CKernel
(10)
49
{
50
init
(l, r);
51
}
52
63
virtual
bool
init
(
CFeatures
* l,
CFeatures
* r)
64
{
65
CKernel::init(l,r);
66
67
ASSERT
(l->
has_property
(
FP_DOT
))
68
ASSERT
(r->
has_property
(
FP_DOT
))
69
ASSERT
(l->
get_feature_type
() == r->
get_feature_type
())
70
ASSERT
(l->
get_feature_class
() == r->
get_feature_class
())
71
72
if
( ((
CDotFeatures
*) l)->get_dim_feature_space() != ((
CDotFeatures
*) r)->get_dim_feature_space() )
73
{
74
SG_ERROR
(
"train or test features #dimension mismatch (l:%d vs. r:%d)\n"
,
75
((
CDotFeatures
*) l)->get_dim_feature_space(),((
CDotFeatures
*) r)->get_dim_feature_space());
76
}
77
return
true
;
78
}
79
86
virtual
EFeatureClass
get_feature_class
() {
return
C_ANY
; }
87
94
virtual
EFeatureType
get_feature_type
() {
return
F_ANY
; }
95
101
virtual
const
char
*
get_name
()
const
{
return
"DotKernel"
; }
102
110
virtual
EKernelType
get_kernel_type
()=0 ;
111
112
protected
:
121
virtual
float64_t
compute
(int32_t idx_a, int32_t idx_b)
122
{
123
return
((
CDotFeatures
*)
lhs
)->dot(idx_a, ((
CDotFeatures
*)
rhs
), idx_b);
124
}
125
};
126
}
127
#endif
/* _DOTKERNEL_H__ */
128
SHOGUN
机器学习工具包 - 项目文档