SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CombinedDotFeatures.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 
13 #ifndef _COMBINEDDOTFEATURES_H___
14 #define _COMBINEDDOTFEATURES_H___
15 
16 #include <shogun/lib/common.h>
17 #include <shogun/lib/List.h>
19 
20 namespace shogun
21 {
22 class CFeatures;
23 class CList;
24 class CListElement;
45 {
46  public:
49 
52 
54  virtual ~CCombinedDotFeatures();
55 
60  inline virtual int32_t get_num_vectors() const
61  {
62  return num_vectors;
63  }
64 
69  inline virtual int32_t get_dim_feature_space() const
70  {
71  return num_dimensions;
72  }
73 
81  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
82 
89  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
90 
102  virtual void dense_dot_range(float64_t* output, int32_t start,
103  int32_t stop, float64_t* alphas, float64_t* vec,
104  int32_t dim, float64_t b);
105 
117  virtual void dense_dot_range_subset(int32_t* sub_index, int32_t num,
118  float64_t* output, float64_t* alphas, float64_t* vec,
119  int32_t dim, float64_t b);
120 
129  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
130  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
131 
137  virtual int32_t get_nnz_features_for_vector(int32_t num);
138 
143  inline virtual EFeatureType get_feature_type() const
144  {
145  return F_DREAL;
146  }
147 
152  inline virtual EFeatureClass get_feature_class() const
153  {
154  return C_COMBINED_DOT;
155  }
156 
161  inline virtual int32_t get_size() const
162  {
163  return sizeof(float64_t);
164  }
165 
166  #ifndef DOXYGEN_SHOULD_SKIP_THIS
167 
168  struct combined_feature_iterator
169  {
171  CDotFeatures* f;
173  CListElement* current;
175  void* iterator;
177  int32_t vector_index;
178  };
179  #endif
180 
190  virtual void* get_feature_iterator(int32_t vector_index);
191 
202  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
203 
209  virtual void free_feature_iterator(void* iterator);
210 
215  virtual CFeatures* duplicate() const;
216 
218  void list_feature_objs();
219 
225 
231  CDotFeatures* get_first_feature_obj(CListElement*& current);
232 
238 
244  CDotFeatures* get_next_feature_obj(CListElement*& current);
245 
251 
257  bool insert_feature_obj(CDotFeatures* obj);
258 
264  bool append_feature_obj(CDotFeatures* obj);
265 
270  bool delete_feature_obj();
271 
276  int32_t get_num_feature_obj();
277 
281  virtual SGVector<float64_t> get_subfeature_weights();
282 
287  virtual void set_subfeature_weights(SGVector<float64_t> weights);
288 
290  inline virtual const char* get_name() const { return "CombinedDotFeatures"; }
291 
292  protected:
295 
296  private:
297  void init();
298 
299  protected:
302 
304  int32_t num_vectors;
306  int32_t num_dimensions;
307 };
308 }
309 #endif // _DOTFEATURES_H___

SHOGUN Machine Learning Toolbox - Documentation