yat  0.12.3pre
Centralizer.h
1 #ifndef _theplu_yat_normalizer_centralizer_
2 #define _theplu_yat_normalizer_centralizer_
3 
4 // $Id: Centralizer.h 2415 2011-01-22 06:01:31Z peter $
5 
6 /*
7  Copyright (C) 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010, 2011 Peter Johansson
9 
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11 
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16 
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24 */
25 
26 #include "utility.h"
27 
28 #include "yat/statistics/Average.h"
29 #include "yat/utility/DataIterator.h"
30 #include "yat/utility/iterator_traits.h"
31 #include "yat/utility/WeightIterator.h"
32 
33 #include <boost/concept_check.hpp>
34 
35 #include <algorithm>
36 #include <functional>
37 
38 namespace theplu {
39 namespace yat {
40 namespace normalizer {
41 
63  template<class UnaryFunction = statistics::Average>
65  {
66  public:
73  Centralizer(void){}
74 
78  Centralizer(const UnaryFunction& uf)
79  : func_(uf) {}
80 
97  template<class InputIterator, class ForwardIterator>
98  void operator()(InputIterator first, InputIterator last,
99  ForwardIterator result) const
100  {
101  BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>));
102  BOOST_CONCEPT_ASSERT((boost::Mutable_ForwardIterator<ForwardIterator>));
103  // copy weight if result is weighted
104  detail::copy_weight_if_weighted(first, last, result);
105  std::transform(utility::data_iterator(first),
106  utility::data_iterator(last),
107  utility::data_iterator(result),
108  std::bind2nd(std::minus<double>(),func_(first, last)));
109  }
110 
111  private:
112  UnaryFunction func_;
113  };
114 
115 }}} // end of namespace normalizer, yat and thep
116 #endif
Centralize a range.
Definition: Centralizer.h:64
Centralizer(void)
default constructor
Definition: Centralizer.h:73
Centralizer(const UnaryFunction &uf)
Definition: Centralizer.h:78
void operator()(InputIterator first, InputIterator last, ForwardIterator result) const
Definition: Centralizer.h:98

Generated on Mon Jun 1 2015 12:29:51 for yat by  doxygen 1.8.5