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 __SGMATRIX_LIST_H__ 00012 #define __SGMATRIX_LIST_H__ 00013 00014 #include <shogun/lib/SGReferencedData.h> 00015 #include <shogun/lib/SGMatrix.h> 00016 00017 namespace shogun 00018 { 00019 00021 template<class T> class SGMatrixList : public SGReferencedData 00022 { 00023 public: 00025 SGMatrixList(); 00026 00028 SGMatrixList(SGMatrix<T>* ml, int32_t nmats, bool ref_counting = true); 00029 00031 SGMatrixList(int32_t nmats, bool ref_counting = true); 00032 00034 SGMatrixList(SGMatrixList const & orig); 00035 00037 virtual ~SGMatrixList(); 00038 00046 inline SGMatrix<T>& get_matrix(index_t index) const 00047 { 00048 return matrix_list[index]; 00049 } 00050 00058 inline SGMatrix<T>& operator[](index_t index) const 00059 { 00060 return matrix_list[index]; 00061 } 00062 00073 static SGMatrixList<T> split(SGMatrix<T> matrix, int32_t num_components); 00074 00075 protected: 00077 virtual void copy_data(SGReferencedData const & orig); 00078 00080 virtual void init_data(); 00081 00083 virtual void free_data(); 00084 00085 private: 00087 void cleanup_matrices(); 00088 00089 public: 00091 SGMatrix<T>* matrix_list; 00092 00094 int32_t num_matrices; 00095 00096 }; /* class SGMatrixList */ 00097 00098 } /* namespace shogun */ 00099 00100 #endif /* define __SGMATRIX_LIST_H__ */