DotFeatures.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _DOTFEATURES_H___
00012 #define _DOTFEATURES_H___
00013
00014 #include "lib/common.h"
00015 #include "features/Features.h"
00016
00036 class CDotFeatures : public CFeatures
00037 {
00038 public:
00039
00044 CDotFeatures(int32_t size=0) : CFeatures(size), combined_weight(1.0)
00045 {
00046 set_property(FP_DOT);
00047 }
00048
00050 CDotFeatures(const CDotFeatures & orig) :
00051 CFeatures(orig), combined_weight(orig.combined_weight) {}
00052
00057 CDotFeatures(char* fname) : CFeatures(fname) {}
00058
00059 virtual ~CDotFeatures() { }
00060
00068 virtual int32_t get_dim_feature_space()=0;
00069
00076 virtual float64_t dot(int32_t vec_idx1, int32_t vec_idx2)=0;
00077
00084 virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len)=0;
00085
00094 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;
00095
00107 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);
00108
00109
00112 static void* dense_dot_range_helper(void* p);
00113
00121 virtual int32_t get_nnz_features_for_vector(int32_t num)=0;
00122
00127 inline float64_t get_combined_feature_weight() { return combined_weight; }
00128
00133 inline void set_combined_feature_weight(float64_t nw) { combined_weight=nw; }
00134
00142 virtual void get_feature_matrix(float64_t** dst, int32_t* num_feat, int32_t* num_vec);
00143
00144 protected:
00151 inline void display_progress(int32_t start, int32_t stop, int32_t v)
00152 {
00153 int32_t num_vectors=stop-start;
00154 int32_t i=v-start;
00155
00156 if ( (i% (num_vectors/100+1))== 0)
00157 SG_PROGRESS(v, 0.0, num_vectors-1);
00158 }
00159 protected:
00160
00162 float64_t combined_weight;
00163 };
00164 #endif // _DOTFEATURES_H___