SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
144  {
145  return F_DREAL;
146  }
147 
153  {
154  return C_COMBINED_DOT;
155  }
156 
161  inline virtual int32_t get_size()
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 
283  virtual void get_subfeature_weights(float64_t** weights, int32_t* num_weights);
284 
290  virtual void set_subfeature_weights(
291  float64_t* weights, int32_t num_weights);
292 
294  inline virtual const char* get_name() const { return "CombinedDotFeatures"; }
295 
296  protected:
299 
300  private:
301  void init();
302 
303  protected:
306 
308  int32_t num_vectors;
310  int32_t num_dimensions;
311 };
312 }
313 #endif // _DOTFEATURES_H___
int32_t num_vectors
total number of vectors
virtual int32_t get_dim_feature_space() const
virtual void dense_dot_range(float64_t *output, int32_t start, int32_t stop, float64_t *alphas, float64_t *vec, int32_t dim, float64_t b)
virtual bool get_next_feature(int32_t &index, float64_t &value, void *iterator)
CDotFeatures(int32_t size=0)
Definition: DotFeatures.cpp:42
bool insert_feature_obj(CDotFeatures *obj)
CFeatures(int32_t size=0)
Definition: Features.cpp:22
virtual void dense_dot_range_subset(int32_t *sub_index, int32_t num, float64_t *output, float64_t *alphas, float64_t *vec, int32_t dim, float64_t b)
virtual CFeatures * duplicate() const
Features that support dot products among other operations.
Definition: DotFeatures.h:41
bool append_feature_obj(CDotFeatures *obj)
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:35
virtual EFeatureClass get_feature_class()
virtual int32_t get_num_vectors() const
virtual const char * get_name() const
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:56
virtual int32_t get_nnz_features_for_vector(int32_t num)
virtual void get_subfeature_weights(float64_t **weights, int32_t *num_weights)
EFeatureType
shogun feature type
Definition: FeatureTypes.h:16
virtual void set_subfeature_weights(float64_t *weights, int32_t num_weights)
virtual EFeatureType get_feature_type()
Class ListElement, defines how an element of the the list looks like.
Definition: List.h:22
Features that allow stacking of a number of DotFeatures.
virtual void free_feature_iterator(void *iterator)
virtual float64_t dense_dot(int32_t vec_idx1, const float64_t *vec2, int32_t vec2_len)
virtual void * get_feature_iterator(int32_t vector_index)
int32_t num_dimensions
total number of dimensions
virtual float64_t dot(int32_t vec_idx1, CDotFeatures *df, int32_t vec_idx2)
Class List implements a doubly connected list for low-level-objects.
Definition: List.h:78

SHOGUN Machine Learning Toolbox - Documentation