Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _DOTFEATURES_H___
00013 #define _DOTFEATURES_H___
00014
00015 #include <shogun/lib/common.h>
00016 #include <shogun/features/Features.h>
00017
00018 namespace shogun
00019 {
00041 class CDotFeatures : public CFeatures
00042 {
00043 public:
00044
00049 CDotFeatures(int32_t size=0);
00050
00052 CDotFeatures(const CDotFeatures & orig);
00053
00058 CDotFeatures(CFile* loader);
00059
00060 virtual ~CDotFeatures() { }
00061
00069 virtual int32_t get_dim_feature_space() const=0;
00070
00078 virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2)=0;
00079
00085 virtual float64_t dense_dot_sgvec(int32_t vec_idx1, const SGVector<float64_t> vec2);
00086
00093 virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len)=0;
00094
00103 virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false)=0;
00104
00118 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);
00119
00131 virtual void dense_dot_range_subset(int32_t* sub_index, int32_t num,
00132 float64_t* output, float64_t* alphas, float64_t* vec, int32_t dim, float64_t b);
00133
00136 static void* dense_dot_range_helper(void* p);
00137
00145 virtual int32_t get_nnz_features_for_vector(int32_t num)=0;
00146
00151 inline float64_t get_combined_feature_weight() { return combined_weight; }
00152
00157 inline void set_combined_feature_weight(float64_t nw) { combined_weight=nw; }
00158
00163 SGMatrix<float64_t> get_computed_dot_feature_matrix();
00164
00169 SGVector<float64_t> get_computed_dot_feature_vector(int32_t num);
00170
00172 void benchmark_add_to_dense_vector(int32_t repeats=5);
00173
00175 void benchmark_dense_dot_range(int32_t repeats=5);
00176
00186 virtual void* get_feature_iterator(int32_t vector_index)=0;
00187
00198 virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator)=0;
00199
00205 virtual void free_feature_iterator(void* iterator)=0;
00206
00211 virtual SGVector<float64_t> get_mean();
00212
00217 static SGVector<float64_t> get_mean(CDotFeatures* lhs, CDotFeatures* rhs);
00218
00223 virtual SGMatrix<float64_t> get_cov();
00224
00229 static SGMatrix<float64_t> compute_cov(CDotFeatures* lhs, CDotFeatures* rhs);
00230
00231 protected:
00238 void display_progress(int32_t start, int32_t stop, int32_t v);
00239
00240 private:
00241 void init();
00242
00243 protected:
00244
00246 float64_t combined_weight;
00247 };
00248 }
00249 #endif // _DOTFEATURES_H___