DotFeatures.h

Go to the documentation of this file.
00001 /*
00002  * This program is free software; you can redistribute it and/or modify
00003  * it under the terms of the GNU General Public License as published by
00004  * the Free Software Foundation; either version 3 of the License, or
00005  * (at your option) any later version.
00006  *
00007  * Written (W) 2009-2010 Soeren Sonnenburg
00008  * Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  * Copyright (C) 2010 Berlin Institute of Technology
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 
00086         virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len)=0;
00087 
00096         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;
00097 
00111         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);
00112 
00124         virtual void dense_dot_range_subset(int32_t* sub_index, int32_t num,
00125                 float64_t* output, float64_t* alphas, float64_t* vec, int32_t dim, float64_t b);
00126 
00129         static void* dense_dot_range_helper(void* p);
00130 
00138         virtual int32_t get_nnz_features_for_vector(int32_t num)=0;
00139 
00144         inline float64_t get_combined_feature_weight() { return combined_weight; }
00145 
00150         inline void set_combined_feature_weight(float64_t nw) { combined_weight=nw; }
00151 
00156         SGMatrix<float64_t> get_computed_dot_feature_matrix();
00157 
00162         SGVector<float64_t> get_computed_dot_feature_vector(int32_t num);
00163 
00165         void benchmark_add_to_dense_vector(int32_t repeats=5);
00166 
00168         void benchmark_dense_dot_range(int32_t repeats=5);
00169 
00179         virtual void* get_feature_iterator(int32_t vector_index)=0;
00180 
00191         virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator)=0;
00192 
00198         virtual void free_feature_iterator(void* iterator)=0;
00199 
00204         virtual SGVector<float64_t> get_mean();
00205 
00210         virtual SGMatrix<float64_t> get_cov();
00211 
00212     protected:
00219         void display_progress(int32_t start, int32_t stop, int32_t v);
00220 
00221     private:
00222         void init();
00223 
00224     protected:
00225 
00227         float64_t combined_weight;
00228 };
00229 }
00230 #endif // _DOTFEATURES_H___
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation