SHOGUN
v2.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
features
ExplicitSpecFeatures.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) 2009 Soeren Sonnenburg
8
* Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
*/
10
11
#ifndef _EXPLICITSPECFEATURES_H___
12
#define _EXPLICITSPECFEATURES_H___
13
14
#include <
shogun/lib/common.h
>
15
#include <
shogun/features/DotFeatures.h
>
16
#include <
shogun/features/StringFeatures.h
>
17
18
namespace
shogun
19
{
20
template
<
class
ST>
class
CStringFeatures;
21
26
class
CExplicitSpecFeatures
:
public
CDotFeatures
27
{
28
public
:
30
CExplicitSpecFeatures
();
31
37
CExplicitSpecFeatures
(
CStringFeatures<uint16_t>
* str,
bool
normalize=
true
);
38
40
CExplicitSpecFeatures
(
const
CExplicitSpecFeatures
& orig);
41
43
virtual
~CExplicitSpecFeatures
();
44
49
virtual
CFeatures
*
duplicate
()
const
;
50
58
virtual
int32_t
get_dim_feature_space
()
const
;
59
67
virtual
float64_t
dot
(int32_t vec_idx1,
CDotFeatures
* df, int32_t vec_idx2);
68
75
virtual
float64_t
dense_dot
(int32_t vec_idx1,
const
float64_t
* vec2, int32_t vec2_len);
76
85
virtual
void
add_to_dense_vec
(
float64_t
alpha, int32_t vec_idx1,
86
float64_t
* vec2, int32_t vec2_len,
bool
abs_val=
false
);
87
88
#ifndef DOXYGEN_SHOULD_SKIP_THIS
89
90
struct
explicit_spec_feature_iterator
91
{
93
uint16_t* vec;
95
int32_t vidx;
97
int32_t vlen;
99
bool
vfree;
100
102
int32_t index;
103
104
};
105
#endif
106
116
virtual
void
*
get_feature_iterator
(int32_t vector_index);
117
128
virtual
bool
get_next_feature
(int32_t& index,
float64_t
& value,
void
* iterator);
129
135
virtual
void
free_feature_iterator
(
void
* iterator);
136
142
virtual
int32_t
get_nnz_features_for_vector
(int32_t num);
143
148
virtual
EFeatureType
get_feature_type
()
const
;
149
154
virtual
EFeatureClass
get_feature_class
()
const
;
155
160
virtual
int32_t
get_num_vectors
()
const
;
161
166
virtual
int32_t
get_size
()
const
;
167
169
inline
virtual
const
char
*
get_name
()
const
{
return
"ExplicitSpecFeatures"
; }
170
171
protected
:
176
void
obtain_kmer_spectrum
(
CStringFeatures<uint16_t>
* str);
177
179
void
delete_kmer_spectrum
();
180
181
protected
:
183
bool
use_normalization
;
185
int32_t
num_strings
;
187
int32_t
alphabet_size
;
188
190
int32_t
spec_size
;
192
float64_t
**
k_spectrum
;
193
};
194
}
195
#endif // _EXPLICITSPECFEATURES_H___
SHOGUN
Machine Learning Toolbox - Documentation