ExplicitSpecFeatures.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 _EXPLICITSPECFEATURES_H___
00012 #define _EXPLICITSPECFEATURES_H___
00013 
00014 #include "lib/common.h"
00015 #include "lib/io.h"
00016 #include "features/DotFeatures.h"
00017 #include "features/StringFeatures.h"
00018 
00019 template <class ST> class CStringFeatures;
00020 
00025 class CExplicitSpecFeatures : public CDotFeatures
00026 {
00027     public:
00028 
00034         CExplicitSpecFeatures(CStringFeatures<uint16_t>* str, bool normalize=true);
00035 
00037         CExplicitSpecFeatures(const CExplicitSpecFeatures & orig);
00038 
00040         virtual ~CExplicitSpecFeatures();
00041 
00046         virtual CFeatures* duplicate() const;
00047 
00055         inline virtual int32_t get_dim_feature_space()
00056         {
00057             return spec_size;
00058         }
00059 
00066         virtual float64_t dot(int32_t vec_idx1, int32_t vec_idx2);
00067 
00074         virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
00075 
00084         virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00085 
00091         virtual inline int32_t get_nnz_features_for_vector(int32_t num)
00092         {
00093             SG_NOTIMPLEMENTED;
00094             return 0;
00095         }
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_SPEC;
00113         }
00114 
00119         inline virtual int32_t get_num_vectors()
00120         {
00121             return num_strings;
00122         }
00123 
00128         inline virtual int32_t get_size()
00129         {
00130             return sizeof(float64_t);
00131         }
00132 
00134         inline virtual const char* get_name() const { return "ExplicitSpecFeatures"; }
00135 
00136     protected:
00141         void obtain_kmer_spectrum(CStringFeatures<uint16_t>* str);
00142 
00144         void delete_kmer_spectrum();
00145 
00146     protected:
00148         bool use_normalization;
00150         int32_t num_strings;
00152         int32_t alphabet_size;
00153 
00155         int32_t spec_size;
00157         float64_t** k_spectrum;
00158 };
00159 #endif // _EXPLICITSPECFEATURES_H___

SHOGUN Machine Learning Toolbox - Documentation