SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ImplicitWeightedSpecFeatures.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-2010 Soeren Sonnenburg
8  * Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  * Copyright (C) 2010 Berlin Institute of Technology
10  */
11 
12 #ifndef _IMPLICITSPECFEATURES_H___
13 #define _IMPLICITSPECFEATURES_H___
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
18 #include <shogun/io/SGIO.h>
21 
22 namespace shogun
23 {
24 
25 template <class ST> class CStringFeatures;
26 
33 {
34  public:
37 
44 
47 
49 
54  virtual CFeatures* duplicate() const;
55 
63  virtual int32_t get_dim_feature_space() const;
64 
72  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
73 
80  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
81 
90  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
91  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
92 
98  virtual int32_t get_nnz_features_for_vector(int32_t num);
99 
104  virtual EFeatureType get_feature_type() const;
105 
110  virtual EFeatureClass get_feature_class() const;
111 
116  virtual int32_t get_num_vectors() const;
117 
122  bool set_wd_weights();
123 
130  bool set_weights(float64_t* w, int32_t d);
131 
132  #ifndef DOXYGEN_SHOULD_SKIP_THIS
133 
134  struct wspec_feature_iterator
135  {
137  uint16_t* vec;
139  int32_t vidx;
141  int32_t vlen;
143  bool vfree;
144 
149  int32_t offs;
150  int32_t d;
151  int32_t j;
152  uint8_t mask;
153  float64_t alpha;
155  };
156  #endif
157 
167  virtual void* get_feature_iterator(int32_t vector_index);
168 
179  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
180 
186  virtual void free_feature_iterator(void* iterator);
187 
189  virtual const char* get_name() const { return "ImplicitWeightedSpecFeatures"; }
190 
191  protected:
197 
198  protected:
201 
205  int32_t num_strings;
207  int32_t alphabet_size;
208 
210  int32_t degree;
212  int32_t spec_size;
213 
216 };
217 }
218 #endif // _IMPLICITSPECFEATURES_H___
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
virtual void * get_feature_iterator(int32_t vector_index)
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
Features that support dot products among other operations.
Definition: DotFeatures.h:44
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
Features that compute the Weighted Spectrum Kernel feature space explicitly.
virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t *vec2, int32_t vec2_len, bool abs_val=false)
double float64_t
Definition: common.h:50
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68

SHOGUN Machine Learning Toolbox - Documentation