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-2010 Soeren Sonnenburg
00008  * Copyright (C) 2009 Fraunhofer Institute FIRST and Max-Planck-Society
00009  * Copyright (C) 2010 Berlin Institute of Technology
00010  */
00011 
00012 #ifndef _WDFEATURES_H___
00013 #define _WDFEATURES_H___
00014 
00015 #include <shogun/lib/common.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 
00028 class CWDFeatures : public CDotFeatures
00029 {
00030     public:
00032         CWDFeatures();
00033 
00040         CWDFeatures(CStringFeatures<uint8_t>* str, int32_t order, int32_t from_order);
00041 
00043         CWDFeatures(const CWDFeatures & orig);
00044 
00046         virtual ~CWDFeatures();
00047 
00055         virtual int32_t get_dim_feature_space() const;
00056 
00064         virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
00065 
00072         virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
00073 
00082         virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
00083                 float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00084 
00090         virtual int32_t get_nnz_features_for_vector(int32_t num);
00091 
00092         #ifndef DOXYGEN_SHOULD_SKIP_THIS
00093 
00094         struct wd_feature_iterator
00095         {
00097             uint8_t* vec;
00099             int32_t vidx;
00101             int32_t vlen;
00103             bool vfree;
00104 
00109             int32_t lim;
00110             int32_t* val;
00111             int32_t asize;
00112             int32_t asizem1;
00113             int32_t offs;
00114             int32_t k;
00115             int32_t i;
00116             int32_t o;
00118         };
00119         #endif
00120 
00130         virtual void* get_feature_iterator(int32_t vector_index);
00131 
00142         virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
00143 
00149         virtual void free_feature_iterator(void* iterator);
00150 
00155         virtual CFeatures* duplicate() const;
00156 
00161         virtual EFeatureType get_feature_type() const;
00162 
00167         virtual EFeatureClass get_feature_class() const;
00168 
00169         virtual int32_t get_num_vectors() const;
00170 
00171         virtual int32_t get_size() const;
00172 
00175         void set_normalization_const(float64_t n=0);
00176 
00178         float64_t get_normalization_const();
00179 
00181         virtual const char* get_name() const { return "WDFeatures"; }
00182 
00187         void set_wd_weights(SGVector<float64_t> weights);
00188 
00190         void set_wd_weights();
00191 
00192     protected:
00194         CStringFeatures<uint8_t>* strings;
00195 
00197         int32_t degree;
00199         int32_t from_degree;
00201         int32_t string_length;
00203         int32_t num_strings;
00205         int32_t alphabet_size;
00207         int32_t w_dim;
00209         float64_t* wd_weights;
00210 
00212         float64_t normalization_const;
00213 
00214 };
00215 }
00216 #endif // _WDFEATURES_H___
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation