00001 #ifndef _theplu_yat_normalizer_centralizer_
00002 #define _theplu_yat_normalizer_centralizer_
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 "utility.h"
00027
00028 #include "yat/statistics/Average.h"
00029 #include "yat/utility/DataIterator.h"
00030 #include "yat/utility/iterator_traits.h"
00031 #include "yat/utility/WeightIterator.h"
00032
00033 #include <boost/concept_check.hpp>
00034
00035 #include <algorithm>
00036 #include <functional>
00037
00038 namespace theplu {
00039 namespace yat {
00040 namespace normalizer {
00041
00056 template<class UnaryFunction = statistics::Average>
00057 class Centralizer
00058 {
00059 public:
00066 Centralizer(void){}
00067
00071 Centralizer(const UnaryFunction& uf)
00072 : func_(uf) {}
00073
00086 template<class InputIterator, class ForwardIterator>
00087 void operator()(InputIterator first, InputIterator last,
00088 ForwardIterator result) const
00089 {
00090 BOOST_CONCEPT_ASSERT((boost::InputIterator<InputIterator>));
00091 BOOST_CONCEPT_ASSERT((boost::Mutable_ForwardIterator<ForwardIterator>));
00092
00093 detail::copy_weight_if_weighted(first, last, result);
00094 std::transform(utility::data_iterator(first),
00095 utility::data_iterator(last),
00096 utility::data_iterator(result),
00097 std::bind2nd(std::minus<double>(),func_(first, last)));
00098 }
00099
00100 private:
00101 UnaryFunction func_;
00102 };
00103
00104 }}}
00105 #endif