yat
0.8.3pre
|
00001 #ifndef _theplu_yat_classifier_matrix_lookup_weighted_ 00002 #define _theplu_yat_classifier_matrix_lookup_weighted_ 00003 00004 // $Id: MatrixLookupWeighted.h 2374 2010-12-12 07:23:27Z peter $ 00005 00006 /* 00007 Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér 00008 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 00009 Copyright (C) 2009, 2010 Peter Johansson 00010 00011 This file is part of the yat library, http://dev.thep.lu.se/yat 00012 00013 The yat library is free software; you can redistribute it and/or 00014 modify it under the terms of the GNU General Public License as 00015 published by the Free Software Foundation; either version 3 of the 00016 License, or (at your option) any later version. 00017 00018 The yat library is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00021 General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with yat. If not, see <http://www.gnu.org/licenses/>. 00025 */ 00026 00027 #include "yat/utility/Container2DIterator.h" 00028 #include "yat/utility/DataWeight.h" 00029 #include "yat/utility/deprecate.h" 00030 #include "yat/utility/Index.h" 00031 #include "yat/utility/MatrixWeighted.h" 00032 #include "yat/utility/SmartPtr.h" 00033 #include "yat/utility/StrideIterator.h" 00034 00035 #include <boost/iterator/permutation_iterator.hpp> 00036 00037 #include <iosfwd> 00038 #include <utility> 00039 #include <vector> 00040 00041 namespace theplu { 00042 namespace yat { 00043 namespace classifier { 00044 00045 class MatrixLookup; 00046 00063 class MatrixLookupWeighted 00064 { 00065 public: 00071 typedef utility::DataWeight value_type; 00072 00078 typedef const utility::DataWeight& const_reference; 00079 00081 typedef utility::StrideIterator< 00082 utility::Container2DIterator<const MatrixLookupWeighted, 00083 const value_type, const_reference> > 00084 const_iterator; 00085 00089 typedef boost::permutation_iterator< 00090 utility::MatrixWeighted::const_column_iterator, 00091 utility::Index::const_iterator> const_column_iterator; 00092 00096 typedef boost::permutation_iterator< 00097 utility::MatrixWeighted::const_row_iterator, 00098 utility::Index::const_iterator> const_row_iterator; 00099 00106 MatrixLookupWeighted(const utility::MatrixWeighted& matrix, 00107 const utility::Index& rows, 00108 const utility::Index& columns); 00109 00113 explicit MatrixLookupWeighted(const utility::MatrixWeighted& matrix, 00114 bool owner=false); 00115 00125 explicit MatrixLookupWeighted(const MatrixLookup& matrix); 00126 00127 00138 MatrixLookupWeighted(const MatrixLookupWeighted& other); 00139 00159 MatrixLookupWeighted(const MatrixLookupWeighted& ml, 00160 const utility::Index& row, 00161 const utility::Index& column); 00162 00189 MatrixLookupWeighted(const MatrixLookupWeighted& ml, 00190 const utility::Index&, 00191 const bool row_vectors) YAT_DEPRECATE; 00192 00198 MatrixLookupWeighted(const size_t rows, const size_t columns, 00199 const double value=0, const double weight=1); 00200 00210 MatrixLookupWeighted(std::istream&, char sep='\0'); 00211 00216 virtual ~MatrixLookupWeighted(); 00217 00224 const_iterator begin(void) const; 00225 00231 const_column_iterator begin_column(size_t) const; 00232 00238 const_row_iterator begin_row(size_t) const; 00239 00243 size_t columns(void) const; 00244 00248 double data(size_t row, size_t column) const; 00249 00253 const_iterator end(void) const; 00254 00258 const_column_iterator end_column(size_t) const; 00259 00263 const_row_iterator end_row(size_t) const; 00264 00268 size_t rows(void) const; 00269 00273 double weight(size_t row, size_t column) const; 00274 00278 bool weighted(void) const; 00279 00285 const_reference operator()(const size_t row, const size_t column) const; 00286 00295 const MatrixLookupWeighted& operator=(const MatrixLookupWeighted&); 00296 00297 private: 00298 typedef utility::SmartPtr<const utility::MatrixWeighted> MatrixWP; 00299 utility::Index column_index_; 00300 MatrixWP data_; 00301 utility::Index row_index_; 00302 00303 // for assertions 00304 bool validate(void) const; 00305 }; 00306 00315 std::ostream& operator<< (std::ostream& s, const MatrixLookupWeighted&); 00316 00317 }}} // of namespace classifier, yat, and theplu 00318 00319 #endif