yat  0.8.3pre
MatrixLookup.h
00001 #ifndef _theplu_yat_classifier_matrix_lookup_ 
00002 #define _theplu_yat_classifier_matrix_lookup_ 
00003 
00004 // $Id: MatrixLookup.h 2374 2010-12-12 07:23:27Z peter $
00005 
00006 /*
00007   Copyright (C) 2005 Peter Johansson, Markus Ringnér
00008   Copyright (C) 2006 Jari Häkkinen, Peter Johansson, Markus Ringnér
00009   Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
00010   Copyright (C) 2009, 2010 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 "yat/utility/Container2DIterator.h"
00029 #include "yat/utility/deprecate.h"
00030 #include "yat/utility/Index.h"
00031 #include "yat/utility/iterator_traits.h"
00032 #include "yat/utility/Matrix.h"
00033 #include "yat/utility/SmartPtr.h"
00034 
00035 #include <boost/iterator/permutation_iterator.hpp>
00036 
00037 #include <iosfwd>
00038 #include <vector>
00039 
00040 namespace theplu {
00041 namespace yat {
00042 namespace classifier {  
00043 
00070   class MatrixLookup
00071   {
00072   public:
00078     typedef utility::Matrix::value_type value_type;
00079 
00085     typedef utility::Matrix::const_reference const_reference;
00086 
00088     typedef utility::Container2DIterator<const MatrixLookup, const double, 
00089                                          const_reference>
00090     const_iterator;
00091 
00095     typedef boost::permutation_iterator<utility::Matrix::const_column_iterator,
00096                                         utility::Index::const_iterator> 
00097     const_column_iterator;
00098 
00102     typedef const_column_iterator const_row_iterator;
00103 
00118     MatrixLookup(const utility::Matrix& matrix, const bool own=false);
00119 
00133     MatrixLookup(const utility::Matrix& matrix, const utility::Index& row, 
00134                  const utility::Index& column);
00135 
00157     MatrixLookup(const utility::Matrix& matrix, 
00158                  const utility::Index& index, 
00159                  const bool row_vectors) YAT_DEPRECATE;
00160 
00171     MatrixLookup(const MatrixLookup& other);
00172 
00197     MatrixLookup(const MatrixLookup& ml, const utility::Index& row, 
00198                  const utility::Index& column);
00199 
00226     MatrixLookup(const MatrixLookup& ml, const utility::Index&, 
00227                  const bool row_vectors);
00228 
00234     MatrixLookup(const size_t rows, const size_t columns, const double value=0);
00235 
00246     MatrixLookup(std::istream&, char sep='\0');
00247 
00254     virtual ~MatrixLookup();
00255 
00262     const_iterator begin(void) const;
00263 
00269     const_column_iterator begin_column(size_t) const;
00270 
00276     const_row_iterator begin_row(size_t) const;
00277 
00281     size_t columns(void) const;
00282 
00286     const_iterator end(void) const;
00287 
00291     const_column_iterator end_column(size_t) const;
00292 
00296     const_row_iterator end_row(size_t) const;
00297 
00301     size_t rows(void) const;
00302 
00306     bool weighted(void) const;
00307 
00313     const_reference operator()(size_t row, size_t column) const;
00314 
00323     const MatrixLookup& operator=(const MatrixLookup&);
00324     
00325   private:
00326     friend class MatrixLookupWeighted;
00327 
00328     utility::Index column_index_;
00329     typedef utility::SmartPtr<const utility::Matrix> MatrixP;
00330     MatrixP data_;
00331     utility::Index row_index_;
00332 
00333     // for assertions
00334     bool validate(void) const;
00335   };  
00336   
00342   std::ostream& operator<< (std::ostream& s, const MatrixLookup&);
00343 
00344 }}} // of namespace classifier, yat, and theplu
00345 
00346 #endif

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