SHOGUN  v3.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CombinedDotFeatures.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 
00013 #ifndef _COMBINEDDOTFEATURES_H___
00014 #define _COMBINEDDOTFEATURES_H___
00015 
00016 #include <shogun/lib/common.h>
00017 #include <shogun/lib/DynamicObjectArray.h>
00018 #include <shogun/features/DotFeatures.h>
00019 
00020 namespace shogun
00021 {
00022 class CFeatures;
00023 class CDynamicObjectArray;
00043 class CCombinedDotFeatures : public CDotFeatures
00044 {
00045     public:
00047         CCombinedDotFeatures();
00048 
00050         CCombinedDotFeatures(const CCombinedDotFeatures & orig);
00051 
00053         virtual ~CCombinedDotFeatures();
00054 
00059         virtual int32_t get_num_vectors() const
00060         {
00061             return num_vectors;
00062         }
00063 
00068         virtual int32_t get_dim_feature_space() const
00069         {
00070             return  num_dimensions;
00071         }
00072 
00080         virtual float64_t dot(int32_t vec_idx1, CDotFeatures* df, int32_t vec_idx2);
00081 
00088         virtual float64_t dense_dot(int32_t vec_idx1, float64_t* vec2, int32_t vec2_len);
00089 
00101         virtual void dense_dot_range(float64_t* output, int32_t start,
00102                 int32_t stop, float64_t* alphas, float64_t* vec,
00103                 int32_t dim, float64_t b);
00104 
00116         virtual void dense_dot_range_subset(int32_t* sub_index, int32_t num,
00117                 float64_t* output, float64_t* alphas, float64_t* vec,
00118                 int32_t dim, float64_t b);
00119 
00128         virtual void add_to_dense_vec(float64_t alpha, int32_t vec_idx1,
00129                 float64_t* vec2, int32_t vec2_len, bool abs_val=false);
00130 
00136         virtual int32_t get_nnz_features_for_vector(int32_t num);
00137 
00142         virtual EFeatureType get_feature_type() const
00143         {
00144             return F_DREAL;
00145         }
00146 
00151         virtual EFeatureClass get_feature_class() const
00152         {
00153             return C_COMBINED_DOT;
00154         }
00155 
00156         #ifndef DOXYGEN_SHOULD_SKIP_THIS
00157 
00158         struct combined_feature_iterator
00159         {
00161             CDotFeatures* f;
00163             void* iterator;
00165             int32_t vector_index;
00166         };
00167         #endif
00168 
00178         virtual void* get_feature_iterator(int32_t vector_index);
00179 
00190         virtual bool get_next_feature(int32_t& index, float64_t& value, void* iterator);
00191 
00197         virtual void free_feature_iterator(void* iterator);
00198 
00203         virtual CFeatures* duplicate() const;
00204 
00206         void list_feature_objs();
00207 
00213         CDotFeatures* get_feature_obj(int32_t idx);
00214 
00222         bool insert_feature_obj(CDotFeatures* obj, int32_t idx);
00223 
00229         bool append_feature_obj(CDotFeatures* obj);
00230 
00236         bool delete_feature_obj(int32_t idx);
00237 
00242         int32_t get_num_feature_obj();
00243 
00247         virtual SGVector<float64_t> get_subfeature_weights();
00248 
00253         virtual void set_subfeature_weights(SGVector<float64_t> weights);
00254 
00256         virtual const char* get_name() const { return "CombinedDotFeatures"; }
00257 
00258     protected:
00260         void update_dim_feature_space_and_num_vec();
00261 
00262     private:
00263         void init();
00264 
00265     protected:
00267         CDynamicObjectArray* feature_array;
00268 
00270         int32_t iterator_idx;
00272         int32_t num_vectors;
00274         int32_t num_dimensions;
00275 };
00276 }
00277 #endif // _DOTFEATURES_H___
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation