BinnedDotFeatures.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  * Copyright (C) 2012 Soeren Sonnenburg
00008  */
00009 
00010 #ifndef _BINNED_DOTFEATURES_H___
00011 #define _BINNED_DOTFEATURES_H___
00012 
00013 #include <shogun/lib/common.h>
00014 #include <shogun/features/DotFeatures.h>
00015 #include <shogun/features/DenseFeatures.h>
00016 
00017 namespace shogun
00018 {
00019     template <class T> class CDenseFeatures;
00020 
00041 class CBinnedDotFeatures : public CDotFeatures
00042 {
00043     public:
00048         CBinnedDotFeatures(int32_t size=0);
00049 
00051         CBinnedDotFeatures(const CBinnedDotFeatures & orig);
00052 
00059         CBinnedDotFeatures(CDenseFeatures<float64_t>* sf, SGMatrix<float64_t> bins);
00060 
00061         virtual ~CBinnedDotFeatures();
00062 
00070         virtual int32_t get_dim_feature_space() const;
00071 
00079         virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
00080 
00087         virtual float64_t dense_dot(int32_t vec_idx1, const float64_t* vec2, int32_t vec2_len);
00088 
00097         virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1, float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00098 
00106         virtual int32_t get_nnz_features_for_vector(int32_t num);
00107 
00117         virtual void* get_feature_iterator(int32_t vector_index);
00118 
00129         virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
00130 
00136         virtual void free_feature_iterator(void* iterator);
00137 
00138 
00143         bool get_fill();
00144 
00149         void set_fill(bool fill);
00150 
00155         bool get_norm_one();
00156 
00161         void set_norm_one(bool norm_one);
00162 
00167         void set_simple_features(CDenseFeatures<float64_t>* features);
00168 
00173         CDenseFeatures<float64_t>* get_simple_features();
00174 
00184         void set_bins(SGMatrix<float64_t> bins);
00185 
00190         SGMatrix<float64_t> get_bins();
00191 
00195         virtual const char* get_name() const;
00196 
00201         virtual CFeatures* duplicate() const;
00202 
00207         virtual EFeatureType get_feature_type() const;
00208 
00213         virtual EFeatureClass get_feature_class() const;
00214 
00219         virtual int32_t get_num_vectors() const;
00220 
00225         virtual int32_t get_size() const;
00226 
00227     private:
00228         void init();
00229 
00234         void assert_shape(int32_t vec2_len);
00235 
00236     protected:
00238         CDenseFeatures<float64_t>* m_features;
00239 
00241         SGMatrix<float64_t> m_bins;
00242 
00244         bool m_fill;
00245 
00247         bool m_norm_one;
00248 };
00249 }
00250 #endif // _BINNED_DOTFEATURES_H___
00251 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation