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

Last change on this file since 1462 was 1462, checked in by Peter, 15 years ago

adding ColumnNormalizer?

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 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 2 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 this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22  02111-1307, USA.
23*/
24
25namespace theplu {
26namespace yat {
27namespace utility {
28  class Matrix;
29}
30namespace normalization {
31
32  /**
33     \brief Normalize each column
34
35     Using a functor T to normalize each column.
36
37     \since New in yat 0.5
38   */
39  template<class T>
40  class ColumnNormalizer
41  {
42  public:
43    /**
44       functor used to normalize each column
45    */
46    typedef T normalizer_type
47
48    /**
49       \brief Default constructor
50     */
51    ColumnNormalizer(void) {}
52
53    /**
54       \brief Constructor taking a functor \a norm
55     */
56    ColumnNormalizer(T norm) 
57      : normalizer_(norm) {}
58
59    /**
60       Each column in \a result is normalized using class T.
61
62       \note matrix is ignored
63     */
64    void operator()(const utility::Matrix& matrix, 
65                    utility::Matrix& result) const;
66  private:
67    T normalizer_;
68  };
69
70  template<class T>
71  void ColumnNormalizer<T>::operator()(const utility::Matrix& matrix, 
72                                       utility::Matrix& result) const
73  {
74    for (size_t i=0; i<matrix.rows(); ++i)
75      normalizer_(result.begin_const_column(i), result.end_const_columns(i),
76                  result.begin_column(i));
77
78  }
79
80
81}}} // end of namespace normalization, yat and thep
82#endif
Note: See TracBrowser for help on using the repository browser.