SHOGUN
v3.2.0
|
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) 2012 Fernando José Iglesias García 00008 * Copyright (C) 2012 Fernando José Iglesias García 00009 */ 00010 00011 #ifndef _MATRIX_FEATURES__H__ 00012 #define _MATRIX_FEATURES__H__ 00013 00014 #include <shogun/features/Features.h> 00015 #include <shogun/lib/SGMatrixList.h> 00016 00017 00018 namespace shogun 00019 { 00020 00029 template< class ST > class CMatrixFeatures : public CFeatures 00030 { 00031 public: 00033 CMatrixFeatures(); 00034 00040 CMatrixFeatures(int32_t num_vecs, int32_t num_feats = 0); 00041 00047 CMatrixFeatures(SGMatrixList< ST > feats, int32_t num_feats = 0); 00048 00060 CMatrixFeatures(SGMatrix< ST > feats, int32_t feat_length, int32_t num_vecs); 00061 00066 virtual CFeatures* duplicate() const; 00067 00069 virtual ~CMatrixFeatures(); 00070 00075 virtual EFeatureType get_feature_type() const; 00076 00081 virtual EFeatureClass get_feature_class() const; 00082 00089 virtual int32_t get_num_vectors() const { return m_num_vectors; } 00090 00097 SGMatrix< ST > get_feature_vector(int32_t num) const; 00098 00105 void get_feature_vector_col(SGVector< ST > out, int32_t num, int32_t col) const; 00106 00112 void set_feature_vector(SGMatrix< ST > const vec, int32_t num); 00113 00118 inline SGMatrixList< ST > get_features() const { return m_features; } 00119 00125 void set_features(SGMatrixList< ST > features, int32_t num_feats); 00126 00128 virtual const char* get_name() const { return "MatrixFeatures"; } 00129 00131 inline int32_t get_num_features() const { return m_num_features; } 00132 00136 static CMatrixFeatures* obtain_from_generic(CFeatures* const base_features); 00137 00138 private: 00140 void init(); 00141 00143 void cleanup(); 00144 00145 private: 00147 int32_t m_num_vectors; 00148 00150 int32_t m_num_features; 00151 00153 SGMatrixList< ST > m_features; 00154 00155 }; /* class CMatrixFeatures */ 00156 00157 } /* namespace shogun */ 00158 00159 #endif /* _MATRIX_FEATURES__H__ */