WDFeatures.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 Soeren Sonnenburg
00008  * Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  */
00010 
00011 #ifndef _WDFEATURES_H___
00012 #define _WDFEATURES_H___
00013 
00014 #include "lib/common.h"
00015 #include "features/DotFeatures.h"
00016 #include "features/StringFeatures.h"
00017 
00018 template <class ST> class CStringFeatures;
00019 
00025 class CWDFeatures : public CDotFeatures
00026 {
00027     public:
00028 
00035         CWDFeatures(CStringFeatures<uint8_t>* str, int32_t order, int32_t from_order);
00036 
00038         CWDFeatures(const CWDFeatures & orig);
00039 
00041         virtual ~CWDFeatures();
00042 
00050         inline virtual int32_t get_dim_feature_space()
00051         {
00052             return w_dim;
00053         }
00054 
00061         virtual float64_t dot(int32_t vec_idx1, int32_t vec_idx2);
00062 
00069         virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
00070 
00079         virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00080 
00086         virtual inline int32_t get_nnz_features_for_vector(int32_t num)
00087         {
00088             return w_dim/alphabet_size;
00089         }
00090 
00095         virtual CFeatures* duplicate() const;
00096 
00101         inline virtual EFeatureType get_feature_type()
00102         {
00103             return F_UNKNOWN;
00104         }
00105 
00110         inline virtual EFeatureClass get_feature_class()
00111         {
00112             return C_WD;
00113         }
00114 
00115         inline virtual int32_t get_num_vectors()
00116         {
00117             return num_strings;
00118         }
00119 
00120         inline virtual int32_t get_size()
00121         {
00122             return sizeof(float64_t);
00123         }
00124 
00126         inline virtual const char* get_name() const { return "WDFeatures"; }
00127 
00128     protected:
00130         void set_normalization_const();
00131 
00133         void set_wd_weights();
00134 
00135     protected:
00136         CStringFeatures<uint8_t>* strings;
00137 
00139         float64_t normalization_const;
00140 
00142         int32_t degree;
00144         int32_t from_degree;
00146         int32_t string_length;
00148         int32_t num_strings;
00150         int32_t alphabet_size;
00152         int32_t w_dim;
00154         float64_t* wd_weights;
00155 };
00156 #endif // _WDFEATURES_H___

SHOGUN Machine Learning Toolbox - Documentation