yat
0.8.3pre
|
00001 #ifndef _theplu_yat_normalizer_row_normalizer_ 00002 #define _theplu_yat_normalizer_rows_normalizer_ 00003 00004 // $Id: RowNormalizer.h 2384 2010-12-22 14:03:36Z peter $ 00005 00006 /* 00007 Copyright (C) 2008 Jari Häkkinen, Peter Johansson 00008 Copyright (C) 2009, 2010 Peter Johansson 00009 00010 This file is part of the yat library, http://dev.thep.lu.se/yat 00011 00012 The yat library is free software; you can redistribute it and/or 00013 modify it under the terms of the GNU General Public License as 00014 published by the Free Software Foundation; either version 3 of the 00015 License, or (at your option) any later version. 00016 00017 The yat library is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 General Public License for more details. 00021 00022 You should have received a copy of the GNU General Public License 00023 along with yat. If not, see <http://www.gnu.org/licenses/>. 00024 */ 00025 00026 #include "yat/utility/yat_assert.h" 00027 #include "yat/utility/concept_check.h" 00028 00029 #include <boost/concept_check.hpp> 00030 00031 #include <cstddef> 00032 #include <stdexcept> 00033 00034 namespace theplu { 00035 namespace yat { 00036 namespace normalizer { 00037 00055 template<class T> 00056 class RowNormalizer 00057 { 00058 public: 00062 typedef T normalizer_type; 00063 00067 RowNormalizer(void) {} 00068 00072 RowNormalizer(T norm) 00073 : normalizer_(norm) {} 00074 00086 template<class Container2D1, class Container2D2> 00087 void operator()(const Container2D1& matrix, 00088 Container2D2& result) const 00089 { 00090 BOOST_CONCEPT_ASSERT((utility::Container2D<Container2D1>)); 00091 BOOST_CONCEPT_ASSERT((utility::Mutable_Container2D<Container2D2>)); 00092 using utility::yat_assert; 00093 YAT_ASSERT(matrix.rows()==result.rows()); 00094 YAT_ASSERT(matrix.columns()==result.columns()); 00095 for (size_t i=0; i<matrix.rows(); ++i) 00096 normalizer_(matrix.begin_row(i), matrix.end_row(i), 00097 result.begin_row(i)); 00098 } 00099 00100 private: 00101 T normalizer_; 00102 }; 00103 00104 }}} // end of namespace normalizer, yat and thep 00105 #endif