yat  0.8.3pre
MatrixWeighted.h
00001 #ifndef _theplu_yat_utility_matrix_weighted_
00002 #define _theplu_yat_utility_matrix_weighted_
00003 
00004 // $Id: MatrixWeighted.h 2119 2009-12-12 23:11:43Z peter $
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 
00109     MatrixWeighted(size_t r, size_t c, double init_value=0,
00110                    double init_weight=1.0);
00111 
00115     MatrixWeighted(const MatrixWeighted&);
00116 
00117     
00125     explicit MatrixWeighted(const Matrix& other);
00126 
00139     explicit MatrixWeighted(std::istream &, char sep='\0'); 
00140 
00147     iterator begin(void);
00148 
00155     const_iterator begin(void) const;
00156 
00162     column_iterator begin_column(size_t i);
00163 
00169     const_column_iterator begin_column(size_t i) const;
00170 
00176     row_iterator begin_row(size_t i);
00177 
00183     const_row_iterator begin_row(size_t i) const;
00184 
00188     size_t columns(void) const;
00189 
00193     iterator end(void);
00194 
00198     const_iterator end(void) const;
00199 
00203     column_iterator end_column(size_t i);
00204 
00208     const_column_iterator end_column(size_t i) const;
00209 
00213     row_iterator end_row(size_t i);
00214 
00218     const_row_iterator end_row(size_t i) const;
00219 
00229     void resize(size_t rows, size_t columns);
00230 
00234     size_t rows(void) const;
00235 
00242     void swap(MatrixWeighted& other);
00243 
00249     DataWeight& operator()(size_t row,size_t column);
00250 
00257     const DataWeight& operator()(size_t row,size_t column) const;
00258 
00259 
00265     const MatrixWeighted& operator=(const MatrixWeighted& other);
00266 
00267   private:
00268     void copy(const Matrix&);
00269 
00270     std::vector<DataWeight> vec_;
00271     size_t columns_;
00272 
00273   };
00274 
00284   void swap(MatrixWeighted&, MatrixWeighted&);
00285 
00286 }}} // of namespace utility, yat, and theplu
00287 
00288 #endif

Generated on Thu Dec 20 2012 03:12:58 for yat by  doxygen 1.8.0-20120409