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 00095 virtual int32_t get_size() const; 00096 00103 SGMatrix< ST > get_feature_vector(int32_t num) const; 00104 00111 void get_feature_vector_col(SGVector< ST > out, int32_t num, int32_t col) const; 00112 00118 void set_feature_vector(SGMatrix< ST > const & vec, int32_t num); 00119 00124 inline SGMatrixList< ST > get_features() const { return m_features; } 00125 00131 void set_features(SGMatrixList< ST > features, int32_t num_feats); 00132 00134 virtual const char* get_name() const { return "MatrixFeatures"; } 00135 00137 inline int32_t get_num_features() const { return m_num_features; } 00138 00139 private: 00141 void init(); 00142 00144 void cleanup(); 00145 00146 private: 00148 int32_t m_num_vectors; 00149 00151 int32_t m_num_features; 00152 00154 SGMatrixList< ST > m_features; 00155 00156 }; /* class CMatrixFeatures */ 00157 00158 } /* namespace shogun */ 00159 00160 #endif /* _MATRIX_FEATURES__H__ */