Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62319 - in sandbox/statistics/support/boost/accumulators/statistics: . detail
From: erwann.rogard_at_[hidden]
Date: 2010-05-30 12:10:48


Author: e_r
Date: 2010-05-30 12:10:48 EDT (Sun, 30 May 2010)
New Revision: 62319
URL: http://svn.boost.org/trac/boost/changeset/62319

Log:
m
Added:
   sandbox/statistics/support/boost/accumulators/statistics/
   sandbox/statistics/support/boost/accumulators/statistics/detail/
   sandbox/statistics/support/boost/accumulators/statistics/detail/weighted_count.hpp (contents, props changed)

Added: sandbox/statistics/support/boost/accumulators/statistics/detail/weighted_count.hpp
==============================================================================
--- (empty file)
+++ sandbox/statistics/support/boost/accumulators/statistics/detail/weighted_count.hpp 2010-05-30 12:10:48 EDT (Sun, 30 May 2010)
@@ -0,0 +1,111 @@
+///////////////////////////////////////////////////////////////////////////////
+// factor.hpp //
+// //
+// Copyright 2010 Erwann Rogard. Distributed under the Boost //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_ACCUMULATORS_STATISTICS_DETAIL_WEIGHTED_COUNT_HPP_ER_2010
+#define BOOST_ACCUMULATORS_STATISTICS_DETAIL_WEIGHTED_COUNT_HPP_ER_2010
+
+#include <boost/mpl/placeholders.hpp>
+#include <boost/accumulators/framework/accumulator_base.hpp>
+#include <boost/accumulators/framework/extractor.hpp>
+#include <boost/accumulators/numeric/functional.hpp>
+#include <boost/accumulators/framework/parameters/sample.hpp>
+#include <boost/accumulators/framework/parameters/weight.hpp>
+#include <boost/accumulators/framework/accumulators/external_accumulator.hpp>
+#include <boost/accumulators/framework/depends_on.hpp>
+#include <boost/accumulators/statistics_fwd.hpp>
+
+namespace boost { namespace accumulators
+{
+
+namespace impl
+{
+ ///////////////////////////////////////////////////////////////////////////////
+ // weighted_count_impl
+ template<typename Weight>
+ struct weighted_count_impl
+ : accumulator_base
+ {
+ typedef Weight weighted_sample;
+
+ // for boost::result_of
+ typedef weighted_sample result_type;
+
+ template<typename Args>
+ weighted_count_impl(Args const &args)
+ : weighted_count_(
+ numeric::zero<Weight>::value
+ )
+ {
+ }
+
+ template<typename Args>
+ void operator ()(Args const &args)
+ {
+ // what about overflow?
+ this->weighted_count_ += args[ weight ];
+ }
+
+ result_type result(dont_care) const
+ {
+ return this->weighted_count_;
+ }
+
+ private:
+
+ weighted_sample weighted_count_;
+ };
+
+} // namespace impl
+
+namespace tag
+{
+ struct weighted_count
+ : depends_on<>
+ {
+ typedef accumulators::impl::weighted_count_impl<mpl::_2> impl;
+ };
+
+/*
+ template<typename VariateType, typename VariateTag>
+ struct weighted_count_of_variates
+ : depends_on<>
+ {
+ /// INTERNAL ONLY
+ ///
+ typedef accumulators::impl::weighted_count_impl<VariateType, mpl::_2, VariateTag> impl;
+ };
+
+ struct abstract_weighted_count_of_variates
+ : depends_on<>
+ {
+ };
+*/
+}
+
+namespace extract
+{
+ extractor<tag::weighted_count> const weighted_count = {};
+// extractor<tag::abstract_weighted_count_of_variates> const weighted_count_of_variates = {};
+
+ BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_count)
+// BOOST_ACCUMULATORS_IGNORE_GLOBAL(weighted_count_of_variates)
+}
+
+using extract::weighted_count;
+//using extract::weighted_count_of_variates;
+
+/*
+template<typename VariateType, typename VariateTag>
+struct feature_of<tag::weighted_count_of_variates<VariateType, VariateTag> >
+ : feature_of<tag::abstract_weighted_count_of_variates>
+{
+};
+*/
+
+}} // namespace boost::accumulators
+
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk