SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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/common.h>
16 #include <shogun/io/SGIO.h>
19 
20 namespace shogun
21 {
22 
23 template <class ST> class CStringFeatures;
24 
31 {
32  public:
35 
42 
45 
47 
52  virtual CFeatures* duplicate() const;
53 
61  virtual int32_t get_dim_feature_space() const;
62 
70  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
71 
78  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
79 
88  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
89  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
90 
96  virtual inline int32_t get_nnz_features_for_vector(int32_t num);
97 
102  virtual EFeatureType get_feature_type() const;
103 
108  virtual EFeatureClass get_feature_class() const;
109 
114  virtual int32_t get_num_vectors() const;
115 
120  virtual int32_t get_size() const;
121 
126  bool set_wd_weights();
127 
134  bool set_weights(float64_t* w, int32_t d);
135 
136  #ifndef DOXYGEN_SHOULD_SKIP_THIS
137 
138  struct wspec_feature_iterator
139  {
141  uint16_t* vec;
143  int32_t vidx;
145  int32_t vlen;
147  bool vfree;
148 
153  int32_t offs;
154  int32_t d;
155  int32_t j;
156  uint8_t mask;
157  float64_t alpha;
159  };
160  #endif
161 
171  virtual void* get_feature_iterator(int32_t vector_index);
172 
183  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
184 
190  virtual void free_feature_iterator(void* iterator);
191 
193  inline virtual const char* get_name() const { return "ImplicitWeightedSpecFeatures"; }
194 
195  protected:
201 
202  protected:
205 
209  int32_t num_strings;
211  int32_t alphabet_size;
212 
214  int32_t degree;
216  int32_t spec_size;
217 
220 };
221 }
222 #endif // _IMPLICITSPECFEATURES_H___

SHOGUN Machine Learning Toolbox - Documentation