SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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/config.h>
17 
18 #include <shogun/lib/common.h>
21 
22 namespace shogun
23 {
24 class CFeatures;
25 class CDynamicObjectArray;
46 {
47  public:
50 
53 
55  virtual ~CCombinedDotFeatures();
56 
61  virtual int32_t get_num_vectors() const
62  {
63  return num_vectors;
64  }
65 
70  virtual int32_t get_dim_feature_space() const
71  {
72  return num_dimensions;
73  }
74 
82  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
83 
90  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
91 
103  virtual void dense_dot_range(float64_t* output, int32_t start,
104  int32_t stop, float64_t* alphas, float64_t* vec,
105  int32_t dim, float64_t b);
106 
118  virtual void dense_dot_range_subset(int32_t* sub_index, int32_t num,
119  float64_t* output, float64_t* alphas, float64_t* vec,
120  int32_t dim, float64_t b);
121 
130  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
131  float64_t* vec2, int32_t vec2_len, bool abs_val=false);
132 
138  virtual int32_t get_nnz_features_for_vector(int32_t num);
139 
145  {
146  return F_DREAL;
147  }
148 
154  {
155  return C_COMBINED_DOT;
156  }
157 
158  #ifndef DOXYGEN_SHOULD_SKIP_THIS
159 
160  struct combined_feature_iterator
161  {
163  CDotFeatures* f;
165  void* iterator;
167  int32_t vector_index;
168  };
169  #endif
170 
180  virtual void* get_feature_iterator(int32_t vector_index);
181 
192  virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
193 
199  virtual void free_feature_iterator(void* iterator);
200 
205  virtual CFeatures* duplicate() const;
206 
208  void list_feature_objs();
209 
215  CDotFeatures* get_feature_obj(int32_t idx);
216 
224  bool insert_feature_obj(CDotFeatures* obj, int32_t idx);
225 
231  bool append_feature_obj(CDotFeatures* obj);
232 
238  bool delete_feature_obj(int32_t idx);
239 
244  int32_t get_num_feature_obj();
245 
249  virtual SGVector<float64_t> get_subfeature_weights();
250 
255  virtual void set_subfeature_weights(SGVector<float64_t> weights);
256 
258  virtual const char* get_name() const { return "CombinedDotFeatures"; }
259 
260  protected:
263 
264  private:
265  void init();
266 
267  protected:
270 
272  int32_t iterator_idx;
274  int32_t num_vectors;
276  int32_t num_dimensions;
277 };
278 }
279 #endif // _DOTFEATURES_H___
int32_t iterator_idx
idx for iterator
CDynamicObjectArray * feature_array
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, int32_t idx)
virtual void set_subfeature_weights(SGVector< float64_t > weights)
CFeatures(int32_t size=0)
Definition: Features.cpp:23
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:44
bool append_feature_obj(CDotFeatures *obj)
EFeatureClass
shogun feature class
Definition: FeatureTypes.h:38
virtual EFeatureType get_feature_type() const
virtual SGVector< float64_t > get_subfeature_weights()
virtual EFeatureClass get_feature_class() const
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:50
CDotFeatures * get_feature_obj(int32_t idx)
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
virtual int32_t get_nnz_features_for_vector(int32_t num)
EFeatureType
shogun feature type
Definition: FeatureTypes.h:19
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
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)

SHOGUN Machine Learning Toolbox - Documentation