source: trunk/yat/normalizer/ColumnNormalizer.h @ 1575

Last change on this file since 1575 was 1575, checked in by Jari Häkkinen, 13 years ago

Added missing $ tag.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1#ifndef _theplu_yat_normalizer_column_normalizer_
2#define _theplu_yat_normalizer_column_normalizer_
3
4// $Id: ColumnNormalizer.h 1575 2008-10-14 07:19:48Z jari $
5
6/*
7  Copyright (C) 2008 Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "yat/utility/Matrix.h"
26#include "yat/utility/yat_assert.h"
27
28#include <stdexcept>
29
30namespace theplu {
31namespace yat {
32namespace normalizer {
33
34  /**
35     \brief Normalize each column
36
37     Using a functor T to normalize each column.
38
39     \since New in yat 0.5
40   */
41  template<class T>
42  class ColumnNormalizer
43  {
44  public:
45    /**
46       functor used to normalize each column
47    */
48    typedef T normalizer_type;
49
50    /**
51       \brief Default constructor
52     */
53    ColumnNormalizer(void) {}
54
55    /**
56       \brief Constructor taking a functor \a norm
57     */
58    ColumnNormalizer(T norm) 
59      : normalizer_(norm) {}
60
61    /**
62       Each column in \a matrix is normalized using class T, and
63       assigned to Matrix \a result.
64
65       Template argument Container2D1 should be a class modelling the
66       concept \ref concept_container_2d. The template argument
67       Container2D2 should be a class modelling the concept \ref
68       concept_mutable_container_2d.
69
70       \note \a result must have same dimensions as \a matrix.
71     */
72    template<class Container2D1, class Container2D2>
73    void operator()(const Container2D1& matrix, Container2D2& result) const
74    {
75      using utility::yat_assert;
76      yat_assert<std::runtime_error>(matrix.rows()==result.rows(),
77                                     "ColumnNormalizer: rows mismatch");
78      yat_assert<std::runtime_error>(matrix.columns()==result.columns(),
79                                     "ColumnNormalizer: columns mismatch");
80      for (size_t i=0; i<matrix.columns(); ++i)
81        normalizer_(matrix.begin_column(i), matrix.end_column(i),
82                    result.begin_column(i));
83     
84    }
85
86  private:
87    T normalizer_;
88  };
89
90}}} // end of namespace normalizer, yat and thep
91#endif
Note: See TracBrowser for help on using the repository browser.