00001 #ifndef _theplu_yat_normalizer_row_normalizer_
00002 #define _theplu_yat_normalizer_rows_normalizer_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "yat/utility/yat_assert.h"
00027
00028 #include <cstddef>
00029 #include <stdexcept>
00030
00031 namespace theplu {
00032 namespace yat {
00033 namespace normalizer {
00034
00052 template<class T>
00053 class RowNormalizer
00054 {
00055 public:
00059 typedef T normalizer_type;
00060
00064 RowNormalizer(void) {}
00065
00069 RowNormalizer(T norm)
00070 : normalizer_(norm) {}
00071
00083 template<class Container2D1, class Container2D2>
00084 void operator()(const Container2D1& matrix,
00085 Container2D2& result) const
00086 {
00087 using utility::yat_assert;
00088 yat_assert<std::runtime_error>(matrix.rows()==result.rows(),
00089 "RowNormalizer: rows mismatch");
00090 yat_assert<std::runtime_error>(matrix.columns()==result.columns(),
00091 "RowNormalizer: columns mismatch");
00092 for (size_t i=0; i<matrix.rows(); ++i)
00093 normalizer_(matrix.begin_row(i), matrix.end_row(i),
00094 result.begin_row(i));
00095 }
00096
00097 private:
00098 T normalizer_;
00099 };
00100
00101 }}}
00102 #endif