fix doc example typo
[boost.git] / boost / accumulators / statistics / rolling_mean.hpp
blob59146d7013c28b199e78f6d745cc01ae2677be27
1 ///////////////////////////////////////////////////////////////////////////////
2 // rolling_mean.hpp
3 //
4 // Copyright 2008 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_ACCUMULATORS_STATISTICS_ROLLING_MEAN_HPP_EAN_26_12_2008
9 #define BOOST_ACCUMULATORS_STATISTICS_ROLLING_MEAN_HPP_EAN_26_12_2008
11 #include <boost/mpl/placeholders.hpp>
12 #include <boost/accumulators/framework/accumulator_base.hpp>
13 #include <boost/accumulators/framework/extractor.hpp>
14 #include <boost/accumulators/numeric/functional.hpp>
15 #include <boost/accumulators/framework/parameters/sample.hpp>
16 #include <boost/accumulators/framework/depends_on.hpp>
17 #include <boost/accumulators/statistics_fwd.hpp>
18 #include <boost/accumulators/statistics/rolling_sum.hpp>
19 #include <boost/accumulators/statistics/rolling_count.hpp>
21 namespace boost { namespace accumulators
24 namespace impl
27 ///////////////////////////////////////////////////////////////////////////////
28 // rolling_mean_impl
29 // returns the unshifted results from the shifted rolling window
30 template<typename Sample>
31 struct rolling_mean_impl
32 : accumulator_base
34 typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
36 rolling_mean_impl(dont_care)
39 template<typename Args>
40 result_type result(Args const &args) const
42 return numeric::average(rolling_sum(args), rolling_count(args));
46 } // namespace impl
48 ///////////////////////////////////////////////////////////////////////////////
49 // tag::rolling_mean
51 namespace tag
53 struct rolling_mean
54 : depends_on< rolling_sum, rolling_count >
56 /// INTERNAL ONLY
57 ///
58 typedef accumulators::impl::rolling_mean_impl< mpl::_1 > impl;
60 #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
61 /// tag::rolling_window::window_size named parameter
62 static boost::parameter::keyword<tag::rolling_window_size> const window_size;
63 #endif
65 } // namespace tag
67 ///////////////////////////////////////////////////////////////////////////////
68 // extract::rolling_mean
70 namespace extract
72 extractor<tag::rolling_mean> const rolling_mean = {};
75 using extract::rolling_mean;
77 }} // namespace boost::accumulators
79 #endif