source: trunk/yat/normalization/ColumnNormalizer.h @ 1490

Last change on this file since 1490 was 1487, checked in by Jari Häkkinen, 15 years ago

Addresses #436. GPL license copy reference should also be updated.

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