SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparsePolyFeatures.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) 2010 Soeren Sonnenburg
8  * Copyright (C) 2010 Berlin Institute of Technology
9  */
10 #ifndef _SPARSEPOLYFEATURES__H__
11 #define _SPARSEPOLYFEATURES__H__
12 
13 #include <shogun/lib/common.h>
16 
17 namespace shogun
18 {
25 {
26  public:
29 
38  CSparsePolyFeatures(CSparseFeatures<float64_t>* feat, int32_t degree, bool normalize, int32_t hash_bits);
39 
40  virtual ~CSparsePolyFeatures();
41 
49 
54  virtual int32_t get_dim_feature_space() const;
55 
61  virtual int32_t get_nnz_features_for_vector(int32_t num);
62 
67  virtual EFeatureType get_feature_type() const;
68 
73  virtual EFeatureClass get_feature_class() const;
74 
79  virtual int32_t get_num_vectors() const;
80 
88  virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
89 
90  #ifndef DOXYGEN_SHOULD_SKIP_THIS
91 
92  struct sparse_poly_feature_iterator
93  {
95  uint16_t* vec;
97  int32_t vidx;
99  int32_t vlen;
101  bool vfree;
102 
104  int32_t index;
105  };
106  #endif
107 
117  virtual void* get_feature_iterator(int32_t vector_index);
118 
129  bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
130 
136  void free_feature_iterator(void* iterator);
137 
142  CFeatures* duplicate() const;
143 
148  virtual const char* get_name() const { return "SparsePolyFeatures"; }
149 
157  virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
158 
167  virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
168 
169  protected:
172 
173  protected:
177  int32_t m_degree;
187  uint32_t mask;
189  int32_t m_hash_bits;
190  private:
192  void init();
193 
194  private:
196  int32_t m_normalization_values_len;
197 };
198 }
199 #endif // _SPARSEPOLYFEATURES__H__

SHOGUN Machine Learning Toolbox - Documentation