summaryrefslogtreecommitdiff
path: root/boost/accumulators
diff options
context:
space:
mode:
Diffstat (limited to 'boost/accumulators')
-rw-r--r--boost/accumulators/accumulators_fwd.hpp66
-rw-r--r--boost/accumulators/framework/accumulator_set.hpp229
-rw-r--r--boost/accumulators/framework/accumulators/external_accumulator.hpp2
-rw-r--r--boost/accumulators/framework/accumulators/reference_accumulator.hpp2
-rw-r--r--boost/accumulators/framework/accumulators/value_accumulator.hpp2
-rw-r--r--boost/accumulators/framework/depends_on.hpp9
-rw-r--r--boost/accumulators/framework/extractor.hpp31
-rw-r--r--boost/accumulators/framework/parameters/accumulator.hpp4
-rw-r--r--boost/accumulators/framework/parameters/sample.hpp4
-rw-r--r--boost/accumulators/framework/parameters/weight.hpp4
-rw-r--r--boost/accumulators/framework/parameters/weights.hpp4
-rw-r--r--boost/accumulators/statistics/count.hpp7
-rw-r--r--boost/accumulators/statistics/covariance.hpp7
-rw-r--r--boost/accumulators/statistics/density.hpp16
-rw-r--r--boost/accumulators/statistics/extended_p_square.hpp14
-rw-r--r--boost/accumulators/statistics/extended_p_square_quantile.hpp11
-rw-r--r--boost/accumulators/statistics/kurtosis.hpp4
-rw-r--r--boost/accumulators/statistics/max.hpp7
-rw-r--r--boost/accumulators/statistics/mean.hpp10
-rw-r--r--boost/accumulators/statistics/median.hpp23
-rw-r--r--boost/accumulators/statistics/min.hpp7
-rw-r--r--boost/accumulators/statistics/moment.hpp7
-rw-r--r--boost/accumulators/statistics/p_square_cumul_dist.hpp16
-rw-r--r--boost/accumulators/statistics/p_square_quantile.hpp42
-rw-r--r--boost/accumulators/statistics/peaks_over_threshold.hpp29
-rw-r--r--boost/accumulators/statistics/pot_quantile.hpp7
-rw-r--r--boost/accumulators/statistics/pot_tail_mean.hpp8
-rw-r--r--boost/accumulators/statistics/rolling_count.hpp4
-rw-r--r--boost/accumulators/statistics/rolling_mean.hpp23
-rw-r--r--boost/accumulators/statistics/rolling_moment.hpp7
-rw-r--r--boost/accumulators/statistics/rolling_sum.hpp7
-rw-r--r--boost/accumulators/statistics/rolling_variance.hpp12
-rw-r--r--boost/accumulators/statistics/rolling_window.hpp49
-rw-r--r--boost/accumulators/statistics/skewness.hpp4
-rw-r--r--boost/accumulators/statistics/sum.hpp7
-rw-r--r--boost/accumulators/statistics/sum_kahan.hpp8
-rw-r--r--boost/accumulators/statistics/tail.hpp11
-rw-r--r--boost/accumulators/statistics/tail_mean.hpp8
-rw-r--r--boost/accumulators/statistics/tail_quantile.hpp4
-rw-r--r--boost/accumulators/statistics/tail_variate.hpp9
-rw-r--r--boost/accumulators/statistics/tail_variate_means.hpp8
-rw-r--r--boost/accumulators/statistics/variance.hpp11
-rw-r--r--boost/accumulators/statistics/weighted_covariance.hpp7
-rw-r--r--boost/accumulators/statistics/weighted_density.hpp16
-rw-r--r--boost/accumulators/statistics/weighted_extended_p_square.hpp12
-rw-r--r--boost/accumulators/statistics/weighted_mean.hpp7
-rw-r--r--boost/accumulators/statistics/weighted_median.hpp18
-rw-r--r--boost/accumulators/statistics/weighted_moment.hpp7
-rw-r--r--boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp13
-rw-r--r--boost/accumulators/statistics/weighted_p_square_quantile.hpp11
-rw-r--r--boost/accumulators/statistics/weighted_peaks_over_threshold.hpp13
-rw-r--r--boost/accumulators/statistics/weighted_sum.hpp7
-rw-r--r--boost/accumulators/statistics/weighted_sum_kahan.hpp8
-rw-r--r--boost/accumulators/statistics/weighted_tail_variate_means.hpp7
-rw-r--r--boost/accumulators/statistics/weighted_variance.hpp7
55 files changed, 766 insertions, 111 deletions
diff --git a/boost/accumulators/accumulators_fwd.hpp b/boost/accumulators/accumulators_fwd.hpp
index 4c0370e21e..fabc4e8406 100644
--- a/boost/accumulators/accumulators_fwd.hpp
+++ b/boost/accumulators/accumulators_fwd.hpp
@@ -9,6 +9,8 @@
#define BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005
#include <boost/config.hpp>
+#include <boost/core/enable_if.hpp>
+#include <boost/parameter/is_argument_pack.hpp>
#include <boost/mpl/apply_fwd.hpp> // for mpl::na
#include <boost/mpl/limits/vector.hpp>
#include <boost/preprocessor/cat.hpp>
@@ -41,7 +43,6 @@
#endif
#ifdef BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS
-# include <boost/utility/enable_if.hpp>
# include <boost/type_traits/is_const.hpp>
# define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T)\
, typename boost::disable_if<boost::is_const<T> >::type * = 0
@@ -128,9 +129,12 @@ template<typename Feature, typename AccumulatorSet>
typename mpl::apply<AccumulatorSet, Feature>::type::result_type
extract_result(AccumulatorSet const &acc);
-template<typename Feature, typename AccumulatorSet, typename A1>
-typename mpl::apply<AccumulatorSet, Feature>::type::result_type
-extract_result(AccumulatorSet const &acc, A1 const &a1);
+namespace detail
+{
+ struct _enabler
+ {
+ };
+}
// ... other overloads generated by Boost.Preprocessor:
@@ -146,17 +150,37 @@ extract_result(AccumulatorSet const &acc, A1 const &a1);
extract_result( \
AccumulatorSet const &acc \
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
+ , typename boost::enable_if< \
+ parameter::is_argument_pack<A0> \
+ , detail::_enabler \
+ >::type = detail::_enabler() \
+ ); \
+ template< \
+ typename Feature \
+ , typename AccumulatorSet \
+ BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
+ > \
+ typename mpl::apply<AccumulatorSet, Feature>::type::result_type \
+ extract_result( \
+ AccumulatorSet const &acc \
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
+ , typename boost::disable_if< \
+ parameter::is_argument_pack<A0> \
+ , detail::_enabler \
+ >::type = detail::_enabler() \
);
/// INTERNAL ONLY
///
BOOST_PP_REPEAT_FROM_TO(
- 2
+ 1
, BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
, BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD
, _
)
+#undef BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD
+
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
template<typename Feature, typename AccumulatorSet, typename A1, typename A2 ...>
typename mpl::apply<AccumulatorSet, Feature>::type::result_type
@@ -185,6 +209,9 @@ namespace detail
struct is_accumulator_set;
inline void ignore_variable(void const *) {}
+}
+
+}} // namespace boost::accumulators
#define BOOST_ACCUMULATORS_IGNORE_GLOBAL(X) \
namespace detail \
@@ -198,33 +225,8 @@ namespace detail
}; \
} \
/**/
-}
-}} // namespace boost::accumulators
+#include <boost/parameter/nested_keyword.hpp>
-// For defining boost::parameter keywords that can be inherited from to
-// get a nested, class-scoped keyword with the requested alias
-#define BOOST_PARAMETER_NESTED_KEYWORD(tag_namespace, name, alias) \
- namespace tag_namespace \
- { \
- template<int Dummy = 0> \
- struct name ## _ \
- { \
- static char const* keyword_name() \
- { \
- return #name; \
- } \
- static ::boost::parameter::keyword<name ## _<Dummy> > &alias; \
- }; \
- template<int Dummy> \
- ::boost::parameter::keyword<name ## _<Dummy> > &name ## _<Dummy>::alias = \
- ::boost::parameter::keyword<name ## _<Dummy> >::get(); \
- typedef name ## _ <> name; \
- } \
- namespace \
- { \
- ::boost::parameter::keyword<tag_namespace::name> &name = \
- ::boost::parameter::keyword<tag_namespace::name>::get(); \
- }
+#endif // include guard
-#endif
diff --git a/boost/accumulators/framework/accumulator_set.hpp b/boost/accumulators/framework/accumulator_set.hpp
index ed1ceb1afa..0b4f4ad3dc 100644
--- a/boost/accumulators/framework/accumulator_set.hpp
+++ b/boost/accumulators/framework/accumulator_set.hpp
@@ -9,16 +9,23 @@
#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005
#include <boost/version.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/protect.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/type_traits/is_same.hpp>
-#include <boost/type_traits/is_base_and_derived.hpp>
-#include <boost/parameter/parameters.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/core/enable_if.hpp>
+#include <boost/parameter/is_argument_pack.hpp>
#include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
+#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/depends_on.hpp>
#include <boost/accumulators/framework/accumulator_concept.hpp>
@@ -64,14 +71,6 @@ namespace detail
return accumulator_visitor<Args>(args);
}
- typedef
- parameter::parameters<
- parameter::required<tag::accumulator>
- , parameter::optional<tag::sample>
- // ... and others which are not specified here...
- >
- accumulator_params;
-
///////////////////////////////////////////////////////////////////////////////
// accumulator_set_base
struct accumulator_set_base
@@ -82,10 +81,38 @@ namespace detail
// is_accumulator_set
template<typename T>
struct is_accumulator_set
- : is_base_and_derived<accumulator_set_base, T>
+ : mpl::if_<
+ boost::is_base_of<
+ accumulator_set_base
+ , typename boost::remove_const<
+ typename boost::remove_reference<T>::type
+ >::type
+ >
+ , mpl::true_
+ , mpl::false_
+ >::type
{
};
+ // function object that serialize an accumulator
+ template<typename Archive>
+ struct serialize_accumulator
+ {
+ serialize_accumulator(Archive & _ar, const unsigned int _file_version) :
+ ar(_ar), file_version(_file_version)
+ {}
+
+ template<typename Accumulator>
+ void operator ()(Accumulator &accumulator)
+ {
+ accumulator.serialize(ar, file_version);
+ }
+
+ private:
+ Archive& ar;
+ const unsigned int file_version;
+ };
+
} // namespace detail
#ifdef _MSC_VER
@@ -140,13 +167,13 @@ struct accumulator_set
: accumulators(
detail::make_acc_list(
accumulators_mpl_vector()
- , detail::accumulator_params()(*this)
+ , (boost::accumulators::accumulator = *this)
)
)
{
// Add-ref the Features that the user has specified
this->template visit_if<detail::contains_feature_of_<Features> >(
- detail::make_add_ref_visitor(detail::accumulator_params()(*this))
+ detail::make_add_ref_visitor(boost::accumulators::accumulator = *this)
);
}
@@ -154,17 +181,48 @@ struct accumulator_set
///
/// \param a1 Optional named parameter to be passed to all the accumulators
template<typename A1>
- explicit accumulator_set(A1 const &a1)
- : accumulators(
+ explicit accumulator_set(
+ A1 const &a1
+ , typename boost::enable_if<
+ parameter::is_argument_pack<A1>
+ , detail::_enabler
+ >::type = detail::_enabler()
+ ) : accumulators(
+ detail::make_acc_list(
+ accumulators_mpl_vector()
+ , (boost::accumulators::accumulator = *this, a1)
+ )
+ )
+ {
+ // Add-ref the Features that the user has specified
+ this->template visit_if<detail::contains_feature_of_<Features> >(
+ detail::make_add_ref_visitor(boost::accumulators::accumulator = *this)
+ );
+ }
+
+ /// \overload
+ ///
+ /// \param a1 Optional sample parameter to be passed to all the accumulators
+ template<typename A1>
+ explicit accumulator_set(
+ A1 const &a1
+ , typename boost::disable_if<
+ parameter::is_argument_pack<A1>
+ , detail::_enabler
+ >::type = detail::_enabler()
+ ) : accumulators(
detail::make_acc_list(
accumulators_mpl_vector()
- , detail::accumulator_params()(*this, a1)
+ , (
+ boost::accumulators::accumulator = *this
+ , boost::accumulators::sample = a1
+ )
)
)
{
// Add-ref the Features that the user has specified
this->template visit_if<detail::contains_feature_of_<Features> >(
- detail::make_add_ref_visitor(detail::accumulator_params()(*this))
+ detail::make_add_ref_visitor(boost::accumulators::accumulator = *this)
);
}
@@ -174,19 +232,47 @@ struct accumulator_set
///
#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_CTOR(z, n, _) \
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
- accumulator_set(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \
- : accumulators( \
+ accumulator_set( \
+ BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a) \
+ , typename boost::enable_if< \
+ parameter::is_argument_pack<A0> \
+ , detail::_enabler \
+ >::type = detail::_enabler() \
+ ) : accumulators( \
detail::make_acc_list( \
accumulators_mpl_vector() \
- , detail::accumulator_params()( \
- *this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
+ , ( \
+ boost::accumulators::accumulator = *this \
+ BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
) \
) \
) \
{ \
/* Add-ref the Features that the user has specified */ \
this->template visit_if<detail::contains_feature_of_<Features> >( \
- detail::make_add_ref_visitor(detail::accumulator_params()(*this)) \
+ detail::make_add_ref_visitor(boost::accumulators::accumulator = *this) \
+ ); \
+ } \
+ template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
+ accumulator_set( \
+ BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a) \
+ , typename boost::disable_if< \
+ parameter::is_argument_pack<A0> \
+ , detail::_enabler \
+ >::type = detail::_enabler() \
+ ) : accumulators( \
+ detail::make_acc_list( \
+ accumulators_mpl_vector() \
+ , ( \
+ boost::accumulators::accumulator = *this \
+ , boost::accumulators::sample = BOOST_PP_ENUM_PARAMS_Z(z, n, a) \
+ ) \
+ ) \
+ ) \
+ { \
+ /* Add-ref the Features that the user has specified */ \
+ this->template visit_if<detail::contains_feature_of_<Features> >( \
+ detail::make_add_ref_visitor(boost::accumulators::accumulator = *this) \
); \
}
@@ -239,17 +325,7 @@ struct accumulator_set
{
this->visit(
detail::make_accumulator_visitor(
- detail::accumulator_params()(*this)
- )
- );
- }
-
- template<typename A1>
- void operator ()(A1 const &a1)
- {
- this->visit(
- detail::make_accumulator_visitor(
- detail::accumulator_params()(*this, a1)
+ boost::accumulators::accumulator = *this
)
);
}
@@ -260,12 +336,37 @@ struct accumulator_set
///
#define BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP(z, n, _) \
template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
- void operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a)) \
+ void operator ()( \
+ BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a) \
+ , typename boost::enable_if< \
+ parameter::is_argument_pack<A0> \
+ , detail::_enabler \
+ >::type = detail::_enabler() \
+ ) \
{ \
this->visit( \
detail::make_accumulator_visitor( \
- detail::accumulator_params()( \
- *this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
+ ( \
+ boost::accumulators::accumulator = *this \
+ BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
+ ) \
+ ) \
+ ); \
+ } \
+ template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \
+ void operator ()( \
+ BOOST_PP_ENUM_BINARY_PARAMS_Z(z, n, A, const &a) \
+ , typename boost::disable_if< \
+ parameter::is_argument_pack<A0> \
+ , detail::_enabler \
+ >::type = detail::_enabler() \
+ ) \
+ { \
+ this->visit( \
+ detail::make_accumulator_visitor( \
+ ( \
+ boost::accumulators::accumulator = *this \
+ , boost::accumulators::sample = BOOST_PP_ENUM_PARAMS_Z(z, n, a) \
) \
) \
); \
@@ -274,7 +375,7 @@ struct accumulator_set
/// INTERNAL ONLY
///
BOOST_PP_REPEAT_FROM_TO(
- 2
+ 1
, BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
, BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP
, _
@@ -329,15 +430,23 @@ struct accumulator_set
the_feature;
(*fusion::find_if<detail::matches_feature<Feature> >(this->accumulators))
- .drop(detail::accumulator_params()(*this));
+ .drop(boost::accumulators::accumulator = *this);
// Also drop accumulators that this feature depends on
typedef typename the_feature::dependencies dependencies;
this->template visit_if<detail::contains_feature_of_<dependencies> >(
- detail::make_drop_visitor(detail::accumulator_params()(*this))
+ detail::make_drop_visitor(boost::accumulators::accumulator = *this)
);
}
+ // make the accumulator set serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ detail::serialize_accumulator<Archive> serializer(ar, file_version);
+ fusion::for_each(this->accumulators, serializer);
+ }
+
private:
accumulators_type accumulators;
@@ -365,6 +474,15 @@ find_accumulator(AccumulatorSet const &acc)
return acc.template extract<Feature>();
}
+template<typename Feature, typename AccumulatorSet>
+typename mpl::apply<AccumulatorSet, Feature>::type::result_type
+extract_result(AccumulatorSet const &acc)
+{
+ return find_accumulator<Feature>(acc).result(
+ boost::accumulators::accumulator = acc
+ );
+}
+
///////////////////////////////////////////////////////////////////////////////
// extract_result
// extract a result from an accumulator set
@@ -380,18 +498,43 @@ find_accumulator(AccumulatorSet const &acc)
extract_result( \
AccumulatorSet const &acc \
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
+ , typename boost::enable_if< \
+ parameter::is_argument_pack<A0> \
+ , detail::_enabler \
+ >::type \
) \
{ \
return find_accumulator<Feature>(acc).result( \
- detail::accumulator_params()( \
- acc \
+ ( \
+ boost::accumulators::accumulator = acc \
BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \
) \
); \
+ } \
+ template< \
+ typename Feature \
+ , typename AccumulatorSet \
+ BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \
+ > \
+ typename mpl::apply<AccumulatorSet, Feature>::type::result_type \
+ extract_result( \
+ AccumulatorSet const &acc \
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \
+ , typename boost::disable_if< \
+ parameter::is_argument_pack<A0> \
+ , detail::_enabler \
+ >::type \
+ ) \
+ { \
+ return find_accumulator<Feature>(acc).result(( \
+ boost::accumulators::accumulator = acc \
+ , boost::accumulators::sample = BOOST_PP_ENUM_PARAMS_Z(z, n, a) \
+ )); \
}
-BOOST_PP_REPEAT(
- BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
+BOOST_PP_REPEAT_FROM_TO(
+ 1
+ , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS)
, BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN
, _
)
diff --git a/boost/accumulators/framework/accumulators/external_accumulator.hpp b/boost/accumulators/framework/accumulators/external_accumulator.hpp
index 71dce42e51..eb6965c0ab 100644
--- a/boost/accumulators/framework/accumulators/external_accumulator.hpp
+++ b/boost/accumulators/framework/accumulators/external_accumulator.hpp
@@ -34,7 +34,7 @@ namespace boost { namespace accumulators { namespace impl
template<typename Args>
result_type result(Args const &args) const
{
- return this->extract_(args, args[parameter::keyword<Tag>::get() | 0]);
+ return this->extract_(args, args[parameter::keyword<Tag>::instance | 0]);
}
private:
diff --git a/boost/accumulators/framework/accumulators/reference_accumulator.hpp b/boost/accumulators/framework/accumulators/reference_accumulator.hpp
index bf4252ca6a..e50a751dc5 100644
--- a/boost/accumulators/framework/accumulators/reference_accumulator.hpp
+++ b/boost/accumulators/framework/accumulators/reference_accumulator.hpp
@@ -31,7 +31,7 @@ namespace impl
template<typename Args>
reference_accumulator_impl(Args const &args)
- : ref(args[parameter::keyword<Tag>::get()])
+ : ref(args[parameter::keyword<Tag>::instance])
{
}
diff --git a/boost/accumulators/framework/accumulators/value_accumulator.hpp b/boost/accumulators/framework/accumulators/value_accumulator.hpp
index 02bf7f3499..148549b085 100644
--- a/boost/accumulators/framework/accumulators/value_accumulator.hpp
+++ b/boost/accumulators/framework/accumulators/value_accumulator.hpp
@@ -30,7 +30,7 @@ namespace impl
template<typename Args>
value_accumulator_impl(Args const &args)
- : val(args[parameter::keyword<Tag>::get()])
+ : val(args[parameter::keyword<Tag>::instance])
{
}
diff --git a/boost/accumulators/framework/depends_on.hpp b/boost/accumulators/framework/depends_on.hpp
index 008f1217da..dd2b637b5c 100644
--- a/boost/accumulators/framework/depends_on.hpp
+++ b/boost/accumulators/framework/depends_on.hpp
@@ -266,11 +266,18 @@ namespace boost { namespace accumulators
template<typename Sequence, typename Args>
typename meta::make_acc_list<Sequence>::type
- make_acc_list(Sequence const &seq, Args const &args)
+ make_acc_list(Sequence &seq, Args const &args)
{
return meta::make_acc_list<Sequence>::call(args, fusion::begin(seq), fusion::end(seq));
}
+ template<typename Sequence, typename Args>
+ typename meta::make_acc_list<Sequence>::type
+ make_acc_list(Sequence const &seq, Args const &args)
+ {
+ return meta::make_acc_list<Sequence const>::call(args, fusion::begin(seq), fusion::end(seq));
+ }
+
///////////////////////////////////////////////////////////////////////////
// checked_as_weighted_feature
template<typename Feature>
diff --git a/boost/accumulators/framework/extractor.hpp b/boost/accumulators/framework/extractor.hpp
index 98281cecb9..169794461c 100644
--- a/boost/accumulators/framework/extractor.hpp
+++ b/boost/accumulators/framework/extractor.hpp
@@ -8,6 +8,7 @@
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005
+#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/tuple/rem.hpp>
#include <boost/preprocessor/array/size.hpp>
#include <boost/preprocessor/array/data.hpp>
@@ -15,11 +16,17 @@
#include <boost/preprocessor/seq/to_array.hpp>
#include <boost/preprocessor/seq/transform.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/enum_trailing.hpp>
#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/repetition/repeat_from_to.hpp>
#include <boost/parameter/binding.hpp>
-#include <boost/mpl/apply.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/if.hpp>
#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
#include <boost/accumulators/framework/parameters/accumulator.hpp>
@@ -33,14 +40,24 @@ namespace detail
struct accumulator_set_result
{
typedef typename as_feature<Feature>::type feature_type;
- typedef typename mpl::apply<AccumulatorSet, feature_type>::type::result_type type;
+ typedef typename mpl::apply<
+ typename boost::remove_const<
+ typename boost::remove_reference<AccumulatorSet>::type
+ >::type
+ , feature_type
+ >::type::result_type type;
};
template<typename Args, typename Feature>
struct argument_pack_result
: accumulator_set_result<
- typename remove_reference<
- typename parameter::binding<Args, tag::accumulator>::type
+ typename boost::remove_reference<
+ typename parameter::binding<
+ typename boost::remove_const<
+ typename boost::remove_reference<Args>::type
+ >::type
+ , tag::accumulator
+ >::type
>::type
, Feature
>
@@ -147,6 +164,8 @@ struct extractor
, _
)
+#undef BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP
+
#ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
/// \overload
///
@@ -156,6 +175,8 @@ struct extractor
#endif
};
+}} // namespace boost::accumulators
+
/// INTERNAL ONLY
///
#define BOOST_ACCUMULATORS_ARRAY_REM(Array) \
@@ -224,6 +245,4 @@ struct extractor
, (3, (Tag, Feature, ParamSeq)) \
)
-}} // namespace boost::accumulators
-
#endif
diff --git a/boost/accumulators/framework/parameters/accumulator.hpp b/boost/accumulators/framework/parameters/accumulator.hpp
index 525ebb30ba..675a3a3924 100644
--- a/boost/accumulators/framework/parameters/accumulator.hpp
+++ b/boost/accumulators/framework/parameters/accumulator.hpp
@@ -8,13 +8,13 @@
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_ACCUMULATOR_HPP_EAN_31_10_2005
-#include <boost/parameter/keyword.hpp>
+#include <boost/parameter/name.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
-BOOST_PARAMETER_KEYWORD(tag, accumulator)
+BOOST_PARAMETER_NAME((accumulator, tag) accumulator)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(accumulator)
}} // namespace boost::accumulators
diff --git a/boost/accumulators/framework/parameters/sample.hpp b/boost/accumulators/framework/parameters/sample.hpp
index 8b227eb334..39afe2b170 100644
--- a/boost/accumulators/framework/parameters/sample.hpp
+++ b/boost/accumulators/framework/parameters/sample.hpp
@@ -8,13 +8,13 @@
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_SAMPLE_HPP_EAN_31_10_2005
-#include <boost/parameter/keyword.hpp>
+#include <boost/parameter/name.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
-BOOST_PARAMETER_KEYWORD(tag, sample)
+BOOST_PARAMETER_NAME((sample, tag) sample)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(sample)
}} // namespace boost::accumulators
diff --git a/boost/accumulators/framework/parameters/weight.hpp b/boost/accumulators/framework/parameters/weight.hpp
index f36016f372..e9c26bfbd0 100644
--- a/boost/accumulators/framework/parameters/weight.hpp
+++ b/boost/accumulators/framework/parameters/weight.hpp
@@ -8,14 +8,14 @@
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHT_HPP_EAN_31_10_2005
-#include <boost/parameter/keyword.hpp>
+#include <boost/parameter/name.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
// The weight of a single sample
-BOOST_PARAMETER_KEYWORD(tag, weight)
+BOOST_PARAMETER_NAME((weight, tag) weight)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(weight)
}} // namespace boost::accumulators
diff --git a/boost/accumulators/framework/parameters/weights.hpp b/boost/accumulators/framework/parameters/weights.hpp
index 6beae61386..ab1948a86b 100644
--- a/boost/accumulators/framework/parameters/weights.hpp
+++ b/boost/accumulators/framework/parameters/weights.hpp
@@ -8,14 +8,14 @@
#ifndef BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005
#define BOOST_ACCUMULATORS_FRAMEWORK_PARAMETERS_WEIGHTS_HPP_EAN_28_10_2005
-#include <boost/parameter/keyword.hpp>
+#include <boost/parameter/name.hpp>
#include <boost/accumulators/accumulators_fwd.hpp>
namespace boost { namespace accumulators
{
// The weight accumulator
-BOOST_PARAMETER_KEYWORD(tag, weights)
+BOOST_PARAMETER_NAME((weights, tag) weights)
BOOST_ACCUMULATORS_IGNORE_GLOBAL(weights)
}} // namespace boost::accumulators
diff --git a/boost/accumulators/statistics/count.hpp b/boost/accumulators/statistics/count.hpp
index 6d30b41e26..b83435a30e 100644
--- a/boost/accumulators/statistics/count.hpp
+++ b/boost/accumulators/statistics/count.hpp
@@ -43,6 +43,13 @@ namespace impl
return this->cnt;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & cnt;
+ }
+
private:
std::size_t cnt;
};
diff --git a/boost/accumulators/statistics/covariance.hpp b/boost/accumulators/statistics/covariance.hpp
index b3030b9676..d80a85eda7 100644
--- a/boost/accumulators/statistics/covariance.hpp
+++ b/boost/accumulators/statistics/covariance.hpp
@@ -152,6 +152,13 @@ namespace impl
return this->cov_;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & cov_;
+ }
+
private:
result_type cov_;
};
diff --git a/boost/accumulators/statistics/density.hpp b/boost/accumulators/statistics/density.hpp
index 88ca17df79..32b48060fc 100644
--- a/boost/accumulators/statistics/density.hpp
+++ b/boost/accumulators/statistics/density.hpp
@@ -25,6 +25,8 @@
#include <boost/accumulators/statistics/count.hpp>
#include <boost/accumulators/statistics/max.hpp>
#include <boost/accumulators/statistics/min.hpp>
+#include <boost/serialization/vector.hpp>
+#include <boost/serialization/utility.hpp>
namespace boost { namespace accumulators
{
@@ -184,6 +186,20 @@ namespace impl
return make_iterator_range(this->histogram);
}
+ // make this accumulator serializeable
+ // TODO split to save/load and check on parameters provided in ctor
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & cache_size;
+ ar & cache;
+ ar & num_bins;
+ ar & samples_in_bin;
+ ar & bin_positions;
+ ar & histogram;
+ ar & is_dirty;
+ }
+
private:
std::size_t cache_size; // number of cached samples
array_type cache; // cache to store the first cache_size samples
diff --git a/boost/accumulators/statistics/extended_p_square.hpp b/boost/accumulators/statistics/extended_p_square.hpp
index e6cc8dc9a1..6990050e4f 100644
--- a/boost/accumulators/statistics/extended_p_square.hpp
+++ b/boost/accumulators/statistics/extended_p_square.hpp
@@ -26,6 +26,7 @@
#include <boost/accumulators/statistics_fwd.hpp>
#include <boost/accumulators/statistics/count.hpp>
#include <boost/accumulators/statistics/times2_iterator.hpp>
+#include <boost/serialization/vector.hpp>
namespace boost { namespace accumulators
{
@@ -236,6 +237,19 @@ namespace impl
);
}
+ public:
+ // make this accumulator serializeable
+ // TODO: do we need to split to load/save and verify that the parameters did not change?
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & probabilities;
+ ar & heights;
+ ar & actual_positions;
+ ar & desired_positions;
+ ar & positions_increments;
+ }
+
private:
array_type probabilities; // the quantile probabilities
array_type heights; // q_i
diff --git a/boost/accumulators/statistics/extended_p_square_quantile.hpp b/boost/accumulators/statistics/extended_p_square_quantile.hpp
index a17843d774..f57304cd04 100644
--- a/boost/accumulators/statistics/extended_p_square_quantile.hpp
+++ b/boost/accumulators/statistics/extended_p_square_quantile.hpp
@@ -185,6 +185,17 @@ namespace impl
}
}
+
+ public:
+ // make this accumulator serializeable
+ // TODO: do we need to split to load/save and verify that the parameters did not change?
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & probabilities;
+ ar & probability;
+ }
+
private:
array_type probabilities;
diff --git a/boost/accumulators/statistics/kurtosis.hpp b/boost/accumulators/statistics/kurtosis.hpp
index 76c93d3850..9ff9ecdccb 100644
--- a/boost/accumulators/statistics/kurtosis.hpp
+++ b/boost/accumulators/statistics/kurtosis.hpp
@@ -63,6 +63,10 @@ namespace impl
* ( accumulators::moment<2>(args) - mean(args) * mean(args) )
) - 3.;
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
} // namespace impl
diff --git a/boost/accumulators/statistics/max.hpp b/boost/accumulators/statistics/max.hpp
index 820f6593f0..15033e6daa 100644
--- a/boost/accumulators/statistics/max.hpp
+++ b/boost/accumulators/statistics/max.hpp
@@ -48,6 +48,13 @@ namespace impl
return this->max_;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & max_;
+ }
+
private:
Sample max_;
};
diff --git a/boost/accumulators/statistics/mean.hpp b/boost/accumulators/statistics/mean.hpp
index 4788837184..c6df176b78 100644
--- a/boost/accumulators/statistics/mean.hpp
+++ b/boost/accumulators/statistics/mean.hpp
@@ -41,6 +41,10 @@ namespace impl
extractor<SumFeature> sum;
return numeric::fdiv(sum(args), count(args));
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
template<typename Sample, typename Tag>
@@ -71,6 +75,12 @@ namespace impl
return this->mean;
}
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & mean;
+ }
+
private:
result_type mean;
};
diff --git a/boost/accumulators/statistics/median.hpp b/boost/accumulators/statistics/median.hpp
index d361c6dda4..4d4118d8b4 100644
--- a/boost/accumulators/statistics/median.hpp
+++ b/boost/accumulators/statistics/median.hpp
@@ -48,6 +48,10 @@ namespace impl
{
return p_square_quantile_for_median(args);
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
///////////////////////////////////////////////////////////////////////////////
// with_density_median_impl
@@ -105,6 +109,16 @@ namespace impl
return this->median;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sum;
+ ar & is_dirty;
+ ar & median;
+ }
+
+
private:
mutable float_type sum;
mutable bool is_dirty;
@@ -160,6 +174,15 @@ namespace impl
return this->median;
}
+
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & is_dirty;
+ ar & median;
+ }
+
private:
mutable bool is_dirty;
diff --git a/boost/accumulators/statistics/min.hpp b/boost/accumulators/statistics/min.hpp
index 83943bdb3c..bf30b79e34 100644
--- a/boost/accumulators/statistics/min.hpp
+++ b/boost/accumulators/statistics/min.hpp
@@ -48,6 +48,13 @@ namespace impl
return this->min_;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & min_;
+ }
+
private:
Sample min_;
};
diff --git a/boost/accumulators/statistics/moment.hpp b/boost/accumulators/statistics/moment.hpp
index 3dabd47ecf..9ba1e4caaf 100644
--- a/boost/accumulators/statistics/moment.hpp
+++ b/boost/accumulators/statistics/moment.hpp
@@ -75,6 +75,13 @@ namespace impl
return numeric::fdiv(this->sum, count(args));
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sum;
+ }
+
private:
Sample sum;
};
diff --git a/boost/accumulators/statistics/p_square_cumul_dist.hpp b/boost/accumulators/statistics/p_square_cumul_dist.hpp
index 50692838c7..daa66f9bd1 100644
--- a/boost/accumulators/statistics/p_square_cumul_dist.hpp
+++ b/boost/accumulators/statistics/p_square_cumul_dist.hpp
@@ -20,6 +20,8 @@
#include <boost/accumulators/framework/parameters/sample.hpp>
#include <boost/accumulators/statistics_fwd.hpp>
#include <boost/accumulators/statistics/count.hpp>
+#include <boost/serialization/vector.hpp>
+#include <boost/serialization/utility.hpp>
namespace boost { namespace accumulators
{
@@ -204,6 +206,20 @@ namespace impl
//return histogram;
return make_iterator_range(this->histogram);
}
+
+ // make this accumulator serializeable
+ // TODO split to save/load and check on parameters provided in ctor
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & num_cells;
+ ar & heights;
+ ar & actual_positions;
+ ar & desired_positions;
+ ar & positions_increments;
+ ar & histogram;
+ ar & is_dirty;
+ }
private:
std::size_t num_cells; // number of cells b
diff --git a/boost/accumulators/statistics/p_square_quantile.hpp b/boost/accumulators/statistics/p_square_quantile.hpp
index 636fea7f23..d87c1b3dbe 100644
--- a/boost/accumulators/statistics/p_square_quantile.hpp
+++ b/boost/accumulators/statistics/p_square_quantile.hpp
@@ -22,6 +22,7 @@
#include <boost/accumulators/statistics_fwd.hpp>
#include <boost/accumulators/statistics/count.hpp>
#include <boost/accumulators/statistics/parameters/quantile_probability.hpp>
+#include <boost/serialization/boost_array.hpp>
namespace boost { namespace accumulators
{
@@ -61,7 +62,7 @@ namespace impl
template<typename Args>
p_square_quantile_impl(Args const &args)
- : p(is_same<Impl, for_median>::value ? 0.5 : args[quantile_probability | 0.5])
+ : p(is_same<Impl, for_median>::value ? float_type(0.5) : args[quantile_probability | float_type(0.5)])
, heights()
, actual_positions()
, desired_positions()
@@ -69,20 +70,21 @@ namespace impl
{
for(std::size_t i = 0; i < 5; ++i)
{
- this->actual_positions[i] = i + 1.;
+ this->actual_positions[i] = i + float_type(1.);
}
- this->desired_positions[0] = 1.;
- this->desired_positions[1] = 1. + 2. * this->p;
- this->desired_positions[2] = 1. + 4. * this->p;
- this->desired_positions[3] = 3. + 2. * this->p;
- this->desired_positions[4] = 5.;
+ this->desired_positions[0] = float_type(1.);
+ this->desired_positions[1] = float_type(1.) + float_type(2.) * this->p;
+ this->desired_positions[2] = float_type(1.) + float_type(4.) * this->p;
+ this->desired_positions[3] = float_type(3.) + float_type(2.) * this->p;
+ this->desired_positions[4] = float_type(5.);
- this->positions_increments[0] = 0.;
- this->positions_increments[1] = this->p / 2.;
+
+ this->positions_increments[0] = float_type(0.);
+ this->positions_increments[1] = this->p / float_type(2.);
this->positions_increments[2] = this->p;
- this->positions_increments[3] = (1. + this->p) / 2.;
- this->positions_increments[4] = 1.;
+ this->positions_increments[3] = (float_type(1.) + this->p) / float_type(2.);
+ this->positions_increments[4] = float_type(1.);
}
template<typename Args>
@@ -156,7 +158,7 @@ namespace impl
float_type hp = (this->heights[i + 1] - this->heights[i]) / dp;
float_type hm = (this->heights[i - 1] - this->heights[i]) / dm;
- if((d >= 1. && dp > 1.) || (d <= -1. && dm < -1.))
+ if((d >= float_type(1.) && dp > float_type(1.)) || (d <= float_type(-1.) && dm < float_type(-1.)))
{
short sign_d = static_cast<short>(d / std::abs(d));
@@ -171,11 +173,11 @@ namespace impl
else
{
// use linear formula
- if(d > 0)
+ if(d > float_type(0))
{
this->heights[i] += hp;
}
- if(d < 0)
+ if(d < float_type(0))
{
this->heights[i] -= hm;
}
@@ -191,6 +193,18 @@ namespace impl
return this->heights[2];
}
+ // make this accumulator serializeable
+ // TODO: do we need to split to load/save and verify that P did not change?
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & p;
+ ar & heights;
+ ar & actual_positions;
+ ar & desired_positions;
+ ar & positions_increments;
+ }
+
private:
float_type p; // the quantile probability p
array_type heights; // q_i
diff --git a/boost/accumulators/statistics/peaks_over_threshold.hpp b/boost/accumulators/statistics/peaks_over_threshold.hpp
index f04f743a0c..de73c658aa 100644
--- a/boost/accumulators/statistics/peaks_over_threshold.hpp
+++ b/boost/accumulators/statistics/peaks_over_threshold.hpp
@@ -181,6 +181,21 @@ namespace impl
return this->fit_parameters_;
}
+ // make this accumulator serializeable
+ // TODO: do we need to split to load/save and verify that threshold did not change?
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & Nu_;
+ ar & mu_;
+ ar & sigma2_;
+ ar & threshold_;
+ ar & get<0>(fit_parameters_);
+ ar & get<1>(fit_parameters_);
+ ar & get<2>(fit_parameters_);
+ ar & is_dirty_;
+ }
+
private:
std::size_t Nu_; // number of samples larger than threshold
mutable float_type mu_; // mean of Nu_ largest samples
@@ -291,6 +306,20 @@ namespace impl
return this->fit_parameters_;
}
+ // make this accumulator serializeable
+ // TODO: do we need to split to load/save and verify that threshold did not change?
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & mu_;
+ ar & sigma2_;
+ ar & threshold_probability_;
+ ar & get<0>(fit_parameters_);
+ ar & get<1>(fit_parameters_);
+ ar & get<2>(fit_parameters_);
+ ar & is_dirty_;
+ }
+
private:
mutable float_type mu_; // mean of samples above threshold u
mutable float_type sigma2_; // variance of samples above threshold u
diff --git a/boost/accumulators/statistics/pot_quantile.hpp b/boost/accumulators/statistics/pot_quantile.hpp
index 470bdbace3..ecd49f2cb2 100644
--- a/boost/accumulators/statistics/pot_quantile.hpp
+++ b/boost/accumulators/statistics/pot_quantile.hpp
@@ -80,6 +80,13 @@ namespace impl
, -xi_hat
) - 1.));
}
+
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sign_;
+ }
private:
short sign_; // if the fit parameters from the mirrored left tail extreme values are used, mirror back the result
diff --git a/boost/accumulators/statistics/pot_tail_mean.hpp b/boost/accumulators/statistics/pot_tail_mean.hpp
index a78043fce2..96f4dc1f27 100644
--- a/boost/accumulators/statistics/pot_tail_mean.hpp
+++ b/boost/accumulators/statistics/pot_tail_mean.hpp
@@ -90,6 +90,14 @@ namespace impl
is_same<LeftRight, left>::value ? args[quantile_probability] : 1. - args[quantile_probability]
, -xi_hat);
}
+
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sign_;
+ }
+
private:
short sign_; // if the fit parameters from the mirrored left tail extreme values are used, mirror back the result
};
diff --git a/boost/accumulators/statistics/rolling_count.hpp b/boost/accumulators/statistics/rolling_count.hpp
index 1e34f76354..803f1b7754 100644
--- a/boost/accumulators/statistics/rolling_count.hpp
+++ b/boost/accumulators/statistics/rolling_count.hpp
@@ -40,6 +40,10 @@ namespace impl
{
return static_cast<std::size_t>(rolling_window_plus1(args).size()) - is_rolling_window_plus1_full(args);
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
} // namespace impl
diff --git a/boost/accumulators/statistics/rolling_mean.hpp b/boost/accumulators/statistics/rolling_mean.hpp
index 1439da1e2c..bd5494c3e1 100644
--- a/boost/accumulators/statistics/rolling_mean.hpp
+++ b/boost/accumulators/statistics/rolling_mean.hpp
@@ -43,6 +43,10 @@ namespace boost { namespace accumulators
{
return numeric::fdiv(rolling_sum(args), rolling_count(args));
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
///////////////////////////////////////////////////////////////////////////////
@@ -67,12 +71,18 @@ namespace boost { namespace accumulators
{
if(is_rolling_window_plus1_full(args))
{
- mean_ += numeric::fdiv(args[sample]-rolling_window_plus1(args).front(),rolling_count(args));
+ if (rolling_window_plus1(args).front() > args[sample])
+ mean_ -= numeric::fdiv(rolling_window_plus1(args).front()-args[sample],rolling_count(args));
+ else if (rolling_window_plus1(args).front() < args[sample])
+ mean_ += numeric::fdiv(args[sample]-rolling_window_plus1(args).front(),rolling_count(args));
}
else
{
result_type prev_mean = mean_;
- mean_ += numeric::fdiv(args[sample]-prev_mean,rolling_count(args));
+ if (prev_mean > args[sample])
+ mean_ -= numeric::fdiv(prev_mean-args[sample],rolling_count(args));
+ else if (prev_mean < args[sample])
+ mean_ += numeric::fdiv(args[sample]-prev_mean,rolling_count(args));
}
}
@@ -81,6 +91,13 @@ namespace boost { namespace accumulators
{
return mean_;
}
+
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & mean_;
+ }
private:
@@ -176,4 +193,4 @@ namespace boost { namespace accumulators
};
}} // namespace boost::accumulators
-#endif \ No newline at end of file
+#endif
diff --git a/boost/accumulators/statistics/rolling_moment.hpp b/boost/accumulators/statistics/rolling_moment.hpp
index f172cee34f..28ea5b580a 100644
--- a/boost/accumulators/statistics/rolling_moment.hpp
+++ b/boost/accumulators/statistics/rolling_moment.hpp
@@ -58,6 +58,13 @@ namespace impl
return numeric::fdiv(this->sum_, rolling_count(args));
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sum_;
+ }
+
private:
result_type sum_;
};
diff --git a/boost/accumulators/statistics/rolling_sum.hpp b/boost/accumulators/statistics/rolling_sum.hpp
index bbb7a8e9a0..c511460655 100644
--- a/boost/accumulators/statistics/rolling_sum.hpp
+++ b/boost/accumulators/statistics/rolling_sum.hpp
@@ -51,6 +51,13 @@ namespace impl
return this->sum_;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sum_;
+ }
+
private:
Sample sum_;
};
diff --git a/boost/accumulators/statistics/rolling_variance.hpp b/boost/accumulators/statistics/rolling_variance.hpp
index 33b3922a50..249d5c1996 100644
--- a/boost/accumulators/statistics/rolling_variance.hpp
+++ b/boost/accumulators/statistics/rolling_variance.hpp
@@ -62,6 +62,10 @@ namespace impl
if (nr_samples < 2) return result_type();
return nr_samples*(rolling_moment<2>(args) - mean*mean)/(nr_samples-1);
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
//! Iterative calculation of the rolling variance.
@@ -138,6 +142,14 @@ namespace impl
if (nr_samples < 2) return result_type();
return numeric::fdiv(sum_of_squares_,(nr_samples-1));
}
+
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & previous_mean_;
+ ar & sum_of_squares_;
+ }
private:
diff --git a/boost/accumulators/statistics/rolling_window.hpp b/boost/accumulators/statistics/rolling_window.hpp
index 2e0a33420a..a43ecdfdac 100644
--- a/boost/accumulators/statistics/rolling_window.hpp
+++ b/boost/accumulators/statistics/rolling_window.hpp
@@ -21,6 +21,45 @@
#include <boost/accumulators/framework/parameters/accumulator.hpp>
#include <boost/accumulators/numeric/functional.hpp>
#include <boost/accumulators/statistics_fwd.hpp>
+#include <boost/serialization/split_free.hpp>
+
+namespace boost { namespace serialization {
+
+// implement serialization for boost::circular_buffer
+template <class Archive, class T>
+void save(Archive& ar, const circular_buffer<T>& b, const unsigned int /* version */)
+{
+ typename circular_buffer<T>::size_type size = b.size();
+ ar << b.capacity();
+ ar << size;
+ const typename circular_buffer<T>::const_array_range one = b.array_one();
+ const typename circular_buffer<T>::const_array_range two = b.array_two();
+ ar.save_binary(one.first, one.second*sizeof(T));
+ ar.save_binary(two.first, two.second*sizeof(T));
+}
+
+template <class Archive, class T>
+void load(Archive& ar, circular_buffer<T>& b, const unsigned int /* version */)
+{
+ typename circular_buffer<T>::capacity_type capacity;
+ typename circular_buffer<T>::size_type size;
+ ar >> capacity;
+ b.set_capacity(capacity);
+ ar >> size;
+ b.clear();
+ const typename circular_buffer<T>::pointer buff = new T[size*sizeof(T)];
+ ar.load_binary(buff, size*sizeof(T));
+ b.insert(b.begin(), buff, buff+size);
+ delete[] buff;
+}
+
+template<class Archive, class T>
+inline void serialize(Archive & ar, circular_buffer<T>& b, const unsigned int version)
+{
+ split_free(ar, b, version);
+}
+
+} } // end namespace boost::serialization
namespace boost { namespace accumulators
{
@@ -83,6 +122,12 @@ namespace impl
return result_type(this->buffer_.begin(), this->buffer_.end());
}
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int version)
+ {
+ ar & buffer_;
+ }
+
private:
circular_buffer<Sample> buffer_;
};
@@ -112,6 +157,10 @@ namespace impl
{
return rolling_window_plus1(args).advance_begin(is_rolling_window_plus1_full(args));
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
} // namespace impl
diff --git a/boost/accumulators/statistics/skewness.hpp b/boost/accumulators/statistics/skewness.hpp
index c383ec4a6c..9c9c376a8a 100644
--- a/boost/accumulators/statistics/skewness.hpp
+++ b/boost/accumulators/statistics/skewness.hpp
@@ -65,6 +65,10 @@ namespace impl
* std::sqrt( accumulators::moment<2>(args) - mean(args) * mean(args) )
);
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
} // namespace impl
diff --git a/boost/accumulators/statistics/sum.hpp b/boost/accumulators/statistics/sum.hpp
index 126ce244fd..7e507ccc26 100644
--- a/boost/accumulators/statistics/sum.hpp
+++ b/boost/accumulators/statistics/sum.hpp
@@ -51,8 +51,13 @@ namespace impl
return this->sum;
}
- private:
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sum;
+ }
+ private:
Sample sum;
};
diff --git a/boost/accumulators/statistics/sum_kahan.hpp b/boost/accumulators/statistics/sum_kahan.hpp
index 97ade18da8..b5e9092238 100644
--- a/boost/accumulators/statistics/sum_kahan.hpp
+++ b/boost/accumulators/statistics/sum_kahan.hpp
@@ -66,6 +66,14 @@ struct sum_kahan_impl
return this->sum;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sum;
+ ar & compensation;
+ }
+
private:
Sample sum;
Sample compensation;
diff --git a/boost/accumulators/statistics/tail.hpp b/boost/accumulators/statistics/tail.hpp
index be6cdee392..154a30cc26 100644
--- a/boost/accumulators/statistics/tail.hpp
+++ b/boost/accumulators/statistics/tail.hpp
@@ -268,6 +268,17 @@ namespace impl
std::vector<Sample> const &samples;
};
+ public:
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & is_sorted;
+ ar & indices;
+ ar & samples;
+ }
+
+ private:
mutable bool is_sorted;
mutable std::vector<std::size_t> indices;
std::vector<Sample> samples;
diff --git a/boost/accumulators/statistics/tail_mean.hpp b/boost/accumulators/statistics/tail_mean.hpp
index 67dae37b50..f56606d14e 100644
--- a/boost/accumulators/statistics/tail_mean.hpp
+++ b/boost/accumulators/statistics/tail_mean.hpp
@@ -88,6 +88,10 @@ namespace impl
- numeric::fdiv(n, count(args))
);
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
///////////////////////////////////////////////////////////////////////////////
@@ -159,6 +163,10 @@ namespace impl
}
}
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
} // namespace impl
diff --git a/boost/accumulators/statistics/tail_quantile.hpp b/boost/accumulators/statistics/tail_quantile.hpp
index 9ff56b56e5..ed1f6e6dff 100644
--- a/boost/accumulators/statistics/tail_quantile.hpp
+++ b/boost/accumulators/statistics/tail_quantile.hpp
@@ -98,6 +98,10 @@ namespace impl
}
}
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
} // namespace impl
diff --git a/boost/accumulators/statistics/tail_variate.hpp b/boost/accumulators/statistics/tail_variate.hpp
index a9fc7d297a..6885ece15f 100644
--- a/boost/accumulators/statistics/tail_variate.hpp
+++ b/boost/accumulators/statistics/tail_variate.hpp
@@ -18,6 +18,7 @@
#include <boost/accumulators/framework/depends_on.hpp>
#include <boost/accumulators/statistics_fwd.hpp>
#include <boost/accumulators/statistics/tail.hpp>
+#include <boost/serialization/vector.hpp>
namespace boost { namespace accumulators
{
@@ -69,6 +70,14 @@ namespace impl
);
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & variates;
+ }
+
+ private:
std::vector<VariateType> variates;
};
diff --git a/boost/accumulators/statistics/tail_variate_means.hpp b/boost/accumulators/statistics/tail_variate_means.hpp
index a97eab5648..efe9f7c37e 100644
--- a/boost/accumulators/statistics/tail_variate_means.hpp
+++ b/boost/accumulators/statistics/tail_variate_means.hpp
@@ -27,6 +27,7 @@
#include <boost/accumulators/statistics/tail_variate.hpp>
#include <boost/accumulators/statistics/tail_mean.hpp>
#include <boost/accumulators/statistics/parameters/quantile_probability.hpp>
+#include <boost/serialization/vector.hpp>
#ifdef _MSC_VER
# pragma warning(push)
@@ -145,6 +146,13 @@ namespace impl
return make_iterator_range(this->tail_means_);
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & tail_means_;
+ }
+
private:
mutable array_type tail_means_;
diff --git a/boost/accumulators/statistics/variance.hpp b/boost/accumulators/statistics/variance.hpp
index baac55696b..9db858d2fb 100644
--- a/boost/accumulators/statistics/variance.hpp
+++ b/boost/accumulators/statistics/variance.hpp
@@ -53,6 +53,10 @@ namespace impl
result_type tmp = mean(args);
return accumulators::moment<2>(args) - tmp * tmp;
}
+
+ // serialization is done by accumulators it depends on
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version) {}
};
//! Iterative calculation of variance.
@@ -113,6 +117,13 @@ namespace impl
return this->variance;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & variance;
+ }
+
private:
result_type variance;
};
diff --git a/boost/accumulators/statistics/weighted_covariance.hpp b/boost/accumulators/statistics/weighted_covariance.hpp
index 25d613c120..e423a225a9 100644
--- a/boost/accumulators/statistics/weighted_covariance.hpp
+++ b/boost/accumulators/statistics/weighted_covariance.hpp
@@ -97,6 +97,13 @@ namespace impl
return this->cov_;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & cov_;
+ }
+
private:
result_type cov_;
};
diff --git a/boost/accumulators/statistics/weighted_density.hpp b/boost/accumulators/statistics/weighted_density.hpp
index 1407368016..6b5a0ee015 100644
--- a/boost/accumulators/statistics/weighted_density.hpp
+++ b/boost/accumulators/statistics/weighted_density.hpp
@@ -23,6 +23,8 @@
#include <boost/accumulators/statistics/max.hpp>
#include <boost/accumulators/statistics/min.hpp>
#include <boost/accumulators/statistics/density.hpp> // for named parameters density_cache_size and density_num_bins
+#include <boost/serialization/vector.hpp>
+#include <boost/serialization/utility.hpp>
namespace boost { namespace accumulators
{
@@ -171,6 +173,20 @@ namespace impl
return make_iterator_range(this->histogram);
}
+ // make this accumulator serializeable
+ // TODO split to save/load and check on parameters provided in ctor
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & cache_size;
+ ar & cache;
+ ar & num_bins;
+ ar & samples_in_bin;
+ ar & bin_positions;
+ ar & histogram;
+ ar & is_dirty;
+ }
+
private:
std::size_t cache_size; // number of cached samples
histogram_type cache; // cache to store the first cache_size samples with their weights as std::pair
diff --git a/boost/accumulators/statistics/weighted_extended_p_square.hpp b/boost/accumulators/statistics/weighted_extended_p_square.hpp
index ac857e056d..f88e9b9ee8 100644
--- a/boost/accumulators/statistics/weighted_extended_p_square.hpp
+++ b/boost/accumulators/statistics/weighted_extended_p_square.hpp
@@ -28,6 +28,7 @@
#include <boost/accumulators/statistics/sum.hpp>
#include <boost/accumulators/statistics/times2_iterator.hpp>
#include <boost/accumulators/statistics/extended_p_square.hpp>
+#include <boost/serialization/vector.hpp>
namespace boost { namespace accumulators
{
@@ -251,6 +252,17 @@ namespace impl
);
}
+ // make this accumulator serializeable
+ // TODO: do we need to split to load/save and verify that the parameters did not change?
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & probabilities;
+ ar & heights;
+ ar & actual_positions;
+ ar & desired_positions;
+ }
+
private:
array_type probabilities; // the quantile probabilities
array_type heights; // q_i
diff --git a/boost/accumulators/statistics/weighted_mean.hpp b/boost/accumulators/statistics/weighted_mean.hpp
index a80ef0984c..1ddce8dd57 100644
--- a/boost/accumulators/statistics/weighted_mean.hpp
+++ b/boost/accumulators/statistics/weighted_mean.hpp
@@ -97,6 +97,13 @@ namespace impl
return this->mean;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & mean;
+ }
+
private:
result_type mean;
};
diff --git a/boost/accumulators/statistics/weighted_median.hpp b/boost/accumulators/statistics/weighted_median.hpp
index ed7cadb331..22224a877a 100644
--- a/boost/accumulators/statistics/weighted_median.hpp
+++ b/boost/accumulators/statistics/weighted_median.hpp
@@ -106,6 +106,15 @@ namespace impl
return this->median;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sum;
+ ar & is_dirty;
+ ar & median;
+ }
+
private:
mutable float_type sum;
mutable bool is_dirty;
@@ -162,6 +171,15 @@ namespace impl
return this->median;
}
+
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & is_dirty;
+ ar & median;
+ }
+
private:
mutable bool is_dirty;
mutable float_type median;
diff --git a/boost/accumulators/statistics/weighted_moment.hpp b/boost/accumulators/statistics/weighted_moment.hpp
index 011701c704..5b6129066a 100644
--- a/boost/accumulators/statistics/weighted_moment.hpp
+++ b/boost/accumulators/statistics/weighted_moment.hpp
@@ -60,6 +60,13 @@ namespace impl
return numeric::fdiv(this->sum, sum_of_weights(args));
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sum;
+ }
+
private:
weighted_sample sum;
};
diff --git a/boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp b/boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp
index ce750ed1f5..f8a44d605b 100644
--- a/boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp
+++ b/boost/accumulators/statistics/weighted_p_square_cumul_dist.hpp
@@ -221,6 +221,19 @@ namespace impl
return make_iterator_range(this->histogram);
}
+ // make this accumulator serializeable
+ // TODO split to save/load and check on parameters provided in ctor
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & num_cells;
+ ar & heights;
+ ar & actual_positions;
+ ar & desired_positions;
+ ar & histogram;
+ ar & is_dirty;
+ }
+
private:
std::size_t num_cells; // number of cells b
array_type heights; // q_i
diff --git a/boost/accumulators/statistics/weighted_p_square_quantile.hpp b/boost/accumulators/statistics/weighted_p_square_quantile.hpp
index 2ebc7b1845..fecd993911 100644
--- a/boost/accumulators/statistics/weighted_p_square_quantile.hpp
+++ b/boost/accumulators/statistics/weighted_p_square_quantile.hpp
@@ -208,6 +208,17 @@ namespace impl {
return this->heights[2];
}
+ // make this accumulator serializeable
+ // TODO split to save/load and check on parameters provided in ctor
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & p;
+ ar & heights;
+ ar & actual_positions;
+ ar & desired_positions;
+ }
+
private:
float_type p; // the quantile probability p
array_type heights; // q_i
diff --git a/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp b/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp
index 418b38cfe0..f3dc327b9e 100644
--- a/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp
+++ b/boost/accumulators/statistics/weighted_peaks_over_threshold.hpp
@@ -109,6 +109,19 @@ namespace impl
return this->fit_parameters_;
}
+ // make this accumulator serializeable
+ // TODO: do we need to split to load/save and verify that threshold did not change?
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & sign_;
+ ar & mu_;
+ ar & sigma2_;
+ ar & threshold_;
+ ar & fit_parameters_;
+ ar & is_dirty_;
+ }
+
private:
short sign_; // for left tail fitting, mirror the extreme values
mutable float_type mu_; // mean of samples above threshold
diff --git a/boost/accumulators/statistics/weighted_sum.hpp b/boost/accumulators/statistics/weighted_sum.hpp
index 27153906d0..41091f8766 100644
--- a/boost/accumulators/statistics/weighted_sum.hpp
+++ b/boost/accumulators/statistics/weighted_sum.hpp
@@ -55,6 +55,13 @@ namespace impl
return this->weighted_sum_;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & weighted_sum_;
+ }
+
private:
weighted_sample weighted_sum_;
diff --git a/boost/accumulators/statistics/weighted_sum_kahan.hpp b/boost/accumulators/statistics/weighted_sum_kahan.hpp
index fbb0303acc..5ee5250d69 100644
--- a/boost/accumulators/statistics/weighted_sum_kahan.hpp
+++ b/boost/accumulators/statistics/weighted_sum_kahan.hpp
@@ -68,6 +68,14 @@ namespace impl
return this->weighted_sum_;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & weighted_sum_;
+ ar & compensation;
+ }
+
private:
weighted_sample weighted_sum_;
weighted_sample compensation;
diff --git a/boost/accumulators/statistics/weighted_tail_variate_means.hpp b/boost/accumulators/statistics/weighted_tail_variate_means.hpp
index b1133109ed..f096a93b52 100644
--- a/boost/accumulators/statistics/weighted_tail_variate_means.hpp
+++ b/boost/accumulators/statistics/weighted_tail_variate_means.hpp
@@ -179,6 +179,13 @@ namespace impl
return make_iterator_range(this->tail_means_);
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & tail_means_;
+ }
+
private:
mutable array_type tail_means_;
diff --git a/boost/accumulators/statistics/weighted_variance.hpp b/boost/accumulators/statistics/weighted_variance.hpp
index bc199affa4..f7d2b6e5f7 100644
--- a/boost/accumulators/statistics/weighted_variance.hpp
+++ b/boost/accumulators/statistics/weighted_variance.hpp
@@ -103,6 +103,13 @@ namespace impl
return this->weighted_variance;
}
+ // make this accumulator serializeable
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int file_version)
+ {
+ ar & weighted_variance;
+ }
+
private:
result_type weighted_variance;
};