Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _EXPLICITSPECFEATURES_H___
00012 #define _EXPLICITSPECFEATURES_H___
00013
00014 #include <shogun/lib/common.h>
00015 #include <shogun/io/SGIO.h>
00016 #include <shogun/features/DotFeatures.h>
00017 #include <shogun/features/StringFeatures.h>
00018
00019 namespace shogun
00020 {
00021 template <class ST> class CStringFeatures;
00022
00027 class CExplicitSpecFeatures : public CDotFeatures
00028 {
00029 public:
00031 CExplicitSpecFeatures(void);
00032
00038 CExplicitSpecFeatures(CStringFeatures<uint16_t>* str, bool normalize=true);
00039
00041 CExplicitSpecFeatures(const CExplicitSpecFeatures & orig);
00042
00044 virtual ~CExplicitSpecFeatures();
00045
00050 virtual CFeatures* duplicate() const;
00051
00059 inline virtual int32_t get_dim_feature_space() const
00060 {
00061 return spec_size;
00062 }
00063
00071 virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
00072
00079 virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
00080
00089 virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00090
00091 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00092
00093 struct explicit_spec_feature_iterator
00094 {
00096 uint16_t* vec;
00098 int32_t vidx;
00100 int32_t vlen;
00102 bool vfree;
00103
00105 int32_t index;
00106
00107 };
00108 #endif
00109
00119 virtual void* get_feature_iterator(int32_t vector_index)
00120 {
00121 SG_NOTIMPLEMENTED;
00122 return NULL;
00123 }
00124
00135 virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator)
00136 {
00137 SG_NOTIMPLEMENTED;
00138 return NULL;
00139 }
00140
00146 virtual void free_feature_iterator(void* iterator)
00147 {
00148 SG_NOTIMPLEMENTED;
00149 }
00150
00156 virtual inline int32_t get_nnz_features_for_vector(int32_t num)
00157 {
00158 SG_NOTIMPLEMENTED;
00159 return 0;
00160 }
00161
00166 inline virtual EFeatureType get_feature_type()
00167 {
00168 return F_UNKNOWN;
00169 }
00170
00175 inline virtual EFeatureClass get_feature_class()
00176 {
00177 return C_SPEC;
00178 }
00179
00184 inline virtual int32_t get_num_vectors() const
00185 {
00186 return num_strings;
00187 }
00188
00193 inline virtual int32_t get_size()
00194 {
00195 return sizeof(float64_t);
00196 }
00197
00199 inline virtual const char* get_name() const { return "ExplicitSpecFeatures"; }
00200
00201 protected:
00206 void obtain_kmer_spectrum(CStringFeatures<uint16_t>* str);
00207
00209 void delete_kmer_spectrum();
00210
00211 protected:
00213 bool use_normalization;
00215 int32_t num_strings;
00217 int32_t alphabet_size;
00218
00220 int32_t spec_size;
00222 float64_t** k_spectrum;
00223 };
00224 }
00225 #endif // _EXPLICITSPECFEATURES_H___