00001 #ifndef _theplu_yat_utility_matrix_weighted_ 00002 #define _theplu_yat_utility_matrix_weighted_ 00003 00004 // $Id: MatrixWeighted.h 1921 2009-04-24 20:01:35Z jari $ 00005 00006 /* 00007 Copyright (C) 2003 Daniel Dalevi, Peter Johansson 00008 Copyright (C) 2004 Jari Häkkinen, Peter Johansson 00009 Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér 00010 Copyright (C) 2007, 2008, 2009 Jari Häkkinen, Peter Johansson 00011 00012 This file is part of the yat library, http://dev.thep.lu.se/yat 00013 00014 The yat library is free software; you can redistribute it and/or 00015 modify it under the terms of the GNU General Public License as 00016 published by the Free Software Foundation; either version 3 of the 00017 License, or (at your option) any later version. 00018 00019 The yat library is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with yat. If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 00028 #include "DataWeight.h" 00029 #include "StrideIterator.h" 00030 00031 #include <vector> 00032 00033 namespace theplu { 00034 namespace yat { 00035 namespace utility { 00036 00037 class Matrix; 00038 00044 class MatrixWeighted 00045 { 00046 public: 00050 typedef DataWeight value_type; 00051 00055 typedef DataWeight& reference; 00056 00060 typedef const DataWeight& const_reference; 00061 00065 typedef std::vector<DataWeight>::iterator iterator; 00066 00070 typedef std::vector<DataWeight>::const_iterator const_iterator; 00071 00075 typedef StrideIterator<std::vector<DataWeight>::iterator> column_iterator; 00076 00080 typedef StrideIterator<std::vector<DataWeight>::const_iterator> 00081 const_column_iterator; 00082 00086 typedef column_iterator row_iterator; 00087 00091 typedef const_column_iterator const_row_iterator; 00092 00098 MatrixWeighted(void); 00099 00107 MatrixWeighted(size_t r, size_t c, double init_value=0, 00108 double init_weight=1.0); 00109 00113 MatrixWeighted(const MatrixWeighted&); 00114 00115 00123 explicit MatrixWeighted(const Matrix& other); 00124 00137 explicit MatrixWeighted(std::istream &, char sep='\0'); 00138 00145 iterator begin(void); 00146 00153 const_iterator begin(void) const; 00154 00160 column_iterator begin_column(size_t i); 00161 00167 const_column_iterator begin_column(size_t i) const; 00168 00174 row_iterator begin_row(size_t i); 00175 00181 const_row_iterator begin_row(size_t i) const; 00182 00186 size_t columns(void) const; 00187 00191 iterator end(void); 00192 00196 const_iterator end(void) const; 00197 00201 column_iterator end_column(size_t i); 00202 00206 const_column_iterator end_column(size_t i) const; 00207 00211 row_iterator end_row(size_t i); 00212 00216 const_row_iterator end_row(size_t i) const; 00217 00225 void resize(size_t rows, size_t columns); 00226 00230 size_t rows(void) const; 00231 00238 void swap(MatrixWeighted& other); 00239 00245 DataWeight& operator()(size_t row,size_t column); 00246 00253 const DataWeight& operator()(size_t row,size_t column) const; 00254 00255 00261 const MatrixWeighted& operator=(const MatrixWeighted& other); 00262 00263 private: 00264 void copy(const Matrix&); 00265 00266 std::vector<DataWeight> vec_; 00267 size_t columns_; 00268 00269 }; 00270 00278 void swap(MatrixWeighted&, MatrixWeighted&); 00279 00280 }}} // of namespace utility, yat, and theplu 00281 00282 #endif