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 namespace shogun
00020 {
00021 template <class ST> class CStringFeatures;
00022 
00027 class CExplicitSpecFeatures : public CDotFeatures
00028 {
00029     public:
00030 
00036         CExplicitSpecFeatures(CStringFeatures<uint16_t>* str, bool normalize=true);
00037 
00039         CExplicitSpecFeatures(const CExplicitSpecFeatures & orig);
00040 
00042         virtual ~CExplicitSpecFeatures();
00043 
00048         virtual CFeatures* duplicate() const;
00049 
00057         inline virtual int32_t get_dim_feature_space()
00058         {
00059             return spec_size;
00060         }
00061 
00068         virtual float64_t dot(int32_t vec_idx1, int32_t vec_idx2);
00069 
00076         virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
00077 
00086         virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00087 
00089         struct explicit_spec_feature_iterator
00090         {
00092             uint16_t* vec;
00094             int32_t vidx;
00096             int32_t vlen;
00098             bool vfree;
00099 
00101             int32_t index;
00102 
00103         };
00104 
00114         virtual void* get_feature_iterator(int32_t vector_index)
00115         {
00116             SG_NOTIMPLEMENTED;
00117             return NULL;
00118         }
00119 
00130         virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator)
00131         {
00132             SG_NOTIMPLEMENTED;
00133             return NULL;
00134         }
00135 
00141         virtual void free_feature_iterator(void* iterator)
00142         {
00143             SG_NOTIMPLEMENTED;
00144         }
00145 
00151         virtual inline int32_t get_nnz_features_for_vector(int32_t num)
00152         {
00153             SG_NOTIMPLEMENTED;
00154             return 0;
00155         }
00156 
00161         inline virtual EFeatureType get_feature_type()
00162         {
00163             return F_UNKNOWN;
00164         }
00165 
00170         inline virtual EFeatureClass get_feature_class()
00171         {
00172             return C_SPEC;
00173         }
00174 
00179         inline virtual int32_t get_num_vectors()
00180         {
00181             return num_strings;
00182         }
00183 
00188         inline virtual int32_t get_size()
00189         {
00190             return sizeof(float64_t);
00191         }
00192 
00194         inline virtual const char* get_name() const { return "ExplicitSpecFeatures"; }
00195 
00196     protected:
00201         void obtain_kmer_spectrum(CStringFeatures<uint16_t>* str);
00202 
00204         void delete_kmer_spectrum();
00205 
00206     protected:
00208         bool use_normalization;
00210         int32_t num_strings;
00212         int32_t alphabet_size;
00213 
00215         int32_t spec_size;
00217         float64_t** k_spectrum;
00218 };
00219 }
00220 #endif // _EXPLICITSPECFEATURES_H___
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation