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 namespace shogun
00019 {
00020 template <class ST> class CStringFeatures;
00021 
00027 class CWDFeatures : public CDotFeatures
00028 {
00029     public:
00030 
00037         CWDFeatures(CStringFeatures<uint8_t>* str, int32_t order, int32_t from_order);
00038 
00040         CWDFeatures(const CWDFeatures & orig);
00041 
00043         virtual ~CWDFeatures();
00044 
00052         inline virtual int32_t get_dim_feature_space()
00053         {
00054             return w_dim;
00055         }
00056 
00063         virtual float64_t dot(int32_t vec_idx1, int32_t vec_idx2);
00064 
00071         virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
00072 
00081         virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00082 
00088         virtual inline int32_t get_nnz_features_for_vector(int32_t num)
00089         {
00090             return w_dim/alphabet_size;
00091         }
00092 
00097         virtual CFeatures* duplicate() const;
00098 
00103         inline virtual EFeatureType get_feature_type()
00104         {
00105             return F_UNKNOWN;
00106         }
00107 
00112         inline virtual EFeatureClass get_feature_class()
00113         {
00114             return C_WD;
00115         }
00116 
00117         inline virtual int32_t get_num_vectors()
00118         {
00119             return num_strings;
00120         }
00121 
00122         inline virtual int32_t get_size()
00123         {
00124             return sizeof(float64_t);
00125         }
00126 
00128         inline virtual const char* get_name() const { return "WDFeatures"; }
00129 
00130     protected:
00132         void set_normalization_const();
00133 
00135         void set_wd_weights();
00136 
00137     protected:
00139         CStringFeatures<uint8_t>* strings;
00140 
00142         float64_t normalization_const;
00143 
00145         int32_t degree;
00147         int32_t from_degree;
00149         int32_t string_length;
00151         int32_t num_strings;
00153         int32_t alphabet_size;
00155         int32_t w_dim;
00157         float64_t* wd_weights;
00158 };
00159 }
00160 #endif // _WDFEATURES_H___

SHOGUN Machine Learning Toolbox - Documentation