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 "lib/common.h"
00015 #include "lib/io.h"
00016 #include "features/DotFeatures.h"
00017 #include "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()
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
00092 struct explicit_spec_feature_iterator
00093 {
00095 uint16_t* vec;
00097 int32_t vidx;
00099 int32_t vlen;
00101 bool vfree;
00102
00104 int32_t index;
00105
00106 };
00107
00117 virtual void* get_feature_iterator(int32_t vector_index)
00118 {
00119 SG_NOTIMPLEMENTED;
00120 return NULL;
00121 }
00122
00133 virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator)
00134 {
00135 SG_NOTIMPLEMENTED;
00136 return NULL;
00137 }
00138
00144 virtual void free_feature_iterator(void* iterator)
00145 {
00146 SG_NOTIMPLEMENTED;
00147 }
00148
00154 virtual inline int32_t get_nnz_features_for_vector(int32_t num)
00155 {
00156 SG_NOTIMPLEMENTED;
00157 return 0;
00158 }
00159
00164 inline virtual EFeatureType get_feature_type()
00165 {
00166 return F_UNKNOWN;
00167 }
00168
00173 inline virtual EFeatureClass get_feature_class()
00174 {
00175 return C_SPEC;
00176 }
00177
00182 inline virtual int32_t get_num_vectors()
00183 {
00184 return num_strings;
00185 }
00186
00191 inline virtual int32_t get_size()
00192 {
00193 return sizeof(float64_t);
00194 }
00195
00197 inline virtual const char* get_name() const { return "ExplicitSpecFeatures"; }
00198
00199 protected:
00204 void obtain_kmer_spectrum(CStringFeatures<uint16_t>* str);
00205
00207 void delete_kmer_spectrum();
00208
00209 protected:
00211 bool use_normalization;
00213 int32_t num_strings;
00215 int32_t alphabet_size;
00216
00218 int32_t spec_size;
00220 float64_t** k_spectrum;
00221 };
00222 }
00223 #endif // _EXPLICITSPECFEATURES_H___