SHOGUN  v3.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>
19 
20 namespace shogun
21 {
22 class CFeatures;
23 class CDynamicObjectArray;
44 {
45  public:
48 
51 
53  virtual ~CCombinedDotFeatures();
54 
59  virtual int32_t get_num_vectors() const
60  {
61  return num_vectors;
62  }
63 
68  virtual int32_t get_dim_feature_space() const
69  {
70  return num_dimensions;
71  }
72 
80  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
81 
88  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
89 
101  virtual void dense_dot_range(float64_t* output, int32_t start,
102  int32_t stop, float64_t* alphas, float64_t* vec,
103  int32_t dim, float64_t b);
104 
116  virtual void dense_dot_range_subset(int32_t* sub_index, int32_t num,
117  float64_t* output, float64_t* alphas, float64_t* vec,
118  int32_t dim, float64_t b);
119 
128  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
129  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
130 
136  virtual int32_t get_nnz_features_for_vector(int32_t num);
137 
143  {
144  return F_DREAL;
145  }
146 
152  {
153  return C_COMBINED_DOT;
154  }
155 
156  #ifndef DOXYGEN_SHOULD_SKIP_THIS
157 
158  struct combined_feature_iterator
159  {
161  CDotFeatures* f;
163  void* iterator;
165  int32_t vector_index;
166  };
167  #endif
168 
178  virtual void* get_feature_iterator(int32_t vector_index);
179 
190  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
191 
197  virtual void free_feature_iterator(void* iterator);
198 
203  virtual CFeatures* duplicate() const;
204 
206  void list_feature_objs();
207 
213  CDotFeatures* get_feature_obj(int32_t idx);
214 
222  bool insert_feature_obj(CDotFeatures* obj, int32_t idx);
223 
229  bool append_feature_obj(CDotFeatures* obj);
230 
236  bool delete_feature_obj(int32_t idx);
237 
242  int32_t get_num_feature_obj();
243 
247  virtual SGVector<float64_t> get_subfeature_weights();
248 
253  virtual void set_subfeature_weights(SGVector<float64_t> weights);
254 
256  virtual const char* get_name() const { return "CombinedDotFeatures"; }
257 
258  protected:
261 
262  private:
263  void init();
264 
265  protected:
268 
270  int32_t iterator_idx;
272  int32_t num_vectors;
274  int32_t num_dimensions;
275 };
276 }
277 #endif // _DOTFEATURES_H___

SHOGUN Machine Learning Toolbox - Documentation