diff options
Diffstat (limited to 'src/third_party/boost-1.56.0/boost/accumulators')
32 files changed, 5076 insertions, 0 deletions
diff --git a/src/third_party/boost-1.56.0/boost/accumulators/accumulators.hpp b/src/third_party/boost-1.56.0/boost/accumulators/accumulators.hpp new file mode 100644 index 00000000000..55ee2f91840 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/accumulators.hpp @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file accumulators.hpp +/// Includes all of the Accumulators Framework +// +// Copyright 2005 Eric Niebler. 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_ACCUMULATORS_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_ACCUMULATORS_HPP_EAN_28_10_2005 + +#include <boost/accumulators/framework/accumulator_set.hpp> +#include <boost/accumulators/framework/accumulator_concept.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/external.hpp> +#include <boost/accumulators/framework/features.hpp> +#include <boost/accumulators/framework/parameters/accumulator.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/parameters/weight.hpp> +#include <boost/accumulators/framework/parameters/weights.hpp> +#include <boost/accumulators/framework/accumulators/external_accumulator.hpp> +#include <boost/accumulators/framework/accumulators/droppable_accumulator.hpp> +#include <boost/accumulators/framework/accumulators/reference_accumulator.hpp> +#include <boost/accumulators/framework/accumulators/value_accumulator.hpp> + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/accumulators_fwd.hpp b/src/third_party/boost-1.56.0/boost/accumulators/accumulators_fwd.hpp new file mode 100644 index 00000000000..4c0370e21ec --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/accumulators_fwd.hpp @@ -0,0 +1,230 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulators_fwd.hpp +// +// Copyright 2005 Eric Niebler. 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_ACCUMULATORS_FWD_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_ACCUMULATORS_FWD_HPP_EAN_28_10_2005 + +#include <boost/config.hpp> +#include <boost/mpl/apply_fwd.hpp> // for mpl::na +#include <boost/mpl/limits/vector.hpp> +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/arithmetic/inc.hpp> +#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +#include <boost/preprocessor/repetition/enum_trailing_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> + +#ifndef BOOST_ACCUMULATORS_MAX_FEATURES + /// The maximum number of accumulators that may be put in an accumulator_set. + /// Defaults to BOOST_MPL_LIMIT_VECTOR_SIZE (which defaults to 20). +# define BOOST_ACCUMULATORS_MAX_FEATURES BOOST_MPL_LIMIT_VECTOR_SIZE +#endif + +#if BOOST_ACCUMULATORS_MAX_FEATURES > BOOST_MPL_LIMIT_VECTOR_SIZE +# error BOOST_ACCUMULATORS_MAX_FEATURES cannot be larger than BOOST_MPL_LIMIT_VECTOR_SIZE +#endif + +#ifndef BOOST_ACCUMULATORS_MAX_ARGS + /// The maximum number of arguments that may be specified to an accumulator_set's + /// accumulation function. Defaults to 15. +# define BOOST_ACCUMULATORS_MAX_ARGS 15 +#endif + +#if BOOST_WORKAROUND(__GNUC__, == 3) \ + || BOOST_WORKAROUND(__EDG_VERSION__, BOOST_TESTED_AT(306)) +# define BOOST_ACCUMULATORS_BROKEN_CONST_OVERLOADS +#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 +#else +# define BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(T) +#endif + +#define BOOST_ACCUMULATORS_GCC_VERSION \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +// Named parameters tags +// +namespace tag +{ + struct sample; + struct weight; + struct accumulator; + struct weights; +} + +/////////////////////////////////////////////////////////////////////////////// +// User-level features +// +namespace tag +{ + template<typename ValueType, typename Tag> + struct value; + + template<typename Tag> + struct value_tag; + + template<typename Referent, typename Tag> + struct reference; + + template<typename Tag> + struct reference_tag; + + template<typename Type, typename Tag = void, typename AccumulatorSet = void> + struct external; + + template<typename Feature> + struct droppable; +} + +template<typename Accumulator> +struct droppable_accumulator_base; + +template<typename Accumulator> +struct droppable_accumulator; + +template<typename Accumulator> +struct with_cached_result; + +template<typename Sample, typename Features, typename Weight = void> +struct accumulator_set; + +template<typename Feature> +struct extractor; + +template<typename Feature> +struct feature_of; + +template<typename Feature> +struct as_feature; + +template<typename Feature> +struct as_weighted_feature; + +template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> +struct depends_on; + +template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> +struct features; + +template<typename Feature, typename AccumulatorSet> +typename mpl::apply<AccumulatorSet, Feature>::type const & +find_accumulator(AccumulatorSet const &acc); + +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); + +// ... other overloads generated by Boost.Preprocessor: + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_EXTRACT_RESULT_FWD(z, n, _) \ + 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) \ + ); + +/// INTERNAL ONLY +/// +BOOST_PP_REPEAT_FROM_TO( + 2 + , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , 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 +extract_result(AccumulatorSet const &acc, A1 const &a1, A2 const &a2 ...); +#endif + +namespace impl +{ + using namespace numeric::operators; + + template<typename Accumulator, typename Tag> + struct external_impl; +} + +namespace detail +{ + template<typename Accumulator> + struct feature_tag; + + template<typename Feature, typename Sample, typename Weight> + struct to_accumulator; + + struct accumulator_set_base; + + template<typename T> + struct is_accumulator_set; + + inline void ignore_variable(void const *) {} + +#define BOOST_ACCUMULATORS_IGNORE_GLOBAL(X) \ + namespace detail \ + { \ + struct BOOST_PP_CAT(ignore_, X) \ + { \ + void ignore() \ + { \ + boost::accumulators::detail::ignore_variable(&X); \ + } \ + }; \ + } \ + /**/ +} + +}} // namespace boost::accumulators + +// 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 diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulator_base.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulator_base.hpp new file mode 100644 index 00000000000..52c520d1074 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulator_base.hpp @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulator_base.hpp +// +// Copyright 2005 Eric Niebler. 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_FRAMEWORK_ACCUMULATORS_BASE_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_BASE_HPP_EAN_28_10_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/joint_view.hpp> +#include <boost/mpl/single_view.hpp> +#include <boost/mpl/fold.hpp> +#include <boost/mpl/contains.hpp> +#include <boost/mpl/empty_sequence.hpp> +#include <boost/accumulators/framework/accumulator_concept.hpp> + +namespace boost { namespace accumulators +{ + +namespace detail +{ + typedef void void_; +} + +/////////////////////////////////////////////////////////////////////////////// +// dont_care +// +struct dont_care +{ + template<typename Args> + dont_care(Args const &) + { + } +}; + +/////////////////////////////////////////////////////////////////////////////// +// accumulator_base +// +struct accumulator_base +{ + // hidden if defined in derived classes + detail::void_ operator ()(dont_care) + { + } + + typedef mpl::false_ is_droppable; + + detail::void_ add_ref(dont_care) + { + } + + detail::void_ drop(dont_care) + { + } + + detail::void_ on_drop(dont_care) + { + } +}; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulator_concept.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulator_concept.hpp new file mode 100644 index 00000000000..492357efbaa --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulator_concept.hpp @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulator_concept.hpp +// +// Copyright 2005 Eric Niebler. 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_FRAMEWORK_ACCUMULATOR_CONCEPT_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_CONCEPT_HPP_EAN_28_10_2005 + +#include <boost/concept_check.hpp> + +namespace boost { namespace accumulators +{ + +template<typename Stat> +struct accumulator_concept +{ + void constraints() + { + // TODO: define the stat concept + } + + Stat stat; +}; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulator_set.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulator_set.hpp new file mode 100644 index 00000000000..ed1ceb1afa4 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulator_set.hpp @@ -0,0 +1,401 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulator_set.hpp +// +// Copyright 2005 Eric Niebler. 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_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATOR_SET_HPP_EAN_28_10_2005 + +#include <boost/version.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/preprocessor/repetition/repeat_from_to.hpp> +#include <boost/preprocessor/repetition/enum_binary_params.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/framework/accumulator_concept.hpp> +#include <boost/accumulators/framework/parameters/accumulator.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/framework/accumulators/external_accumulator.hpp> +#include <boost/accumulators/framework/accumulators/droppable_accumulator.hpp> +#include <boost/fusion/include/any.hpp> +#include <boost/fusion/include/find_if.hpp> +#include <boost/fusion/include/for_each.hpp> +#include <boost/fusion/include/filter_view.hpp> + +namespace boost { namespace accumulators +{ + +namespace detail +{ + /////////////////////////////////////////////////////////////////////////////// + // accumulator_visitor + // wrap a boost::parameter argument pack in a Fusion extractor object + template<typename Args> + struct accumulator_visitor + { + explicit accumulator_visitor(Args const &a) + : args(a) + { + } + + template<typename Accumulator> + void operator ()(Accumulator &accumulator) const + { + accumulator(this->args); + } + + private: + accumulator_visitor &operator =(accumulator_visitor const &); + Args const &args; + }; + + template<typename Args> + inline accumulator_visitor<Args> const make_accumulator_visitor(Args const &args) + { + 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 + { + }; + + /////////////////////////////////////////////////////////////////////////////// + // is_accumulator_set + template<typename T> + struct is_accumulator_set + : is_base_and_derived<accumulator_set_base, T> + { + }; + +} // namespace detail + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4355) // warning C4355: 'this' : used in base member initializer list +#endif + +/////////////////////////////////////////////////////////////////////////////// +/// \brief A set of accumulators. +/// +/// accumulator_set resolves the dependencies between features and ensures that +/// the accumulators in the set are updated in the proper order. +/// +/// acccumulator_set provides a general mechanism to visit the accumulators +/// in the set in order, with or without a filter. You can also fetch a reference +/// to an accumulator that corresponds to a feature. +/// +template<typename Sample, typename Features, typename Weight> +struct accumulator_set + : detail::accumulator_set_base +{ + typedef Sample sample_type; ///< The type of the samples that will be accumulated + typedef Features features_type; ///< An MPL sequence of the features that should be accumulated. + typedef Weight weight_type; ///< The type of the weight parameter. Must be a scalar. Defaults to void. + + /// INTERNAL ONLY + /// + typedef + typename detail::make_accumulator_tuple< + Features + , Sample + , Weight + >::type + accumulators_mpl_vector; + + // generate a fusion::list of accumulators + /// INTERNAL ONLY + /// + typedef + typename detail::meta::make_acc_list< + accumulators_mpl_vector + >::type + accumulators_type; + + /// INTERNAL ONLY + /// + //BOOST_MPL_ASSERT((mpl::is_sequence<accumulators_type>)); + + /////////////////////////////////////////////////////////////////////////////// + /// default-construct all contained accumulators + accumulator_set() + : accumulators( + detail::make_acc_list( + accumulators_mpl_vector() + , detail::accumulator_params()(*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)) + ); + } + + /// \overload + /// + /// \param a1 Optional named parameter to be passed to all the accumulators + template<typename A1> + explicit accumulator_set(A1 const &a1) + : accumulators( + detail::make_acc_list( + accumulators_mpl_vector() + , detail::accumulator_params()(*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(detail::accumulator_params()(*this)) + ); + } + + // ... other overloads generated by Boost.Preprocessor: + + /// INTERNAL ONLY + /// +#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( \ + detail::make_acc_list( \ + accumulators_mpl_vector() \ + , detail::accumulator_params()( \ + *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)) \ + ); \ + } + + /// INTERNAL ONLY + /// + BOOST_PP_REPEAT_FROM_TO( + 2 + , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , BOOST_ACCUMULATORS_ACCUMULATOR_SET_CTOR + , _ + ) + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// \overload + /// + template<typename A1, typename A2, ...> + accumulator_set(A1 const &a1, A2 const &a2, ...); + #endif + + // ... other overloads generated by Boost.Preprocessor below ... + + /////////////////////////////////////////////////////////////////////////////// + /// Visitation + /// \param func UnaryFunction which is invoked with each accumulator in turn. + template<typename UnaryFunction> + void visit(UnaryFunction const &func) + { + fusion::for_each(this->accumulators, func); + } + + /////////////////////////////////////////////////////////////////////////////// + /// Conditional visitation + /// \param func UnaryFunction which is invoked with each accumulator in turn, + /// provided the accumulator satisfies the MPL predicate FilterPred. + template<typename FilterPred, typename UnaryFunction> + void visit_if(UnaryFunction const &func) + { + fusion::filter_view<accumulators_type, FilterPred> filtered_accs(this->accumulators); + fusion::for_each(filtered_accs, func); + } + + /////////////////////////////////////////////////////////////////////////////// + /// The return type of the operator() overloads is void. + typedef void result_type; + + /////////////////////////////////////////////////////////////////////////////// + /// Accumulation + /// \param a1 Optional named parameter to be passed to all the accumulators + void operator ()() + { + 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) + ) + ); + } + + // ... other overloads generated by Boost.Preprocessor: + + /// INTERNAL ONLY + /// +#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)) \ + { \ + this->visit( \ + detail::make_accumulator_visitor( \ + detail::accumulator_params()( \ + *this BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \ + ) \ + ) \ + ); \ + } + + /// INTERNAL ONLY + /// + BOOST_PP_REPEAT_FROM_TO( + 2 + , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , BOOST_ACCUMULATORS_ACCUMULATOR_SET_FUN_OP + , _ + ) + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// \overload + /// + template<typename A1, typename A2, ...> + void operator ()(A1 const &a1, A2 const &a2, ...); + #endif + + /////////////////////////////////////////////////////////////////////////////// + /// Extraction + template<typename Feature> + struct apply + : fusion::result_of::value_of< + typename fusion::result_of::find_if< + accumulators_type + , detail::matches_feature<Feature> + >::type + > + { + }; + + /////////////////////////////////////////////////////////////////////////////// + /// Extraction + template<typename Feature> + typename apply<Feature>::type &extract() + { + return *fusion::find_if<detail::matches_feature<Feature> >(this->accumulators); + } + + /// \overload + template<typename Feature> + typename apply<Feature>::type const &extract() const + { + return *fusion::find_if<detail::matches_feature<Feature> >(this->accumulators); + } + + /////////////////////////////////////////////////////////////////////////////// + /// Drop + template<typename Feature> + void drop() + { + // You can only drop the features that you have specified explicitly + typedef typename apply<Feature>::type the_accumulator; + BOOST_MPL_ASSERT((detail::contains_feature_of<Features, the_accumulator>)); + + typedef + typename feature_of<typename as_feature<Feature>::type>::type + the_feature; + + (*fusion::find_if<detail::matches_feature<Feature> >(this->accumulators)) + .drop(detail::accumulator_params()(*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)) + ); + } + +private: + + accumulators_type accumulators; +}; + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +/////////////////////////////////////////////////////////////////////////////// +// find_accumulator +// find an accumulator in an accumulator_set corresponding to a feature +template<typename Feature, typename AccumulatorSet> +typename mpl::apply<AccumulatorSet, Feature>::type & +find_accumulator(AccumulatorSet &acc BOOST_ACCUMULATORS_PROTO_DISABLE_IF_IS_CONST(AccumulatorSet)) +{ + return acc.template extract<Feature>(); +} + +/// \overload +template<typename Feature, typename AccumulatorSet> +typename mpl::apply<AccumulatorSet, Feature>::type const & +find_accumulator(AccumulatorSet const &acc) +{ + return acc.template extract<Feature>(); +} + +/////////////////////////////////////////////////////////////////////////////// +// extract_result +// extract a result from an accumulator set +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN(z, n, _) \ + 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) \ + ) \ + { \ + return find_accumulator<Feature>(acc).result( \ + detail::accumulator_params()( \ + acc \ + BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a) \ + ) \ + ); \ + } + +BOOST_PP_REPEAT( + BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , BOOST_ACCUMULATORS_EXTRACT_RESULT_FUN + , _ +) + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/droppable_accumulator.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/droppable_accumulator.hpp new file mode 100644 index 00000000000..0e882b5c35d --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/droppable_accumulator.hpp @@ -0,0 +1,328 @@ +/////////////////////////////////////////////////////////////////////////////// +// droppable_accumulator.hpp +// +// Copyright 2005 Eric Niebler. 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_FRAMEWORK_ACCUMULATORS_DROPPABLE_ACCUMULATOR_HPP_EAN_13_12_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_DROPPABLE_ACCUMULATOR_HPP_EAN_13_12_2005 + +#include <new> +#include <boost/assert.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/aligned_storage.hpp> +#include <boost/accumulators/framework/depends_on.hpp> // for feature_of +#include <boost/accumulators/framework/parameters/accumulator.hpp> // for accumulator + +namespace boost { namespace accumulators +{ + + template<typename Accumulator> + struct droppable_accumulator; + + namespace detail + { + /////////////////////////////////////////////////////////////////////////////// + // add_ref_visitor + // a fusion function object for add_ref'ing accumulators + template<typename Args> + struct add_ref_visitor + { + explicit add_ref_visitor(Args const &args) + : args_(args) + { + } + + template<typename Accumulator> + void operator ()(Accumulator &acc) const + { + typedef typename Accumulator::feature_tag::dependencies dependencies; + + acc.add_ref(this->args_); + + // Also add_ref accumulators that this feature depends on + this->args_[accumulator].template + visit_if<detail::contains_feature_of_<dependencies> >( + *this + ); + } + + private: + add_ref_visitor &operator =(add_ref_visitor const &); + Args const &args_; + }; + + template<typename Args> + add_ref_visitor<Args> make_add_ref_visitor(Args const &args) + { + return add_ref_visitor<Args>(args); + } + + /////////////////////////////////////////////////////////////////////////////// + // drop_visitor + // a fusion function object for dropping accumulators + template<typename Args> + struct drop_visitor + { + explicit drop_visitor(Args const &args) + : args_(args) + { + } + + template<typename Accumulator> + void operator ()(Accumulator &acc) const + { + if(typename Accumulator::is_droppable()) + { + typedef typename Accumulator::feature_tag::dependencies dependencies; + + acc.drop(this->args_); + // Also drop accumulators that this feature depends on + this->args_[accumulator].template + visit_if<detail::contains_feature_of_<dependencies> >( + *this + ); + } + } + + private: + drop_visitor &operator =(drop_visitor const &); + Args const &args_; + }; + + template<typename Args> + drop_visitor<Args> make_drop_visitor(Args const &args) + { + return drop_visitor<Args>(args); + } + } + + ////////////////////////////////////////////////////////////////////////// + // droppable_accumulator_base + template<typename Accumulator> + struct droppable_accumulator_base + : Accumulator + { + typedef droppable_accumulator_base base; + typedef mpl::true_ is_droppable; + typedef typename Accumulator::result_type result_type; + + template<typename Args> + droppable_accumulator_base(Args const &args) + : Accumulator(args) + , ref_count_(0) + { + } + + droppable_accumulator_base(droppable_accumulator_base const &that) + : Accumulator(*static_cast<Accumulator const *>(&that)) + , ref_count_(that.ref_count_) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + if(!this->is_dropped()) + { + this->Accumulator::operator ()(args); + } + } + + template<typename Args> + void add_ref(Args const &) + { + ++this->ref_count_; + } + + template<typename Args> + void drop(Args const &args) + { + BOOST_ASSERT(0 < this->ref_count_); + if(1 == this->ref_count_) + { + static_cast<droppable_accumulator<Accumulator> *>(this)->on_drop(args); + } + --this->ref_count_; + } + + bool is_dropped() const + { + return 0 == this->ref_count_; + } + + private: + int ref_count_; + }; + + ////////////////////////////////////////////////////////////////////////// + // droppable_accumulator + // this can be specialized for any type that needs special handling + template<typename Accumulator> + struct droppable_accumulator + : droppable_accumulator_base<Accumulator> + { + template<typename Args> + droppable_accumulator(Args const &args) + : droppable_accumulator::base(args) + { + } + + droppable_accumulator(droppable_accumulator const &that) + : droppable_accumulator::base(*static_cast<typename droppable_accumulator::base const *>(&that)) + { + } + }; + + ////////////////////////////////////////////////////////////////////////// + // with_cached_result + template<typename Accumulator> + struct with_cached_result + : Accumulator + { + typedef typename Accumulator::result_type result_type; + + template<typename Args> + with_cached_result(Args const &args) + : Accumulator(args) + , cache() + { + } + + with_cached_result(with_cached_result const &that) + : Accumulator(*static_cast<Accumulator const *>(&that)) + , cache() + { + if(that.has_result()) + { + this->set(that.get()); + } + } + + ~with_cached_result() + { + // Since this is a base class of droppable_accumulator_base, + // this destructor is called before any of droppable_accumulator_base's + // members get cleaned up, including is_dropped, so the following + // call to has_result() is valid. + if(this->has_result()) + { + this->get().~result_type(); + } + } + + template<typename Args> + void on_drop(Args const &args) + { + // cache the result at the point this calculation was dropped + BOOST_ASSERT(!this->has_result()); + this->set(this->Accumulator::result(args)); + } + + template<typename Args> + result_type result(Args const &args) const + { + return this->has_result() ? this->get() : this->Accumulator::result(args); + } + + private: + with_cached_result &operator =(with_cached_result const &); + + void set(result_type const &r) + { + ::new(this->cache.address()) result_type(r); + } + + result_type const &get() const + { + return *static_cast<result_type const *>(this->cache.address()); + } + + bool has_result() const + { + typedef with_cached_result<Accumulator> this_type; + typedef droppable_accumulator_base<this_type> derived_type; + return static_cast<derived_type const *>(this)->is_dropped(); + } + + aligned_storage<sizeof(result_type)> cache; + }; + + namespace tag + { + template<typename Feature> + struct as_droppable + { + typedef droppable<Feature> type; + }; + + template<typename Feature> + struct as_droppable<droppable<Feature> > + { + typedef droppable<Feature> type; + }; + + ////////////////////////////////////////////////////////////////////////// + // droppable + template<typename Feature> + struct droppable + : as_feature<Feature>::type + { + typedef typename as_feature<Feature>::type feature_type; + typedef typename feature_type::dependencies tmp_dependencies_; + + typedef + typename mpl::transform< + typename feature_type::dependencies + , as_droppable<mpl::_1> + >::type + dependencies; + + struct impl + { + template<typename Sample, typename Weight> + struct apply + { + typedef + droppable_accumulator< + typename mpl::apply2<typename feature_type::impl, Sample, Weight>::type + > + type; + }; + }; + }; + } + + // make droppable<tag::feature(modifier)> work + template<typename Feature> + struct as_feature<tag::droppable<Feature> > + { + typedef tag::droppable<typename as_feature<Feature>::type> type; + }; + + // make droppable<tag::mean> work with non-void weights (should become + // droppable<tag::weighted_mean> + template<typename Feature> + struct as_weighted_feature<tag::droppable<Feature> > + { + typedef tag::droppable<typename as_weighted_feature<Feature>::type> type; + }; + + // for the purposes of feature-based dependency resolution, + // droppable<Foo> provides the same feature as Foo + template<typename Feature> + struct feature_of<tag::droppable<Feature> > + : feature_of<Feature> + { + }; + + // Note: Usually, the extractor is pulled into the accumulators namespace with + // a using directive, not the tag. But the droppable<> feature doesn't have an + // extractor, so we can put the droppable tag in the accumulators namespace + // without fear of a name conflict. + using tag::droppable; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/external_accumulator.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/external_accumulator.hpp new file mode 100644 index 00000000000..71dce42e51b --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/external_accumulator.hpp @@ -0,0 +1,108 @@ +/////////////////////////////////////////////////////////////////////////////// +// external_accumulator.hpp +// +// Copyright 2005 Eric Niebler. 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_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_EXTERNAL_ACCUMULATOR_HPP_EAN_01_12_2005 + +#include <boost/mpl/placeholders.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/accumulators/reference_accumulator.hpp> + +namespace boost { namespace accumulators { namespace impl +{ + + ////////////////////////////////////////////////////////////////////////// + // external_impl + /// INTERNAL ONLY + /// + template<typename Accumulator, typename Tag> + struct external_impl + : accumulator_base + { + typedef typename Accumulator::result_type result_type; + typedef typename detail::feature_tag<Accumulator>::type feature_tag; + + external_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + return this->extract_(args, args[parameter::keyword<Tag>::get() | 0]); + } + + private: + + template<typename Args> + static result_type extract_(Args const &args, int) + { + // No named parameter passed to the extractor. Maybe the external + // feature is held by reference<>. + extractor<feature_tag> extract; + return extract(accumulators::reference_tag<Tag>(args)); + } + + template<typename Args, typename AccumulatorSet> + static result_type extract_(Args const &, AccumulatorSet const &acc) + { + // OK, a named parameter for this external feature was passed to the + // extractor, so use that. + extractor<feature_tag> extract; + return extract(acc); + } + }; + +} // namespace impl + +namespace tag +{ + ////////////////////////////////////////////////////////////////////////// + // external + template<typename Feature, typename Tag, typename AccumulatorSet> + struct external + : depends_on<reference<AccumulatorSet, Tag> > + { + typedef + accumulators::impl::external_impl< + detail::to_accumulator<Feature, mpl::_1, mpl::_2> + , Tag + > + impl; + }; + + template<typename Feature, typename Tag> + struct external<Feature, Tag, void> + : depends_on<> + { + typedef + accumulators::impl::external_impl< + detail::to_accumulator<Feature, mpl::_1, mpl::_2> + , Tag + > + impl; + }; +} + +// for the purposes of feature-based dependency resolution, +// external_accumulator<Feature, Tag> provides the same feature as Feature +template<typename Feature, typename Tag, typename AccumulatorSet> +struct feature_of<tag::external<Feature, Tag, AccumulatorSet> > + : feature_of<Feature> +{ +}; + +// Note: Usually, the extractor is pulled into the accumulators namespace with +// a using directive, not the tag. But the external<> feature doesn't have an +// extractor, so we can put the external tag in the accumulators namespace +// without fear of a name conflict. +using tag::external; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/reference_accumulator.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/reference_accumulator.hpp new file mode 100644 index 00000000000..bf4252ca6a9 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/reference_accumulator.hpp @@ -0,0 +1,89 @@ +/////////////////////////////////////////////////////////////////////////////// +// reference_accumulator.hpp +// +// Copyright 2005 Eric Niebler. 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_FRAMEWORK_ACCUMULATORS_REFERENCE_ACCUMULATOR_HPP_EAN_03_23_2006 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_REFERENCE_ACCUMULATOR_HPP_EAN_03_23_2006 + +#include <boost/ref.hpp> +#include <boost/mpl/always.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + ////////////////////////////////////////////////////////////////////////// + // reference_accumulator_impl + // + template<typename Referent, typename Tag> + struct reference_accumulator_impl + : accumulator_base + { + typedef Referent &result_type; + + template<typename Args> + reference_accumulator_impl(Args const &args) + : ref(args[parameter::keyword<Tag>::get()]) + { + } + + result_type result(dont_care) const + { + return this->ref; + } + + private: + reference_wrapper<Referent> ref; + }; +} // namespace impl + +namespace tag +{ + ////////////////////////////////////////////////////////////////////////// + // reference_tag + template<typename Tag> + struct reference_tag + { + }; + + ////////////////////////////////////////////////////////////////////////// + // reference + template<typename Referent, typename Tag> + struct reference + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::reference_accumulator_impl<Referent, Tag> > impl; + }; +} + +namespace extract +{ + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, reference, (typename)(typename)) + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, reference_tag, (typename)) +} + +using extract::reference; +using extract::reference_tag; + +// Map all reference<V,T> features to reference_tag<T> so +// that references can be extracted using reference_tag<T> +// without specifying the referent type. +template<typename ValueType, typename Tag> +struct feature_of<tag::reference<ValueType, Tag> > + : feature_of<tag::reference_tag<Tag> > +{ +}; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/value_accumulator.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/value_accumulator.hpp new file mode 100644 index 00000000000..02bf7f34993 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/accumulators/value_accumulator.hpp @@ -0,0 +1,89 @@ +/////////////////////////////////////////////////////////////////////////////// +// value_accumulator.hpp +// +// Copyright 2005 Eric Niebler, Daniel Egloff. 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_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006 +#define BOOST_ACCUMULATORS_FRAMEWORK_ACCUMULATORS_VALUE_ACCUMULATOR_HPP_EAN_03_23_2006 + +#include <boost/mpl/always.hpp> +#include <boost/parameter/keyword.hpp> +#include <boost/accumulators/framework/depends_on.hpp> // for feature_tag +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + + ////////////////////////////////////////////////////////////////////////// + // value_accumulator_impl + template<typename ValueType, typename Tag> + struct value_accumulator_impl + : accumulator_base + { + typedef ValueType result_type; + + template<typename Args> + value_accumulator_impl(Args const &args) + : val(args[parameter::keyword<Tag>::get()]) + { + } + + result_type result(dont_care) const + { + return this->val; + } + + private: + ValueType val; + }; + +} // namespace impl + +namespace tag +{ + ////////////////////////////////////////////////////////////////////////// + // value_tag + template<typename Tag> + struct value_tag + { + }; + + ////////////////////////////////////////////////////////////////////////// + // value + template<typename ValueType, typename Tag> + struct value + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::value_accumulator_impl<ValueType, Tag> > impl; + }; +} + +namespace extract +{ + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value, (typename)(typename)) + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, value_tag, (typename)) +} + +using extract::value; +using extract::value_tag; + +// Map all value<V,T> features to value_tag<T> so +// that values can be extracted using value_tag<T> +// without specifying the value type. +template<typename ValueType, typename Tag> +struct feature_of<tag::value<ValueType, Tag> > + : feature_of<tag::value_tag<Tag> > +{ +}; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/depends_on.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/depends_on.hpp new file mode 100644 index 00000000000..c3289729463 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/depends_on.hpp @@ -0,0 +1,448 @@ +/////////////////////////////////////////////////////////////////////////////// +// depends_on.hpp +// +// Copyright 2005 Eric Niebler. 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_FRAMEWORK_DEPENDS_ON_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_DEPENDS_ON_HPP_EAN_28_10_2005 + +#include <boost/version.hpp> +#include <boost/mpl/end.hpp> +#include <boost/mpl/map.hpp> +#include <boost/mpl/set.hpp> +#include <boost/mpl/copy.hpp> +#include <boost/mpl/fold.hpp> +#include <boost/mpl/size.hpp> +#include <boost/mpl/sort.hpp> +#include <boost/mpl/insert.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/mpl/remove.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/mpl/inherit.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/equal_to.hpp> +#include <boost/mpl/contains.hpp> +#include <boost/mpl/transform.hpp> +#include <boost/mpl/is_sequence.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/mpl/insert_range.hpp> +#include <boost/mpl/back_inserter.hpp> +#include <boost/mpl/transform_view.hpp> +#include <boost/mpl/inherit_linearly.hpp> +#include <boost/type_traits/is_base_and_derived.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/facilities/intercept.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> +#include <boost/fusion/include/next.hpp> +#include <boost/fusion/include/equal_to.hpp> +#include <boost/fusion/include/value_of.hpp> +#include <boost/fusion/include/mpl.hpp> +#include <boost/fusion/include/end.hpp> +#include <boost/fusion/include/begin.hpp> +#include <boost/fusion/include/cons.hpp> + +namespace boost { namespace accumulators +{ + /////////////////////////////////////////////////////////////////////////// + // as_feature + template<typename Feature> + struct as_feature + { + typedef Feature type; + }; + + /////////////////////////////////////////////////////////////////////////// + // weighted_feature + template<typename Feature> + struct as_weighted_feature + { + typedef Feature type; + }; + + /////////////////////////////////////////////////////////////////////////// + // feature_of + template<typename Feature> + struct feature_of + { + typedef Feature type; + }; + + namespace detail + { + /////////////////////////////////////////////////////////////////////////// + // feature_tag + template<typename Accumulator> + struct feature_tag + { + typedef typename Accumulator::feature_tag type; + }; + + template<typename Feature> + struct undroppable + { + typedef Feature type; + }; + + template<typename Feature> + struct undroppable<tag::droppable<Feature> > + { + typedef Feature type; + }; + + // For the purpose of determining whether one feature depends on another, + // disregard whether the feature is droppable or not. + template<typename A, typename B> + struct is_dependent_on + : is_base_and_derived< + typename feature_of<typename undroppable<B>::type>::type + , typename undroppable<A>::type + > + {}; + + template<typename Feature> + struct dependencies_of + { + typedef typename Feature::dependencies type; + }; + + // Should use mpl::insert_range, but doesn't seem to work with mpl sets + template<typename Set, typename Range> + struct set_insert_range + : mpl::fold< + Range + , Set + , mpl::insert<mpl::_1, mpl::_2> + > + {}; + + template<typename Features> + struct collect_abstract_features + : mpl::fold< + Features + , mpl::set0<> + , set_insert_range< + mpl::insert<mpl::_1, feature_of<mpl::_2> > + , collect_abstract_features<dependencies_of<mpl::_2> > + > + > + {}; + + template<typename Features> + struct depends_on_base + : mpl::inherit_linearly< + typename mpl::sort< + typename mpl::copy< + typename collect_abstract_features<Features>::type + , mpl::back_inserter<mpl::vector0<> > + >::type + , is_dependent_on<mpl::_1, mpl::_2> + >::type + // Don't inherit multiply from a feature + , mpl::if_< + is_dependent_on<mpl::_1, mpl::_2> + , mpl::_1 + , mpl::inherit<mpl::_1, mpl::_2> + > + >::type + { + }; + } + + /////////////////////////////////////////////////////////////////////////// + /// depends_on + template<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature)> + struct depends_on + : detail::depends_on_base< + typename mpl::transform< + mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)> + , as_feature<mpl::_1> + >::type + > + { + typedef mpl::false_ is_weight_accumulator; + typedef + typename mpl::transform< + mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)> + , as_feature<mpl::_1> + >::type + dependencies; + }; + + namespace detail + { + template<typename Feature> + struct matches_feature + { + template<typename Accumulator> + struct apply + : is_same< + typename feature_of<typename as_feature<Feature>::type>::type + , typename feature_of<typename as_feature<typename feature_tag<Accumulator>::type>::type>::type + > + {}; + }; + + template<typename Features, typename Accumulator> + struct contains_feature_of + { + typedef + mpl::transform_view<Features, feature_of<as_feature<mpl::_> > > + features_list; + + typedef + typename feature_of<typename feature_tag<Accumulator>::type>::type + the_feature; + + typedef + typename mpl::contains<features_list, the_feature>::type + type; + }; + + // This is to work around a bug in early versions of Fusion which caused + // a compile error if contains_feature_of<List, mpl::_> is used as a + // predicate to fusion::find_if + template<typename Features> + struct contains_feature_of_ + { + template<typename Accumulator> + struct apply + : contains_feature_of<Features, Accumulator> + {}; + }; + + template< + typename First + , typename Last + , bool is_empty = fusion::result_of::equal_to<First, Last>::value + > + struct build_acc_list; + + template<typename First, typename Last> + struct build_acc_list<First, Last, true> + { + typedef fusion::nil type; + + template<typename Args> + static fusion::nil + call(Args const &, First const&, Last const&) + { + return fusion::nil(); + } + }; + + template<typename First, typename Last> + struct build_acc_list<First, Last, false> + { + typedef + build_acc_list<typename fusion::result_of::next<First>::type, Last> + next_build_acc_list; + + typedef fusion::cons< + typename fusion::result_of::value_of<First>::type + , typename next_build_acc_list::type> + type; + + template<typename Args> + static type + call(Args const &args, First const& f, Last const& l) + { + return type(args, next_build_acc_list::call(args, fusion::next(f), l)); + } + }; + + namespace meta + { + template<typename Sequence> + struct make_acc_list + : build_acc_list< + typename fusion::result_of::begin<Sequence>::type + , typename fusion::result_of::end<Sequence>::type + > + {}; + } + + 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>::call(args, fusion::begin(seq), fusion::end(seq)); + } + + /////////////////////////////////////////////////////////////////////////// + // checked_as_weighted_feature + template<typename Feature> + struct checked_as_weighted_feature + { + typedef typename as_feature<Feature>::type feature_type; + typedef typename as_weighted_feature<feature_type>::type type; + // weighted and non-weighted flavors should provide the same feature. + BOOST_MPL_ASSERT(( + is_same< + typename feature_of<feature_type>::type + , typename feature_of<type>::type + > + )); + }; + + /////////////////////////////////////////////////////////////////////////// + // as_feature_list + template<typename Features, typename Weight> + struct as_feature_list + : mpl::transform_view<Features, checked_as_weighted_feature<mpl::_1> > + { + }; + + template<typename Features> + struct as_feature_list<Features, void> + : mpl::transform_view<Features, as_feature<mpl::_1> > + { + }; + + /////////////////////////////////////////////////////////////////////////// + // accumulator_wrapper + template<typename Accumulator, typename Feature> + struct accumulator_wrapper + : Accumulator + { + typedef Feature feature_tag; + + accumulator_wrapper(accumulator_wrapper const &that) + : Accumulator(*static_cast<Accumulator const *>(&that)) + { + } + + template<typename Args> + accumulator_wrapper(Args const &args) + : Accumulator(args) + { + } + }; + + /////////////////////////////////////////////////////////////////////////// + // to_accumulator + template<typename Feature, typename Sample, typename Weight> + struct to_accumulator + { + typedef + accumulator_wrapper< + typename mpl::apply2<typename Feature::impl, Sample, Weight>::type + , Feature + > + type; + }; + + template<typename Feature, typename Sample, typename Weight, typename Tag, typename AccumulatorSet> + struct to_accumulator<Feature, Sample, tag::external<Weight, Tag, AccumulatorSet> > + { + BOOST_MPL_ASSERT((is_same<Tag, void>)); + BOOST_MPL_ASSERT((is_same<AccumulatorSet, void>)); + + typedef + accumulator_wrapper< + typename mpl::apply2<typename Feature::impl, Sample, Weight>::type + , Feature + > + accumulator_type; + + typedef + typename mpl::if_< + typename Feature::is_weight_accumulator + , accumulator_wrapper<impl::external_impl<accumulator_type, tag::weights>, Feature> + , accumulator_type + >::type + type; + }; + + // BUGBUG work around an MPL bug wrt map insertion + template<typename FeatureMap, typename Feature> + struct insert_feature + : mpl::eval_if< + mpl::has_key<FeatureMap, typename feature_of<Feature>::type> + , mpl::identity<FeatureMap> + , mpl::insert<FeatureMap, mpl::pair<typename feature_of<Feature>::type, Feature> > + > + { + }; + + template<typename FeatureMap, typename Feature, typename Weight> + struct insert_dependencies + : mpl::fold< + as_feature_list<typename Feature::dependencies, Weight> + , FeatureMap + , insert_dependencies< + insert_feature<mpl::_1, mpl::_2> + , mpl::_2 + , Weight + > + > + { + }; + + template<typename FeatureMap, typename Features, typename Weight> + struct insert_sequence + : mpl::fold< // BUGBUG should use insert_range, but doesn't seem to work for maps + as_feature_list<Features, Weight> + , FeatureMap + , insert_feature<mpl::_1, mpl::_2> + > + { + }; + + template<typename Features, typename Sample, typename Weight> + struct make_accumulator_tuple + { + typedef + typename mpl::fold< + as_feature_list<Features, Weight> + , mpl::map0<> + , mpl::if_< + mpl::is_sequence<mpl::_2> + , insert_sequence<mpl::_1, mpl::_2, Weight> + , insert_feature<mpl::_1, mpl::_2> + > + >::type + feature_map; + + // for each element in the map, add its dependencies also + typedef + typename mpl::fold< + feature_map + , feature_map + , insert_dependencies<mpl::_1, mpl::second<mpl::_2>, Weight> + >::type + feature_map_with_dependencies; + + // turn the map into a vector so we can sort it + typedef + typename mpl::insert_range< + mpl::vector<> + , mpl::end<mpl::vector<> >::type + , mpl::transform_view<feature_map_with_dependencies, mpl::second<mpl::_1> > + >::type + feature_vector_with_dependencies; + + // sort the features according to which is derived from which + typedef + typename mpl::sort< + feature_vector_with_dependencies + , is_dependent_on<mpl::_2, mpl::_1> + >::type + sorted_feature_vector; + + // From the vector of features, construct a vector of accumulators + typedef + typename mpl::transform< + sorted_feature_vector + , to_accumulator<mpl::_1, Sample, Weight> + >::type + type; + }; + + } // namespace detail + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/external.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/external.hpp new file mode 100644 index 00000000000..dbd5d916939 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/external.hpp @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////// +// external.hpp +// +// Copyright 2005 Eric Niebler. 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_FRAMEWORK_EXTERNAL_HPP_EAN_01_12_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_EXTERNAL_HPP_EAN_01_12_2005 + +#include <boost/mpl/apply.hpp> +#include <boost/accumulators/framework/accumulators/external_accumulator.hpp> + +//namespace boost { namespace accumulators +//{ +// +///////////////////////////////////////////////////////////////////////////////// +//// external +//// +//template<typename Type> +//struct external +//{ +//}; +// +//}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/extractor.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/extractor.hpp new file mode 100644 index 00000000000..98281cecb9d --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/extractor.hpp @@ -0,0 +1,229 @@ +/////////////////////////////////////////////////////////////////////////////// +// extractor.hpp +// +// Copyright 2005 Eric Niebler. 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_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_FRAMEWORK_EXTRACTOR_HPP_EAN_28_10_2005 + +#include <boost/preprocessor/tuple/rem.hpp> +#include <boost/preprocessor/array/size.hpp> +#include <boost/preprocessor/array/data.hpp> +#include <boost/preprocessor/array/elem.hpp> +#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_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp> +#include <boost/parameter/binding.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> +#include <boost/accumulators/framework/parameters/accumulator.hpp> + +namespace boost { namespace accumulators +{ + +namespace detail +{ + template<typename AccumulatorSet, typename Feature> + struct accumulator_set_result + { + typedef typename as_feature<Feature>::type feature_type; + typedef typename mpl::apply<AccumulatorSet, 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 + >::type + , Feature + > + { + }; + + template<typename A, typename Feature> + struct extractor_result + : mpl::eval_if< + detail::is_accumulator_set<A> + , accumulator_set_result<A, Feature> + , argument_pack_result<A, Feature> + > + { + }; + + template<typename Feature, typename AccumulatorSet> + typename extractor_result<AccumulatorSet, Feature>::type + do_extract(AccumulatorSet const &acc, mpl::true_) + { + typedef typename as_feature<Feature>::type feature_type; + return extract_result<feature_type>(acc); + } + + template<typename Feature, typename Args> + typename extractor_result<Args, Feature>::type + do_extract(Args const &args, mpl::false_) + { + typedef typename as_feature<Feature>::type feature_type; + return find_accumulator<feature_type>(args[accumulator]).result(args); + } + +} // namespace detail + + +/////////////////////////////////////////////////////////////////////////////// +/// Extracts the result associated with Feature from the specified accumulator_set. +template<typename Feature> +struct extractor +{ + typedef extractor<Feature> this_type; + + /// The result meta-function for determining the return type of the extractor + template<typename F> + struct result; + + template<typename A1> + struct result<this_type(A1)> + : detail::extractor_result<A1, Feature> + { + }; + + /// Extract the result associated with Feature from the accumulator set + /// \param acc The accumulator set object from which to extract the result + template<typename Arg1> + typename detail::extractor_result<Arg1, Feature>::type + operator ()(Arg1 const &arg1) const + { + // Arg1 could be an accumulator_set or an argument pack containing + // an accumulator_set. Dispatch accordingly. + return detail::do_extract<Feature>(arg1, detail::is_accumulator_set<Arg1>()); + } + + /// \overload + /// + /// \param a1 Optional named parameter to be passed to the accumulator's result() function. + template<typename AccumulatorSet, typename A1> + typename detail::extractor_result<AccumulatorSet, Feature>::type + operator ()(AccumulatorSet const &acc, A1 const &a1) const + { + BOOST_MPL_ASSERT((detail::is_accumulator_set<AccumulatorSet>)); + typedef typename as_feature<Feature>::type feature_type; + return extract_result<feature_type>(acc, a1); + } + + // ... other overloads generated by Boost.Preprocessor: + + /// INTERNAL ONLY + /// +#define BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP(z, n, _) \ + template<BOOST_PP_ENUM_PARAMS_Z(z, n, typename A)> \ + struct result<this_type(BOOST_PP_ENUM_PARAMS_Z(z, n, A))> \ + : detail::extractor_result<A1, Feature> \ + {}; \ + template< \ + typename AccumulatorSet \ + BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ + > \ + typename detail::extractor_result<AccumulatorSet, Feature>::type \ + operator ()( \ + AccumulatorSet const &acc \ + BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) \ + ) const \ + { \ + BOOST_MPL_ASSERT((detail::is_accumulator_set<AccumulatorSet>)); \ + typedef typename as_feature<Feature>::type feature_type; \ + return extract_result<feature_type>(acc BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a));\ + } + + BOOST_PP_REPEAT_FROM_TO( + 2 + , BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) + , BOOST_ACCUMULATORS_EXTRACTOR_FUN_OP + , _ + ) + + #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED + /// \overload + /// + template<typename AccumulatorSet, typename A1, typename A2, ...> + typename detail::extractor_result<AccumulatorSet, Feature>::type + operator ()(AccumulatorSet const &acc, A1 const &a1, A2 const &a2, ...); + #endif +}; + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_ARRAY_REM(Array) \ + BOOST_PP_TUPLE_REM_CTOR(BOOST_PP_ARRAY_SIZE(Array), BOOST_PP_ARRAY_DATA(Array)) + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_SEQ_REM(Seq) \ + BOOST_ACCUMULATORS_ARRAY_REM(BOOST_PP_SEQ_TO_ARRAY(Seq)) + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_ARGS_OP(s, data, elem) \ + T ## s + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_PARAMS_OP(s, data, elem) \ + elem T ## s + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) \ + Tag::Feature< \ + BOOST_ACCUMULATORS_SEQ_REM( \ + BOOST_PP_SEQ_TRANSFORM(BOOST_ACCUMULATORS_ARGS_OP, ~, ParamsSeq) \ + ) \ + > + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN_IMPL(z, n, Tag, Feature, ParamsSeq) \ + template< \ + BOOST_ACCUMULATORS_SEQ_REM( \ + BOOST_PP_SEQ_TRANSFORM(BOOST_ACCUMULATORS_PARAMS_OP, ~, ParamsSeq) \ + ) \ + , typename Arg1 \ + BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, typename A) \ + > \ + typename boost::accumulators::detail::extractor_result< \ + Arg1 \ + , BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) \ + >::type \ + Feature(Arg1 const &arg1 BOOST_PP_ENUM_TRAILING_BINARY_PARAMS_Z(z, n, A, const &a) ) \ + { \ + typedef BOOST_ACCUMULATORS_MAKE_FEATURE(Tag, Feature, ParamsSeq) feature_type; \ + return boost::accumulators::extractor<feature_type>()( \ + arg1 BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, a)); \ + } + +/// INTERNAL ONLY +/// +#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN(z, n, _) \ + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN_IMPL( \ + z \ + , n \ + , BOOST_PP_ARRAY_ELEM(0, _) \ + , BOOST_PP_ARRAY_ELEM(1, _) \ + , BOOST_PP_ARRAY_ELEM(2, _) \ + ) + +#define BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(Tag, Feature, ParamSeq) \ + BOOST_PP_REPEAT( \ + BOOST_PP_INC(BOOST_ACCUMULATORS_MAX_ARGS) \ + , BOOST_ACCUMULATORS_DEFINE_EXTRACTOR_FUN \ + , (3, (Tag, Feature, ParamSeq)) \ + ) + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/features.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/features.hpp new file mode 100644 index 00000000000..21cae004dae --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/features.hpp @@ -0,0 +1,29 @@ +/////////////////////////////////////////////////////////////////////////////// +// features.hpp +// +// Copyright 2005 Eric Niebler. 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_STATS_HPP_EAN_08_12_2005 +#define BOOST_ACCUMULATORS_STATISTICS_STATS_HPP_EAN_08_12_2005 + +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/mpl/vector.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +// features +// +template<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature)> +struct features + : mpl::vector<BOOST_PP_ENUM_PARAMS(BOOST_ACCUMULATORS_MAX_FEATURES, Feature)> +{ +}; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/accumulator.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/accumulator.hpp new file mode 100644 index 00000000000..525ebb30ba3 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/accumulator.hpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////// +// accumulator.hpp +// +// Copyright 2005 Eric Niebler. 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_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/accumulators/accumulators_fwd.hpp> + +namespace boost { namespace accumulators +{ + +BOOST_PARAMETER_KEYWORD(tag, accumulator) +BOOST_ACCUMULATORS_IGNORE_GLOBAL(accumulator) + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/sample.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/sample.hpp new file mode 100644 index 00000000000..8b227eb3343 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/sample.hpp @@ -0,0 +1,22 @@ +/////////////////////////////////////////////////////////////////////////////// +// sample.hpp +// +// Copyright 2005 Eric Niebler. 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_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/accumulators/accumulators_fwd.hpp> + +namespace boost { namespace accumulators +{ + +BOOST_PARAMETER_KEYWORD(tag, sample) +BOOST_ACCUMULATORS_IGNORE_GLOBAL(sample) + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/weight.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/weight.hpp new file mode 100644 index 00000000000..f36016f3726 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/weight.hpp @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////// +// weight.hpp +// +// Copyright 2005 Eric Niebler. 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_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/accumulators/accumulators_fwd.hpp> + +namespace boost { namespace accumulators +{ + +// The weight of a single sample +BOOST_PARAMETER_KEYWORD(tag, weight) +BOOST_ACCUMULATORS_IGNORE_GLOBAL(weight) + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/weights.hpp b/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/weights.hpp new file mode 100644 index 00000000000..6beae61386c --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/framework/parameters/weights.hpp @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////// +// weights.hpp +// +// Copyright 2005 Eric Niebler. 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_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/accumulators/accumulators_fwd.hpp> + +namespace boost { namespace accumulators +{ + +// The weight accumulator +BOOST_PARAMETER_KEYWORD(tag, weights) +BOOST_ACCUMULATORS_IGNORE_GLOBAL(weights) + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/function1.hpp b/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/function1.hpp new file mode 100644 index 00000000000..282eb1ef3e9 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/function1.hpp @@ -0,0 +1,75 @@ +// Copyright David Abrahams 2006. 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_DETAIL_FUNCTION1_DWA200655_HPP +# define BOOST_DETAIL_FUNCTION1_DWA200655_HPP + +# include <boost/concept_check.hpp> +# include <boost/type_traits/remove_reference.hpp> +# include <boost/type_traits/add_const.hpp> +# include <boost/mpl/apply.hpp> + +namespace boost { namespace detail { + +// A utility for creating unary function objects that play nicely with +// boost::result_of and that handle the forwarding problem. +// +// mpl::apply<F, A0>::type is expected to be a stateless function +// object that accepts an argument of type A0&. It is also expected +// to have a nested ::result_type identical to its return type. +template<typename F> +struct function1 +{ + template<typename Signature> + struct result + {}; + + template<typename This, typename A0> + struct result<This(A0)> + { + // How adding const to arguments handles rvalues. + // + // if A0 is arg0 is represents actual argument + // -------- ------- -------------------------- + // T const & T const const T lvalue + // T & T non-const T lvalue + // T const T const const T rvalue + // T T const non-const T rvalue + typedef typename remove_reference< + typename add_const< A0 >::type + >::type arg0; + + typedef typename mpl::apply1<F, arg0>::type impl; + typedef typename impl::result_type type; + }; + + // Handles mutable lvalues + template<typename A0> + typename result<function1(A0 &)>::type + operator ()(A0 &a0) const + { + typedef typename result<function1(A0 &)>::impl impl; + typedef typename result<function1(A0 &)>::type type; + typedef A0 &arg0; + BOOST_CONCEPT_ASSERT((UnaryFunction<impl, type, arg0>)); + //boost::function_requires<UnaryFunctionConcept<impl, type, arg0> >(); + return impl()(a0); + } + + // Handles const lvalues and all rvalues + template<typename A0> + typename result<function1(A0 const &)>::type + operator ()(A0 const &a0) const + { + typedef typename result<function1(A0 const &)>::impl impl; + typedef typename result<function1(A0 const &)>::type type; + typedef A0 const &arg0; + BOOST_CONCEPT_ASSERT((UnaryFunction<impl, type, arg0>)); + //boost::function_requires<UnaryFunctionConcept<impl, type, arg0> >(); + return impl()(a0); + } +}; + +}} // namespace boost::detail + +#endif // BOOST_DETAIL_FUNCTION1_DWA200655_HPP diff --git a/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/function2.hpp b/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/function2.hpp new file mode 100644 index 00000000000..daf3c4d4e76 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/function2.hpp @@ -0,0 +1,10 @@ +// Copyright David Abrahams 2006. 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_DETAIL_FUNCTION2_DWA200655_HPP +# define BOOST_DETAIL_FUNCTION2_DWA200655_HPP + +# define args (2) +# include <boost/accumulators/numeric/detail/function_n.hpp> + +#endif // BOOST_DETAIL_FUNCTION2_DWA200655_HPP diff --git a/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/function_n.hpp b/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/function_n.hpp new file mode 100644 index 00000000000..47c42ed05b8 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/function_n.hpp @@ -0,0 +1,148 @@ +// Copyright David Abrahams 2006. 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) +// +// #include guards intentionally disabled. +// #ifndef BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP +// # define BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP + +#include <boost/mpl/void.hpp> +#include <boost/mpl/apply.hpp> + +#include <boost/preprocessor/control/if.hpp> +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/punctuation/comma_if.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_trailing_params.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/seq/fold_left.hpp> +#include <boost/preprocessor/seq/seq.hpp> +#include <boost/preprocessor/seq/for_each.hpp> +#include <boost/preprocessor/seq/for_each_i.hpp> +#include <boost/preprocessor/seq/for_each_product.hpp> +#include <boost/preprocessor/seq/size.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/type_traits/remove_reference.hpp> + +namespace boost { namespace detail { + +# define BOOST_DETAIL_default_arg(z, n, _) \ + typedef mpl::void_ BOOST_PP_CAT(arg, n); + +# define BOOST_DETAIL_function_arg(z, n, _) \ + typedef typename remove_reference< \ + typename add_const< BOOST_PP_CAT(A, n) >::type \ + >::type BOOST_PP_CAT(arg, n); + +#define BOOST_DETAIL_cat_arg_counts(s, state, n) \ + BOOST_PP_IF( \ + n \ + , BOOST_PP_CAT(state, BOOST_PP_CAT(_, n)) \ + , state \ + ) \ + /**/ + +#define function_name \ + BOOST_PP_SEQ_FOLD_LEFT( \ + BOOST_DETAIL_cat_arg_counts \ + , BOOST_PP_CAT(function, BOOST_PP_SEQ_HEAD(args)) \ + , BOOST_PP_SEQ_TAIL(args)(0) \ + ) \ + /**/ + +template<typename F> +struct function_name +{ + BOOST_PP_REPEAT( + BOOST_MPL_LIMIT_METAFUNCTION_ARITY + , BOOST_DETAIL_default_arg + , ~ + ) + + template<typename Signature> + struct result {}; + +#define BOOST_DETAIL_function_result(r, _, n) \ + template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A)> \ + struct result<This(BOOST_PP_ENUM_PARAMS(n, A))> \ + { \ + BOOST_PP_REPEAT(n, BOOST_DETAIL_function_arg, ~) \ + typedef \ + typename BOOST_PP_CAT(mpl::apply, BOOST_MPL_LIMIT_METAFUNCTION_ARITY)<\ + F \ + BOOST_PP_ENUM_TRAILING_PARAMS( \ + BOOST_MPL_LIMIT_METAFUNCTION_ARITY \ + , arg \ + ) \ + >::type \ + impl; \ + typedef typename impl::result_type type; \ + }; \ + /**/ + + BOOST_PP_SEQ_FOR_EACH(BOOST_DETAIL_function_result, _, args) + +# define arg_type(r, _, i, is_const) \ + BOOST_PP_COMMA_IF(i) BOOST_PP_CAT(A, i) BOOST_PP_CAT(const_if, is_const) & + +# define result_(r, n, constness) \ + typename result< \ + function_name( \ + BOOST_PP_SEQ_FOR_EACH_I_R(r, arg_type, ~, constness) \ + ) \ + > \ + /**/ + +# define param(r, _, i, is_const) BOOST_PP_COMMA_IF(i) \ + BOOST_PP_CAT(A, i) BOOST_PP_CAT(const_if, is_const) & BOOST_PP_CAT(x, i) + +# define param_list(r, n, constness) \ + BOOST_PP_SEQ_FOR_EACH_I_R(r, param, ~, constness) + +# define call_operator(r, constness) \ + template<BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(constness), typename A)> \ + result_(r, BOOST_PP_SEQ_SIZE(constness), constness)::type \ + operator ()( param_list(r, BOOST_PP_SEQ_SIZE(constness), constness) ) const \ + { \ + typedef result_(r, BOOST_PP_SEQ_SIZE(constness), constness)::impl impl; \ + return impl()(BOOST_PP_ENUM_PARAMS(BOOST_PP_SEQ_SIZE(constness), x)); \ + } \ + /**/ + +# define const_if0 +# define const_if1 const + +# define bits(z, n, _) ((0)(1)) + +# define gen_operator(r, _, n) \ + BOOST_PP_SEQ_FOR_EACH_PRODUCT_R( \ + r \ + , call_operator \ + , BOOST_PP_REPEAT(n, bits, ~) \ + ) \ + /**/ + + BOOST_PP_SEQ_FOR_EACH( + gen_operator + , ~ + , args + ) + +# undef bits +# undef const_if1 +# undef const_if0 +# undef call_operator +# undef param_list +# undef param +# undef result_ +# undef default_ +# undef arg_type +# undef gen_operator +# undef function_name + +# undef args +}; + +}} // namespace boost::detail + +//#endif // BOOST_DETAIL_FUNCTION_N_DWA2006514_HPP diff --git a/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/pod_singleton.hpp b/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/pod_singleton.hpp new file mode 100644 index 00000000000..317d85fb24a --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/numeric/detail/pod_singleton.hpp @@ -0,0 +1,20 @@ +// Copyright David Abrahams 2006. 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_DETAIL_POD_SINGLETON_DWA200655_HPP +# define BOOST_DETAIL_POD_SINGLETON_DWA200655_HPP + +namespace boost { namespace detail { + +template<typename T> +struct pod_singleton +{ + static T instance; +}; + +template<typename T> +T pod_singleton<T>::instance; + +}} // namespace boost::detail + +#endif // BOOST_DETAIL_POD_SINGLETON_DWA200655_HPP diff --git a/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional.hpp b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional.hpp new file mode 100644 index 00000000000..d5d79f5c492 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional.hpp @@ -0,0 +1,521 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file functional.hpp +/// +// Copyright 2005 Eric Niebler. 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_NUMERIC_FUNCTIONAL_HPP_EAN_08_12_2005 +#define BOOST_NUMERIC_FUNCTIONAL_HPP_EAN_08_12_2005 + +#include <limits> +#include <functional> +#include <boost/static_assert.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/and.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/is_empty.hpp> +#include <boost/type_traits/is_integral.hpp> +#include <boost/type_traits/is_floating_point.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/typeof/typeof.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> +#include <boost/accumulators/numeric/detail/function1.hpp> +#include <boost/accumulators/numeric/detail/function2.hpp> +#include <boost/accumulators/numeric/detail/pod_singleton.hpp> + +#ifdef BOOST_NUMERIC_FUNCTIONAL_STD_VECTOR_SUPPORT +# include <boost/accumulators/numeric/functional/vector.hpp> +#endif + +#ifdef BOOST_NUMERIC_FUNCTIONAL_STD_VALARRAY_SUPPORT +# include <boost/accumulators/numeric/functional/valarray.hpp> +#endif + +#ifdef BOOST_NUMERIC_FUNCTIONAL_STD_COMPLEX_SUPPORT +# include <boost/accumulators/numeric/functional/complex.hpp> +#endif + +/// INTERNAL ONLY +/// +#define BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED + +#ifdef BOOST_NUMERIC_FUNCTIONAL_DOXYGEN_INVOKED +// Hack to make Doxygen show the inheritance relationships +/// INTERNAL ONLY +/// +namespace std +{ + /// INTERNAL ONLY + /// + template<class Arg, class Ret> struct unary_function {}; + /// INTERNAL ONLY + /// + template<class Left, class Right, class Ret> struct binary_function {}; +} +#endif + +namespace boost { namespace numeric +{ + namespace functional + { + /// INTERNAL ONLY + /// + template<typename A0, typename A1> + struct are_integral + : mpl::and_<is_integral<A0>, is_integral<A1> > + {}; + + template<typename Left, typename Right> + struct left_ref + { + typedef Left &type; + }; + + namespace detail + { + template<typename T> + T &lvalue_of(); + } + } + + // TODO: handle complex weight, valarray, MTL vectors + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(Name, Op) \ + namespace functional \ + { \ + template<typename Arg> \ + struct result_of_ ## Name \ + { \ + BOOST_TYPEOF_NESTED_TYPEDEF_TPL( \ + nested \ + , Op boost::numeric::functional::detail::lvalue_of<Arg>() \ + ) \ + typedef typename nested::type type; \ + }; \ + template<typename Arg, typename EnableIf> \ + struct Name ## _base \ + : std::unary_function< \ + typename remove_const<Arg>::type \ + , typename result_of_ ## Name<Arg>::type \ + > \ + { \ + typename result_of_ ## Name<Arg>::type operator ()(Arg &arg) const \ + { \ + return Op arg; \ + } \ + }; \ + template<typename Arg, typename ArgTag> \ + struct Name \ + : Name ## _base<Arg, void> \ + {}; \ + } \ + namespace op \ + { \ + struct Name \ + : boost::detail::function1<functional::Name<_, functional::tag<_> > > \ + {}; \ + } \ + namespace \ + { \ + op::Name const &Name = boost::detail::pod_singleton<op::Name>::instance; \ + } \ + /**/ + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(Name, Op, RetType) \ + namespace functional \ + { \ + template<typename Left, typename Right, typename EnableIf> \ + struct result_of_ ## Name \ + { \ + RetType(Left, Op, Right) \ + }; \ + template<typename Left, typename Right, typename EnableIf> \ + struct Name ## _base \ + : std::binary_function< \ + typename remove_const<Left>::type \ + , typename remove_const<Right>::type \ + , typename result_of_ ## Name<Left, Right>::type \ + > \ + { \ + typename result_of_ ## Name<Left, Right>::type \ + operator ()(Left &left, Right &right) const \ + { \ + return left Op right; \ + } \ + }; \ + template<typename Left, typename Right, typename LeftTag, typename RightTag> \ + struct Name \ + : Name ## _base<Left, Right, void> \ + {}; \ + } \ + namespace op \ + { \ + struct Name \ + : boost::detail::function2< \ + functional::Name<_1, _2, functional::tag<_1>, functional::tag<_2> > \ + > \ + {}; \ + } \ + namespace \ + { \ + op::Name const &Name = boost::detail::pod_singleton<op::Name>::instance; \ + } \ + BOOST_ACCUMULATORS_IGNORE_GLOBAL(Name) \ + /**/ + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DEDUCED(Left, Op, Right) \ + BOOST_TYPEOF_NESTED_TYPEDEF_TPL( \ + nested \ + , boost::numeric::functional::detail::lvalue_of<Left>() Op \ + boost::numeric::functional::detail::lvalue_of<Right>() \ + ) \ + typedef typename nested::type type; \ + /**/ + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_LEFT(Left, Op, Right) \ + typedef Left &type; \ + /**/ + + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(plus, +, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(minus, -, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(multiplies, *, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(divides, /, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(modulus, %, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(greater, >, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(greater_equal, >=, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(less, <, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(less_equal, <=, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(equal_to, ==, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(not_equal_to, !=, BOOST_NUMERIC_FUNCTIONAL_DEDUCED) + + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(assign, =, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(plus_assign, +=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(minus_assign, -=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(multiplies_assign, *=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(divides_assign, /=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP(modulus_assign, %=, BOOST_NUMERIC_FUNCTIONAL_LEFT) + + BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(unary_plus, +) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(unary_minus, -) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(complement, ~) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP(logical_not, !) + +#undef BOOST_NUMERIC_FUNCTIONAL_LEFT +#undef BOOST_NUMERIC_FUNCTIONAL_DEDUCED +#undef BOOST_NUMERIC_FUNCTIONAL_DEFINE_UNARY_OP +#undef BOOST_NUMERIC_FUNCTIONAL_DEFINE_BINARY_OP + + namespace functional + { + template<typename Left, typename Right, typename EnableIf> + struct min_assign_base + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + if(numeric::less(right, left)) + { + left = right; + } + } + }; + + template<typename Left, typename Right, typename EnableIf> + struct max_assign_base + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + if(numeric::greater(right, left)) + { + left = right; + } + } + }; + + template<typename Left, typename Right, typename EnableIf> + struct fdiv_base + : functional::divides<Left, Right> + {}; + + // partial specialization that promotes the arguments to double for + // integral division. + template<typename Left, typename Right> + struct fdiv_base<Left, Right, typename enable_if<are_integral<Left, Right> >::type> + : functional::divides<double const, double const> + {}; + + template<typename To, typename From, typename EnableIf> + struct promote_base + : std::unary_function<From, To> + { + To operator ()(From &from) const + { + return from; + } + }; + + template<typename ToFrom> + struct promote_base<ToFrom, ToFrom, void> + : std::unary_function<ToFrom, ToFrom> + { + ToFrom &operator ()(ToFrom &tofrom) + { + return tofrom; + } + }; + + template<typename Arg, typename EnableIf> + struct as_min_base + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + BOOST_STATIC_ASSERT(std::numeric_limits<typename remove_const<Arg>::type>::is_specialized); + + typename remove_const<Arg>::type operator ()(Arg &) const + { + return (std::numeric_limits<typename remove_const<Arg>::type>::min)(); + } + }; + + template<typename Arg> + struct as_min_base<Arg, typename enable_if<is_floating_point<Arg> >::type> + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + BOOST_STATIC_ASSERT(std::numeric_limits<typename remove_const<Arg>::type>::is_specialized); + + typename remove_const<Arg>::type operator ()(Arg &) const + { + return -(std::numeric_limits<typename remove_const<Arg>::type>::max)(); + } + }; + + template<typename Arg, typename EnableIf> + struct as_max_base + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + BOOST_STATIC_ASSERT(std::numeric_limits<typename remove_const<Arg>::type>::is_specialized); + + typename remove_const<Arg>::type operator ()(Arg &) const + { + return (std::numeric_limits<typename remove_const<Arg>::type>::max)(); + } + }; + + template<typename Arg, typename EnableIf> + struct as_zero_base + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + typename remove_const<Arg>::type operator ()(Arg &) const + { + return numeric::zero<typename remove_const<Arg>::type>::value; + } + }; + + template<typename Arg, typename EnableIf> + struct as_one_base + : std::unary_function<Arg, typename remove_const<Arg>::type> + { + typename remove_const<Arg>::type operator ()(Arg &) const + { + return numeric::one<typename remove_const<Arg>::type>::value; + } + }; + + template<typename To, typename From, typename ToTag, typename FromTag> + struct promote + : promote_base<To, From, void> + {}; + + template<typename Left, typename Right, typename LeftTag, typename RightTag> + struct min_assign + : min_assign_base<Left, Right, void> + {}; + + template<typename Left, typename Right, typename LeftTag, typename RightTag> + struct max_assign + : max_assign_base<Left, Right, void> + {}; + + template<typename Left, typename Right, typename LeftTag, typename RightTag> + struct fdiv + : fdiv_base<Left, Right, void> + {}; + + /// INTERNAL ONLY + /// For back-compat only. Use fdiv. + template<typename Left, typename Right, typename LeftTag, typename RightTag> + struct average + : fdiv<Left, Right, LeftTag, RightTag> + {}; + + template<typename Arg, typename Tag> + struct as_min + : as_min_base<Arg, void> + {}; + + template<typename Arg, typename Tag> + struct as_max + : as_max_base<Arg, void> + {}; + + template<typename Arg, typename Tag> + struct as_zero + : as_zero_base<Arg, void> + {}; + + template<typename Arg, typename Tag> + struct as_one + : as_one_base<Arg, void> + {}; + } + + namespace op + { + template<typename To> + struct promote + : boost::detail::function1<functional::promote<To, _, typename functional::tag<To>::type, functional::tag<_> > > + {}; + + struct min_assign + : boost::detail::function2<functional::min_assign<_1, _2, functional::tag<_1>, functional::tag<_2> > > + {}; + + struct max_assign + : boost::detail::function2<functional::max_assign<_1, _2, functional::tag<_1>, functional::tag<_2> > > + {}; + + struct fdiv + : boost::detail::function2<functional::fdiv<_1, _2, functional::tag<_1>, functional::tag<_2> > > + {}; + + /// INTERNAL ONLY + struct average + : boost::detail::function2<functional::fdiv<_1, _2, functional::tag<_1>, functional::tag<_2> > > + {}; + + struct as_min + : boost::detail::function1<functional::as_min<_, functional::tag<_> > > + {}; + + struct as_max + : boost::detail::function1<functional::as_max<_, functional::tag<_> > > + {}; + + struct as_zero + : boost::detail::function1<functional::as_zero<_, functional::tag<_> > > + {}; + + struct as_one + : boost::detail::function1<functional::as_one<_, functional::tag<_> > > + {}; + } + + namespace + { + op::min_assign const &min_assign = boost::detail::pod_singleton<op::min_assign>::instance; + op::max_assign const &max_assign = boost::detail::pod_singleton<op::max_assign>::instance; + op::fdiv const &fdiv = boost::detail::pod_singleton<op::fdiv>::instance; + op::fdiv const &average = boost::detail::pod_singleton<op::fdiv>::instance; ///< INTERNAL ONLY + op::as_min const &as_min = boost::detail::pod_singleton<op::as_min>::instance; + op::as_max const &as_max = boost::detail::pod_singleton<op::as_max>::instance; + op::as_zero const &as_zero = boost::detail::pod_singleton<op::as_zero>::instance; + op::as_one const &as_one = boost::detail::pod_singleton<op::as_one>::instance; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(min_assign) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(max_assign) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(fdiv) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(average) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_min) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_max) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_zero) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(as_one) + } + + /////////////////////////////////////////////////////////////////////////////// + // promote + template<typename To, typename From> + typename lazy_disable_if<is_const<From>, mpl::if_<is_same<To, From>, To &, To> >::type + promote(From &from) + { + return functional::promote<To, From>()(from); + } + + template<typename To, typename From> + typename mpl::if_<is_same<To const, From const>, To const &, To const>::type + promote(From const &from) + { + return functional::promote<To const, From const>()(from); + } + + template<typename T> + struct default_ + { + typedef default_ type; + typedef T value_type; + static T const value; + + operator T const & () const + { + return default_::value; + } + }; + + template<typename T> + T const default_<T>::value = T(); + + template<typename T> + struct one + { + typedef one type; + typedef T value_type; + static T const value; + + operator T const & () const + { + return one::value; + } + }; + + template<typename T> + T const one<T>::value = T(1); + + template<typename T> + struct zero + { + typedef zero type; + typedef T value_type; + static T const value; + + operator T const & () const + { + return zero::value; + } + }; + + template<typename T> + T const zero<T>::value = T(); + + template<typename T> + struct one_or_default + : mpl::if_<is_empty<T>, default_<T>, one<T> >::type + {}; + + template<typename T> + struct zero_or_default + : mpl::if_<is_empty<T>, default_<T>, zero<T> >::type + {}; + +}} // namespace boost::numeric + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional/complex.hpp b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional/complex.hpp new file mode 100644 index 00000000000..ea8c0332400 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional/complex.hpp @@ -0,0 +1,82 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file complex.hpp +/// +// Copyright 2005 Eric Niebler. 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_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006 +#define BOOST_NUMERIC_FUNCTIONAL_COMPLEX_HPP_EAN_01_17_2006 + +#ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED +# error Include this file before boost/accumulators/numeric/functional.hpp +#endif + +#include <complex> +#include <boost/mpl/or.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/typeof/std/complex.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> + +namespace boost { namespace numeric { namespace operators +{ + // So that the stats compile when Sample type is std::complex + template<typename T, typename U> + typename + disable_if< + mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> > + , std::complex<T> + >::type + operator *(std::complex<T> ri, U const &u) + { + // BUGBUG promote result to typeof(T()*u) ? + return ri *= static_cast<T>(u); + } + + template<typename T, typename U> + typename + disable_if< + mpl::or_<is_same<T, U>, is_same<std::complex<T>, U> > + , std::complex<T> + >::type + operator /(std::complex<T> ri, U const &u) + { + // BUGBUG promote result to typeof(T()*u) ? + return ri /= static_cast<T>(u); + } + +}}} // namespace boost::numeric::operators + +namespace boost { namespace numeric +{ + namespace detail + { + template<typename T> + struct one_complex + { + static std::complex<T> const value; + }; + + template<typename T> + std::complex<T> const one_complex<T>::value + = std::complex<T>(numeric::one<T>::value, numeric::one<T>::value); + } + + /// INTERNAL ONLY + /// + template<typename T> + struct one<std::complex<T> > + : detail::one_complex<T> + { + typedef one type; + typedef std::complex<T> value_type; + operator value_type const & () const + { + return detail::one_complex<T>::value; + } + }; + +}} // namespace boost::numeric + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional/valarray.hpp b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional/valarray.hpp new file mode 100644 index 00000000000..c24b45859d9 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional/valarray.hpp @@ -0,0 +1,360 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file valarray.hpp +/// +// Copyright 2005 Eric Niebler. 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_NUMERIC_FUNCTIONAL_VALARRAY_HPP_EAN_12_12_2005 +#define BOOST_NUMERIC_FUNCTIONAL_VALARRAY_HPP_EAN_12_12_2005 + +#ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED +# error Include this file before boost/accumulators/numeric/functional.hpp +#endif + +#include <valarray> +#include <functional> +#include <boost/assert.hpp> +#include <boost/mpl/and.hpp> +#include <boost/mpl/not.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/typeof/std/valarray.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> + +namespace boost { namespace numeric +{ + namespace operators + { + namespace acc_detail + { + template<typename Fun> + struct make_valarray + { + typedef std::valarray<typename Fun::result_type> type; + }; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle valarray<Left> / Right where Right is a scalar and Right != Left. + template<typename Left, typename Right> + typename lazy_enable_if< + mpl::and_<is_scalar<Right>, mpl::not_<is_same<Left, Right> > > + , acc_detail::make_valarray<functional::divides<Left, Right> > + >::type + operator /(std::valarray<Left> const &left, Right const &right) + { + typedef typename functional::divides<Left, Right>::result_type value_type; + std::valarray<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::divides(left[i], right); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle valarray<Left> * Right where Right is a scalar and Right != Left. + template<typename Left, typename Right> + typename lazy_enable_if< + mpl::and_<is_scalar<Right>, mpl::not_<is_same<Left, Right> > > + , acc_detail::make_valarray<functional::multiplies<Left, Right> > + >::type + operator *(std::valarray<Left> const &left, Right const &right) + { + typedef typename functional::multiplies<Left, Right>::result_type value_type; + std::valarray<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::multiplies(left[i], right); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle valarray<Left> + valarray<Right> where Right != Left. + template<typename Left, typename Right> + typename lazy_disable_if< + is_same<Left, Right> + , acc_detail::make_valarray<functional::plus<Left, Right> > + >::type + operator +(std::valarray<Left> const &left, std::valarray<Right> const &right) + { + typedef typename functional::plus<Left, Right>::result_type value_type; + std::valarray<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::plus(left[i], right[i]); + } + return result; + } + } + + namespace functional + { + struct std_valarray_tag; + + template<typename T> + struct tag<std::valarray<T> > + { + typedef std_valarray_tag type; + }; + + #ifdef __GLIBCXX__ + template<typename T, typename U> + struct tag<std::_Expr<T, U> > + { + typedef std_valarray_tag type; + }; + #endif + + /// INTERNAL ONLY + /// + // This is necessary because the GCC stdlib uses expression templates, and + // typeof(som-valarray-expression) is not an instance of std::valarray + #define BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(Name, Op) \ + template<typename Left, typename Right> \ + struct Name<Left, Right, std_valarray_tag, std_valarray_tag> \ + : std::binary_function< \ + Left \ + , Right \ + , std::valarray< \ + typename Name< \ + typename Left::value_type \ + , typename Right::value_type \ + >::result_type \ + > \ + > \ + { \ + typedef typename Left::value_type left_value_type; \ + typedef typename Right::value_type right_value_type; \ + typedef \ + std::valarray< \ + typename Name<left_value_type, right_value_type>::result_type \ + > \ + result_type; \ + result_type \ + operator ()(Left &left, Right &right) const \ + { \ + return numeric::promote<std::valarray<left_value_type> >(left) \ + Op numeric::promote<std::valarray<right_value_type> >(right); \ + } \ + }; \ + template<typename Left, typename Right> \ + struct Name<Left, Right, std_valarray_tag, void> \ + : std::binary_function< \ + Left \ + , Right \ + , std::valarray< \ + typename Name<typename Left::value_type, Right>::result_type \ + > \ + > \ + { \ + typedef typename Left::value_type left_value_type; \ + typedef \ + std::valarray< \ + typename Name<left_value_type, Right>::result_type \ + > \ + result_type; \ + result_type \ + operator ()(Left &left, Right &right) const \ + { \ + return numeric::promote<std::valarray<left_value_type> >(left) Op right;\ + } \ + }; \ + template<typename Left, typename Right> \ + struct Name<Left, Right, void, std_valarray_tag> \ + : std::binary_function< \ + Left \ + , Right \ + , std::valarray< \ + typename Name<Left, typename Right::value_type>::result_type \ + > \ + > \ + { \ + typedef typename Right::value_type right_value_type; \ + typedef \ + std::valarray< \ + typename Name<Left, right_value_type>::result_type \ + > \ + result_type; \ + result_type \ + operator ()(Left &left, Right &right) const \ + { \ + return left Op numeric::promote<std::valarray<right_value_type> >(right);\ + } \ + }; + + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(plus, +) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(minus, -) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(multiplies, *) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(divides, /) + BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP(modulus, %) + + #undef BOOST_NUMERIC_FUNCTIONAL_DEFINE_VALARRAY_BIN_OP + + /////////////////////////////////////////////////////////////////////////////// + // element-wise min of std::valarray + template<typename Left, typename Right> + struct min_assign<Left, Right, std_valarray_tag, std_valarray_tag> + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + if(numeric::less(right[i], left[i])) + { + left[i] = right[i]; + } + } + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // element-wise max of std::valarray + template<typename Left, typename Right> + struct max_assign<Left, Right, std_valarray_tag, std_valarray_tag> + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + if(numeric::greater(right[i], left[i])) + { + left[i] = right[i]; + } + } + } + }; + + // partial specialization of numeric::fdiv<> for std::valarray. + template<typename Left, typename Right, typename RightTag> + struct fdiv<Left, Right, std_valarray_tag, RightTag> + : mpl::if_< + are_integral<typename Left::value_type, Right> + , divides<Left, double const> + , divides<Left, Right> + >::type + {}; + + // promote + template<typename To, typename From> + struct promote<To, From, std_valarray_tag, std_valarray_tag> + : std::unary_function<From, To> + { + To operator ()(From &arr) const + { + typename remove_const<To>::type res(arr.size()); + for(std::size_t i = 0, size = arr.size(); i != size; ++i) + { + res[i] = numeric::promote<typename To::value_type>(arr[i]); + } + return res; + } + }; + + template<typename ToFrom> + struct promote<ToFrom, ToFrom, std_valarray_tag, std_valarray_tag> + : std::unary_function<ToFrom, ToFrom> + { + ToFrom &operator ()(ToFrom &tofrom) const + { + return tofrom; + } + }; + + // for "promoting" a std::valarray<bool> to a bool, useful for + // comparing 2 valarrays for equality: + // if(numeric::promote<bool>(a == b)) + template<typename From> + struct promote<bool, From, void, std_valarray_tag> + : std::unary_function<From, bool> + { + bool operator ()(From &arr) const + { + BOOST_MPL_ASSERT((is_same<bool, typename From::value_type>)); + for(std::size_t i = 0, size = arr.size(); i != size; ++i) + { + if(!arr[i]) + { + return false; + } + } + return true; + } + }; + + template<typename From> + struct promote<bool const, From, void, std_valarray_tag> + : promote<bool, From, void, std_valarray_tag> + {}; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_min + template<typename T> + struct as_min<T, std_valarray_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(numeric::as_min(arr[0]), arr.size()); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_max + template<typename T> + struct as_max<T, std_valarray_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(numeric::as_max(arr[0]), arr.size()); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_zero + template<typename T> + struct as_zero<T, std_valarray_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(numeric::as_zero(arr[0]), arr.size()); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_one + template<typename T> + struct as_one<T, std_valarray_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(numeric::as_one(arr[0]), arr.size()); + } + }; + + } // namespace functional + +}} // namespace boost::numeric + +#endif + diff --git a/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional/vector.hpp b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional/vector.hpp new file mode 100644 index 00000000000..8a68a3f3030 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional/vector.hpp @@ -0,0 +1,329 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file vector.hpp +/// +// Copyright 2005 Eric Niebler. 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_NUMERIC_FUNCTIONAL_VECTOR_HPP_EAN_12_12_2005 +#define BOOST_NUMERIC_FUNCTIONAL_VECTOR_HPP_EAN_12_12_2005 + +#ifdef BOOST_NUMERIC_FUNCTIONAL_HPP_INCLUDED +# error Include this file before boost/accumulators/numeric/functional.hpp +#endif + +#include <vector> +#include <functional> +#include <boost/assert.hpp> +#include <boost/mpl/and.hpp> +#include <boost/mpl/not.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_scalar.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/typeof/std/vector.hpp> +#include <boost/accumulators/numeric/functional_fwd.hpp> + +namespace boost { namespace numeric +{ + namespace operators + { + namespace acc_detail + { + template<typename Fun> + struct make_vector + { + typedef std::vector<typename Fun::result_type> type; + }; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> / Right where Right is a scalar. + template<typename Left, typename Right> + typename lazy_enable_if< + is_scalar<Right> + , acc_detail::make_vector<functional::divides<Left, Right> > + >::type + operator /(std::vector<Left> const &left, Right const &right) + { + typedef typename functional::divides<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::divides(left[i], right); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> / vector<Right>. + template<typename Left, typename Right> + std::vector<typename functional::divides<Left, Right>::result_type> + operator /(std::vector<Left> const &left, std::vector<Right> const &right) + { + typedef typename functional::divides<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::divides(left[i], right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> * Right where Right is a scalar. + template<typename Left, typename Right> + typename lazy_enable_if< + is_scalar<Right> + , acc_detail::make_vector<functional::multiplies<Left, Right> > + >::type + operator *(std::vector<Left> const &left, Right const &right) + { + typedef typename functional::multiplies<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::multiplies(left[i], right); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle Left * vector<Right> where Left is a scalar. + template<typename Left, typename Right> + typename lazy_enable_if< + is_scalar<Left> + , acc_detail::make_vector<functional::multiplies<Left, Right> > + >::type + operator *(Left const &left, std::vector<Right> const &right) + { + typedef typename functional::multiplies<Left, Right>::result_type value_type; + std::vector<value_type> result(right.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::multiplies(left, right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> * vector<Right> + template<typename Left, typename Right> + std::vector<typename functional::multiplies<Left, Right>::result_type> + operator *(std::vector<Left> const &left, std::vector<Right> const &right) + { + typedef typename functional::multiplies<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::multiplies(left[i], right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> + vector<Right> + template<typename Left, typename Right> + std::vector<typename functional::plus<Left, Right>::result_type> + operator +(std::vector<Left> const &left, std::vector<Right> const &right) + { + typedef typename functional::plus<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::plus(left[i], right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> - vector<Right> + template<typename Left, typename Right> + std::vector<typename functional::minus<Left, Right>::result_type> + operator -(std::vector<Left> const &left, std::vector<Right> const &right) + { + typedef typename functional::minus<Left, Right>::result_type value_type; + std::vector<value_type> result(left.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::minus(left[i], right[i]); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle vector<Left> += vector<Left> + template<typename Left> + std::vector<Left> & + operator +=(std::vector<Left> &left, std::vector<Left> const &right) + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + numeric::plus_assign(left[i], right[i]); + } + return left; + } + + /////////////////////////////////////////////////////////////////////////////// + // Handle -vector<Arg> + template<typename Arg> + std::vector<typename functional::unary_minus<Arg>::result_type> + operator -(std::vector<Arg> const &arg) + { + typedef typename functional::unary_minus<Arg>::result_type value_type; + std::vector<value_type> result(arg.size()); + for(std::size_t i = 0, size = result.size(); i != size; ++i) + { + result[i] = numeric::unary_minus(arg[i]); + } + return result; + } + } + + namespace functional + { + struct std_vector_tag; + + template<typename T, typename Al> + struct tag<std::vector<T, Al> > + { + typedef std_vector_tag type; + }; + + /////////////////////////////////////////////////////////////////////////////// + // element-wise min of std::vector + template<typename Left, typename Right> + struct min_assign<Left, Right, std_vector_tag, std_vector_tag> + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + if(numeric::less(right[i], left[i])) + { + left[i] = right[i]; + } + } + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // element-wise max of std::vector + template<typename Left, typename Right> + struct max_assign<Left, Right, std_vector_tag, std_vector_tag> + : std::binary_function<Left, Right, void> + { + void operator ()(Left &left, Right &right) const + { + BOOST_ASSERT(left.size() == right.size()); + for(std::size_t i = 0, size = left.size(); i != size; ++i) + { + if(numeric::greater(right[i], left[i])) + { + left[i] = right[i]; + } + } + } + }; + + // partial specialization for std::vector. + template<typename Left, typename Right> + struct fdiv<Left, Right, std_vector_tag, void> + : mpl::if_< + are_integral<typename Left::value_type, Right> + , divides<Left, double const> + , divides<Left, Right> + >::type + {}; + + // promote + template<typename To, typename From> + struct promote<To, From, std_vector_tag, std_vector_tag> + : std::unary_function<From, To> + { + To operator ()(From &arr) const + { + typename remove_const<To>::type res(arr.size()); + for(std::size_t i = 0, size = arr.size(); i != size; ++i) + { + res[i] = numeric::promote<typename To::value_type>(arr[i]); + } + return res; + } + }; + + template<typename ToFrom> + struct promote<ToFrom, ToFrom, std_vector_tag, std_vector_tag> + : std::unary_function<ToFrom, ToFrom> + { + ToFrom &operator ()(ToFrom &tofrom) const + { + return tofrom; + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_min + template<typename T> + struct as_min<T, std_vector_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(arr.size(), numeric::as_min(arr[0])); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_max + template<typename T> + struct as_max<T, std_vector_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(arr.size(), numeric::as_max(arr[0])); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_zero + template<typename T> + struct as_zero<T, std_vector_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(arr.size(), numeric::as_zero(arr[0])); + } + }; + + /////////////////////////////////////////////////////////////////////////////// + // functional::as_one + template<typename T> + struct as_one<T, std_vector_tag> + : std::unary_function<T, typename remove_const<T>::type> + { + typename remove_const<T>::type operator ()(T &arr) const + { + return 0 == arr.size() + ? T() + : T(arr.size(), numeric::as_one(arr[0])); + } + }; + + } // namespace functional + +}} // namespace boost::numeric + +#endif + diff --git a/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional_fwd.hpp b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional_fwd.hpp new file mode 100644 index 00000000000..501f654b298 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/numeric/functional_fwd.hpp @@ -0,0 +1,221 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file functional_fwd.hpp +/// +// Copyright 2005 Eric Niebler. 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_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005 +#define BOOST_NUMERIC_FUNCTIONAL_FWD_HPP_EAN_08_12_2005 + +#include <boost/mpl/if.hpp> +#include <boost/mpl/placeholders.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_const.hpp> + +namespace boost { namespace numeric +{ + // For using directives -- this namespace may be re-opened elsewhere + namespace operators + {} + + namespace op + { + using mpl::_; + using mpl::_1; + using mpl::_2; + } + + namespace functional + { + using namespace operators; + + template<typename T> + struct tag + { + typedef void type; + }; + + template<typename T> + struct tag<T const> + : tag<T> + {}; + + template<typename T> + struct tag<T volatile> + : tag<T> + {}; + + template<typename T> + struct tag<T const volatile> + : tag<T> + {}; + + template<typename T> + struct static_; + + template<typename A0, typename A1> + struct are_integral; + } + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(Name, Op) \ + namespace functional \ + { \ + template<typename Arg, typename EnableIf = void> \ + struct Name ## _base; \ + template<typename Arg, typename ArgTag = typename tag<Arg>::type> \ + struct Name; \ + } \ + namespace op \ + { \ + struct Name; \ + } \ + namespace \ + { \ + extern op::Name const &Name; \ + } + + /// INTERNAL ONLY + /// +#define BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(Name) \ + namespace functional \ + { \ + template<typename Left, typename Right, typename EnableIf = void> \ + struct result_of_ ## Name; \ + template<typename Left, typename Right, typename EnableIf = void> \ + struct Name ## _base; \ + template< \ + typename Left \ + , typename Right \ + , typename LeftTag = typename tag<Left>::type \ + , typename RightTag = typename tag<Right>::type \ + > \ + struct Name; \ + } \ + namespace op \ + { \ + struct Name; \ + } \ + namespace \ + { \ + extern op::Name const &Name; \ + } + + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(greater_equal) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(less_equal) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(equal_to) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(not_equal_to) + + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(plus_assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(minus_assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(multiplies_assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(divides_assign) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP(modulus_assign) + + BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_plus, +) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(unary_minus, -) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(complement, ~) + BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP(logical_not, !) + +#undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_UNARY_OP +#undef BOOST_NUMERIC_FUNCTIONAL_DECLARE_BINARY_OP + + + namespace functional + { + template<typename To, typename From, typename EnableIf = void> + struct promote_base; + template<typename Left, typename Right, typename EnableIf = void> + struct min_assign_base; + template<typename Left, typename Right, typename EnableIf = void> + struct max_assign_base; + template<typename Left, typename Right, typename EnableIf = void> + struct fdiv_base; + template<typename Arg, typename EnableIf = void> + struct as_min_base; + template<typename Arg, typename EnableIf = void> + struct as_max_base; + template<typename Arg, typename EnableIf = void> + struct as_zero_base; + template<typename Arg, typename EnableIf = void> + struct as_one_base; + + template<typename To, typename From, typename ToTag = typename tag<To>::type, typename FromTag = typename tag<From>::type> + struct promote; + template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type> + struct min_assign; + template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type> + struct max_assign; + template<typename Left, typename Right, typename LeftTag = typename tag<Left>::type, typename RightTag = typename tag<Right>::type> + struct fdiv; + template<typename Arg, typename Tag = typename tag<Arg>::type> + struct as_min; + template<typename Arg, typename Tag = typename tag<Arg>::type> + struct as_max; + template<typename Arg, typename Tag = typename tag<Arg>::type> + struct as_zero; + template<typename Arg, typename Tag = typename tag<Arg>::type> + struct as_one; + } + + namespace op + { + template<typename To> + struct promote; + struct min_assign; + struct max_assign; + struct fdiv; + struct as_min; + struct as_max; + struct as_zero; + struct as_one; + } + + namespace + { + extern op::min_assign const &min_assign; + extern op::max_assign const &max_assign; + extern op::fdiv const &fdiv; + extern op::as_min const &as_min; + extern op::as_max const &as_max; + extern op::as_zero const &as_zero; + extern op::as_one const &as_one; + } + + template<typename To, typename From> + typename lazy_disable_if<is_const<From>, mpl::if_<is_same<To, From>, To &, To> >::type + promote(From &from); + + template<typename To, typename From> + typename mpl::if_<is_same<To const, From const>, To const &, To const>::type + promote(From const &from); + + template<typename T> + struct default_; + + template<typename T> + struct one; + + template<typename T> + struct zero; + + template<typename T> + struct one_or_default; + + template<typename T> + struct zero_or_default; + +}} // namespace boost::numeric + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/statistics/count.hpp b/src/third_party/boost-1.56.0/boost/accumulators/statistics/count.hpp new file mode 100644 index 00000000000..6d30b41e263 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/statistics/count.hpp @@ -0,0 +1,80 @@ +/////////////////////////////////////////////////////////////////////////////// +// count.hpp +// +// Copyright 2005 Eric Niebler. 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_COUNT_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_COUNT_HPP_EAN_28_10_2005 + +#include <boost/mpl/always.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + + /////////////////////////////////////////////////////////////////////////////// + // count_impl + struct count_impl + : accumulator_base + { + // for boost::result_of + typedef std::size_t result_type; + + count_impl(dont_care) + : cnt(0) + { + } + + void operator ()(dont_care) + { + ++this->cnt; + } + + result_type result(dont_care) const + { + return this->cnt; + } + + private: + std::size_t cnt; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::count +// +namespace tag +{ + struct count + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::count_impl> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::count +// +namespace extract +{ + extractor<tag::count> const count = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(count) +} + +using extract::count; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/statistics/max.hpp b/src/third_party/boost-1.56.0/boost/accumulators/statistics/max.hpp new file mode 100644 index 00000000000..820f6593f0d --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/statistics/max.hpp @@ -0,0 +1,85 @@ +/////////////////////////////////////////////////////////////////////////////// +// max.hpp +// +// Copyright 2005 Eric Niebler. 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_MAX_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_MAX_HPP_EAN_28_10_2005 + +#include <limits> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // max_impl + template<typename Sample> + struct max_impl + : accumulator_base + { + // for boost::result_of + typedef Sample result_type; + + template<typename Args> + max_impl(Args const &args) + : max_(numeric::as_min(args[sample | Sample()])) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + numeric::max_assign(this->max_, args[sample]); + } + + result_type result(dont_care) const + { + return this->max_; + } + + private: + Sample max_; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::max +// +namespace tag +{ + struct max + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::max_impl<mpl::_1> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::max +// +namespace extract +{ + extractor<tag::max> const max = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(max) +} + +using extract::max; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/statistics/mean.hpp b/src/third_party/boost-1.56.0/boost/accumulators/statistics/mean.hpp new file mode 100644 index 00000000000..47888371843 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/statistics/mean.hpp @@ -0,0 +1,298 @@ +/////////////////////////////////////////////////////////////////////////////// +// mean.hpp +// +// Copyright 2005 Eric Niebler. 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_MEAN_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_MEAN_HPP_EAN_28_10_2005 + +#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/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/sum.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // mean_impl + // lazy, by default + template<typename Sample, typename SumFeature> + struct mean_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type; + + mean_impl(dont_care) {} + + template<typename Args> + result_type result(Args const &args) const + { + extractor<SumFeature> sum; + return numeric::fdiv(sum(args), count(args)); + } + }; + + template<typename Sample, typename Tag> + struct immediate_mean_impl + : accumulator_base + { + // for boost::result_of + typedef typename numeric::functional::fdiv<Sample, std::size_t>::result_type result_type; + + template<typename Args> + immediate_mean_impl(Args const &args) + : mean(numeric::fdiv(args[sample | Sample()], numeric::one<std::size_t>::value)) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + std::size_t cnt = count(args); + this->mean = numeric::fdiv( + (this->mean * (cnt - 1)) + args[parameter::keyword<Tag>::get()] + , cnt + ); + } + + result_type result(dont_care) const + { + return this->mean; + } + + private: + result_type mean; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::mean +// tag::immediate_mean +// tag::mean_of_weights +// tag::immediate_mean_of_weights +// tag::mean_of_variates +// tag::immediate_mean_of_variates +// +namespace tag +{ + struct mean + : depends_on<count, sum> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::mean_impl<mpl::_1, sum> impl; + }; + struct immediate_mean + : depends_on<count> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::immediate_mean_impl<mpl::_1, tag::sample> impl; + }; + struct mean_of_weights + : depends_on<count, sum_of_weights> + { + typedef mpl::true_ is_weight_accumulator; + /// INTERNAL ONLY + /// + typedef accumulators::impl::mean_impl<mpl::_2, sum_of_weights> impl; + }; + struct immediate_mean_of_weights + : depends_on<count> + { + typedef mpl::true_ is_weight_accumulator; + /// INTERNAL ONLY + /// + typedef accumulators::impl::immediate_mean_impl<mpl::_2, tag::weight> impl; + }; + template<typename VariateType, typename VariateTag> + struct mean_of_variates + : depends_on<count, sum_of_variates<VariateType, VariateTag> > + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::mean_impl<VariateType, sum_of_variates<VariateType, VariateTag> > > impl; + }; + template<typename VariateType, typename VariateTag> + struct immediate_mean_of_variates + : depends_on<count> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::immediate_mean_impl<VariateType, VariateTag> > impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::mean +// extract::mean_of_weights +// extract::mean_of_variates +// +namespace extract +{ + extractor<tag::mean> const mean = {}; + extractor<tag::mean_of_weights> const mean_of_weights = {}; + BOOST_ACCUMULATORS_DEFINE_EXTRACTOR(tag, mean_of_variates, (typename)(typename)) + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(mean) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(mean_of_weights) +} + +using extract::mean; +using extract::mean_of_weights; +using extract::mean_of_variates; + +// mean(lazy) -> mean +template<> +struct as_feature<tag::mean(lazy)> +{ + typedef tag::mean type; +}; + +// mean(immediate) -> immediate_mean +template<> +struct as_feature<tag::mean(immediate)> +{ + typedef tag::immediate_mean type; +}; + +// mean_of_weights(lazy) -> mean_of_weights +template<> +struct as_feature<tag::mean_of_weights(lazy)> +{ + typedef tag::mean_of_weights type; +}; + +// mean_of_weights(immediate) -> immediate_mean_of_weights +template<> +struct as_feature<tag::mean_of_weights(immediate)> +{ + typedef tag::immediate_mean_of_weights type; +}; + +// mean_of_variates<VariateType, VariateTag>(lazy) -> mean_of_variates<VariateType, VariateTag> +template<typename VariateType, typename VariateTag> +struct as_feature<tag::mean_of_variates<VariateType, VariateTag>(lazy)> +{ + typedef tag::mean_of_variates<VariateType, VariateTag> type; +}; + +// mean_of_variates<VariateType, VariateTag>(immediate) -> immediate_mean_of_variates<VariateType, VariateTag> +template<typename VariateType, typename VariateTag> +struct as_feature<tag::mean_of_variates<VariateType, VariateTag>(immediate)> +{ + typedef tag::immediate_mean_of_variates<VariateType, VariateTag> type; +}; + +// for the purposes of feature-based dependency resolution, +// immediate_mean provides the same feature as mean +template<> +struct feature_of<tag::immediate_mean> + : feature_of<tag::mean> +{ +}; + +// for the purposes of feature-based dependency resolution, +// immediate_mean provides the same feature as mean +template<> +struct feature_of<tag::immediate_mean_of_weights> + : feature_of<tag::mean_of_weights> +{ +}; + +// for the purposes of feature-based dependency resolution, +// immediate_mean provides the same feature as mean +template<typename VariateType, typename VariateTag> +struct feature_of<tag::immediate_mean_of_variates<VariateType, VariateTag> > + : feature_of<tag::mean_of_variates<VariateType, VariateTag> > +{ +}; + +// So that mean can be automatically substituted with +// weighted_mean when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::mean> +{ + typedef tag::weighted_mean type; +}; + +template<> +struct feature_of<tag::weighted_mean> + : feature_of<tag::mean> +{}; + +// So that immediate_mean can be automatically substituted with +// immediate_weighted_mean when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::immediate_mean> +{ + typedef tag::immediate_weighted_mean type; +}; + +template<> +struct feature_of<tag::immediate_weighted_mean> + : feature_of<tag::immediate_mean> +{}; + +// So that mean_of_weights<> can be automatically substituted with +// weighted_mean_of_variates<> when the weight parameter is non-void. +template<typename VariateType, typename VariateTag> +struct as_weighted_feature<tag::mean_of_variates<VariateType, VariateTag> > +{ + typedef tag::weighted_mean_of_variates<VariateType, VariateTag> type; +}; + +template<typename VariateType, typename VariateTag> +struct feature_of<tag::weighted_mean_of_variates<VariateType, VariateTag> > + : feature_of<tag::mean_of_variates<VariateType, VariateTag> > +{ +}; + +// So that immediate_mean_of_weights<> can be automatically substituted with +// immediate_weighted_mean_of_variates<> when the weight parameter is non-void. +template<typename VariateType, typename VariateTag> +struct as_weighted_feature<tag::immediate_mean_of_variates<VariateType, VariateTag> > +{ + typedef tag::immediate_weighted_mean_of_variates<VariateType, VariateTag> type; +}; + +template<typename VariateType, typename VariateTag> +struct feature_of<tag::immediate_weighted_mean_of_variates<VariateType, VariateTag> > + : feature_of<tag::immediate_mean_of_variates<VariateType, VariateTag> > +{ +}; + +//////////////////////////////////////////////////////////////////////////// +//// droppable_accumulator<mean_impl> +//// need to specialize droppable lazy mean to cache the result at the +//// point the accumulator is dropped. +///// INTERNAL ONLY +///// +//template<typename Sample, typename SumFeature> +//struct droppable_accumulator<impl::mean_impl<Sample, SumFeature> > +// : droppable_accumulator_base< +// with_cached_result<impl::mean_impl<Sample, SumFeature> > +// > +//{ +// template<typename Args> +// droppable_accumulator(Args const &args) +// : droppable_accumulator::base(args) +// { +// } +//}; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/statistics/min.hpp b/src/third_party/boost-1.56.0/boost/accumulators/statistics/min.hpp new file mode 100644 index 00000000000..83943bdb3c3 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/statistics/min.hpp @@ -0,0 +1,85 @@ +/////////////////////////////////////////////////////////////////////////////// +// min.hpp +// +// Copyright 2005 Eric Niebler. 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_MIN_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_MIN_HPP_EAN_28_10_2005 + +#include <limits> +#include <boost/mpl/placeholders.hpp> +#include <boost/accumulators/framework/accumulator_base.hpp> +#include <boost/accumulators/framework/extractor.hpp> +#include <boost/accumulators/framework/parameters/sample.hpp> +#include <boost/accumulators/numeric/functional.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/statistics_fwd.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // min_impl + template<typename Sample> + struct min_impl + : accumulator_base + { + // for boost::result_of + typedef Sample result_type; + + template<typename Args> + min_impl(Args const &args) + : min_(numeric::as_max(args[sample | Sample()])) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + numeric::min_assign(this->min_, args[sample]); + } + + result_type result(dont_care) const + { + return this->min_; + } + + private: + Sample min_; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::min +// +namespace tag +{ + struct min + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::min_impl<mpl::_1> impl; + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::min +// +namespace extract +{ + extractor<tag::min> const min = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(min) +} + +using extract::min; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/statistics/sum.hpp b/src/third_party/boost-1.56.0/boost/accumulators/statistics/sum.hpp new file mode 100644 index 00000000000..126ce244fde --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/statistics/sum.hpp @@ -0,0 +1,141 @@ +/////////////////////////////////////////////////////////////////////////////// +// sum.hpp +// +// Copyright 2005 Eric Niebler. 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_SUM_HPP_EAN_28_10_2005 +#define BOOST_ACCUMULATORS_STATISTICS_SUM_HPP_EAN_28_10_2005 + +#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> +#include <boost/accumulators/statistics/count.hpp> + +namespace boost { namespace accumulators +{ + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // sum_impl + template<typename Sample, typename Tag> + struct sum_impl + : accumulator_base + { + // for boost::result_of + typedef Sample result_type; + + template<typename Args> + sum_impl(Args const &args) + : sum(args[parameter::keyword<Tag>::get() | Sample()]) + { + } + + template<typename Args> + void operator ()(Args const &args) + { + // what about overflow? + this->sum += args[parameter::keyword<Tag>::get()]; + } + + result_type result(dont_care) const + { + return this->sum; + } + + private: + + Sample sum; + }; + +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// tag::sum +// tag::sum_of_weights +// tag::sum_of_variates +// +namespace tag +{ + struct sum + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef accumulators::impl::sum_impl<mpl::_1, tag::sample> impl; + }; + + struct sum_of_weights + : depends_on<> + { + typedef mpl::true_ is_weight_accumulator; + /// INTERNAL ONLY + /// + typedef accumulators::impl::sum_impl<mpl::_2, tag::weight> impl; + }; + + template<typename VariateType, typename VariateTag> + struct sum_of_variates + : depends_on<> + { + /// INTERNAL ONLY + /// + typedef mpl::always<accumulators::impl::sum_impl<VariateType, VariateTag> > impl; + }; + + struct abstract_sum_of_variates + : depends_on<> + { + }; +} + +/////////////////////////////////////////////////////////////////////////////// +// extract::sum +// extract::sum_of_weights +// extract::sum_of_variates +// +namespace extract +{ + extractor<tag::sum> const sum = {}; + extractor<tag::sum_of_weights> const sum_of_weights = {}; + extractor<tag::abstract_sum_of_variates> const sum_of_variates = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_weights) + BOOST_ACCUMULATORS_IGNORE_GLOBAL(sum_of_variates) +} + +using extract::sum; +using extract::sum_of_weights; +using extract::sum_of_variates; + +// So that mean can be automatically substituted with +// weighted_mean when the weight parameter is non-void. +template<> +struct as_weighted_feature<tag::sum> +{ + typedef tag::weighted_sum type; +}; + +template<> +struct feature_of<tag::weighted_sum> + : feature_of<tag::sum> +{}; + +template<typename VariateType, typename VariateTag> +struct feature_of<tag::sum_of_variates<VariateType, VariateTag> > + : feature_of<tag::abstract_sum_of_variates> +{ +}; + +}} // namespace boost::accumulators + +#endif diff --git a/src/third_party/boost-1.56.0/boost/accumulators/statistics_fwd.hpp b/src/third_party/boost-1.56.0/boost/accumulators/statistics_fwd.hpp new file mode 100644 index 00000000000..61904f30b36 --- /dev/null +++ b/src/third_party/boost-1.56.0/boost/accumulators/statistics_fwd.hpp @@ -0,0 +1,432 @@ +/////////////////////////////////////////////////////////////////////////////// +// statistics_fwd.hpp +// +// Copyright 2005 Eric Niebler. 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_STATISTICS_FWD_HPP_EAN_23_11_2005 +#define BOOST_ACCUMULATORS_STATISTICS_STATISTICS_FWD_HPP_EAN_23_11_2005 + +#include <boost/mpl/apply_fwd.hpp> // for mpl::na +#include <boost/mpl/print.hpp> +#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +#include <boost/accumulators/accumulators_fwd.hpp> +#include <boost/accumulators/framework/depends_on.hpp> +#include <boost/accumulators/framework/extractor.hpp> + +namespace boost { namespace accumulators +{ + +/////////////////////////////////////////////////////////////////////////////// +// base struct and base extractor for quantiles +namespace tag +{ + struct quantile + : depends_on<> + { + typedef mpl::print<class ____MISSING_SPECIFIC_QUANTILE_FEATURE_IN_ACCUMULATOR_SET____ > impl; + }; +} +namespace extract +{ + extractor<tag::quantile> const quantile = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(quantile) +} +using extract::quantile; + +/////////////////////////////////////////////////////////////////////////////// +// base struct and base extractor for *coherent* tail means +namespace tag +{ + struct tail_mean + : depends_on<> + { + typedef mpl::print<class ____MISSING_SPECIFIC_TAIL_MEAN_FEATURE_IN_ACCUMULATOR_SET____ > impl; + }; +} +namespace extract +{ + extractor<tag::tail_mean> const tail_mean = {}; + + BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_mean) +} +using extract::tail_mean; + +namespace tag +{ + /////////////////////////////////////////////////////////////////////////////// + // Variates tags + struct weights; + struct covariate1; + struct covariate2; + + /////////////////////////////////////////////////////////////////////////////// + // Statistic tags + struct count; + template<typename VariateType, typename VariateTag> + struct covariance; + struct density; + template<typename Feature> + struct error_of; + struct extended_p_square; + struct extended_p_square_quantile; + struct extended_p_square_quantile_quadratic; + struct kurtosis; + struct max; + struct mean; + struct immediate_mean; + struct mean_of_weights; + struct immediate_mean_of_weights; + template<typename VariateType, typename VariateTag> + struct mean_of_variates; + template<typename VariateType, typename VariateTag> + struct immediate_mean_of_variates; + struct median; + struct with_density_median; + struct with_p_square_cumulative_distribution_median; + struct min; + template<int N> + struct moment; + template<typename LeftRight> + struct peaks_over_threshold; + template<typename LeftRight> + struct peaks_over_threshold_prob; + template<typename LeftRight> + struct pot_tail_mean; + template<typename LeftRight> + struct pot_tail_mean_prob; + template<typename LeftRight> + struct pot_quantile; + template<typename LeftRight> + struct pot_quantile_prob; + struct p_square_cumulative_distribution; + struct p_square_quantile; + struct p_square_quantile_for_median; + struct skewness; + struct sum; + struct sum_of_weights; + template<typename VariateType, typename VariateTag> + struct sum_of_variates; + struct sum_kahan; + struct sum_of_weights_kahan; + template<typename VariateType, typename VariateTag> + struct sum_of_variates_kahan; + template<typename LeftRight> + struct tail; + template<typename LeftRight> + struct coherent_tail_mean; + template<typename LeftRight> + struct non_coherent_tail_mean; + template<typename LeftRight> + struct tail_quantile; + template<typename VariateType, typename VariateTag, typename LeftRight> + struct tail_variate; + template<typename LeftRight> + struct tail_weights; + template<typename VariateType, typename VariateTag, typename LeftRight> + struct right_tail_variate; + template<typename VariateType, typename VariateTag, typename LeftRight> + struct left_tail_variate; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct tail_variate_means; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct absolute_tail_variate_means; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct relative_tail_variate_means; + struct lazy_variance; + struct variance; + template<typename VariateType, typename VariateTag> + struct weighted_covariance; + struct weighted_density; + struct weighted_kurtosis; + struct weighted_mean; + struct immediate_weighted_mean; + template<typename VariateType, typename VariateTag> + struct weighted_mean_of_variates; + template<typename VariateType, typename VariateTag> + struct immediate_weighted_mean_of_variates; + struct weighted_median; + struct with_density_weighted_median; + struct with_p_square_cumulative_distribution_weighted_median; + struct weighted_extended_p_square; + struct weighted_extended_p_square_quantile; + struct weighted_extended_p_square_quantile_quadratic; + template<int N> + struct weighted_moment; + template<typename LeftRight> + struct weighted_peaks_over_threshold; + template<typename LeftRight> + struct weighted_peaks_over_threshold_prob; + template<typename LeftRight> + struct weighted_pot_quantile; + template<typename LeftRight> + struct weighted_pot_quantile_prob; + template<typename LeftRight> + struct weighted_pot_tail_mean; + template<typename LeftRight> + struct weighted_pot_tail_mean_prob; + struct weighted_p_square_cumulative_distribution; + struct weighted_p_square_quantile; + struct weighted_p_square_quantile_for_median; + struct weighted_skewness; + template<typename LeftRight> + struct weighted_tail_quantile; + template<typename LeftRight> + struct non_coherent_weighted_tail_mean; + template<typename LeftRight> + struct weighted_tail_quantile; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct weighted_tail_variate_means; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct absolute_weighted_tail_variate_means; + template<typename LeftRight, typename VariateType, typename VariateTag> + struct relative_weighted_tail_variate_means; + struct lazy_weighted_variance; + struct weighted_variance; + struct weighted_sum; + template<typename VariateType, typename VariateTag> + struct weighted_sum_of_variates; + struct rolling_window_plus1; + struct rolling_window; + struct rolling_sum; + struct rolling_count; + struct rolling_mean; +} // namespace tag + +namespace impl +{ + /////////////////////////////////////////////////////////////////////////////// + // Statistics impls + struct count_impl; + + template<typename Sample, typename VariateType, typename VariateTag> + struct covariance_impl; + + template<typename Sample> + struct density_impl; + + template<typename Sample, typename Feature> + struct error_of_impl; + + template<typename Sample, typename Variance> + struct error_of_mean_impl; + + template<typename Sample> + struct extended_p_square_impl; + + template<typename Sample, typename Impl1, typename Impl2> + struct extended_p_square_quantile_impl; + + template<typename Sample> + struct kurtosis_impl; + + template<typename Sample> + struct max_impl; + + template<typename Sample> + struct median_impl; + + template<typename Sample> + struct with_density_median_impl; + + template<typename Sample> + struct with_p_square_cumulative_distribution_median_impl; + + template<typename Sample> + struct min_impl; + + template<typename Sample, typename SumFeature = tag::sum> + struct mean_impl; + + template<typename Sample, typename Tag = tag::sample> + struct immediate_mean_impl; + + template<typename N, typename Sample> + struct moment_impl; + + template<typename Sample, typename LeftRight> + struct peaks_over_threshold_prob_impl; + + template<typename Sample, typename Impl, typename LeftRight> + struct pot_quantile_impl; + + template<typename Sample, typename Impl, typename LeftRight> + struct pot_tail_mean_impl; + + template<typename Sample> + struct p_square_cumulative_distribution_impl; + + template<typename Sample, typename Impl> + struct p_square_quantile_impl; + + template<typename Sample> + struct skewness_impl; + + template<typename Sample, typename Tag = tag::sample> + struct sum_impl; + + template<typename Sample, typename Tag> + struct sum_kahan_impl; + + template<typename Sample, typename LeftRight> + struct tail_impl; + + template<typename Sample, typename LeftRight> + struct coherent_tail_mean_impl; + + template<typename Sample, typename LeftRight> + struct non_coherent_tail_mean_impl; + + template<typename Sample, typename LeftRight> + struct tail_quantile_impl; + + template<typename VariateType, typename VariateTag, typename LeftRight> + struct tail_variate_impl; + + template<typename Sample, typename Impl, typename LeftRight, typename VariateTag> + struct tail_variate_means_impl; + + template<typename Sample, typename MeanFeature> + struct lazy_variance_impl; + + template<typename Sample, typename MeanFeature, typename Tag> + struct variance_impl; + + template<typename Sample, typename Weight, typename VariateType, typename VariateTag> + struct weighted_covariance_impl; + + template<typename Sample, typename Weight> + struct weighted_density_impl; + + template<typename Sample, typename Weight> + struct weighted_kurtosis_impl; + + template<typename Sample> + struct weighted_median_impl; + + template<typename Sample> + struct with_density_weighted_median_impl; + + template<typename Sample, typename Weight> + struct with_p_square_cumulative_distribution_weighted_median_impl; + + template<typename Sample, typename Weight, typename Tag> + struct weighted_mean_impl; + + template<typename Sample, typename Weight, typename Tag> + struct immediate_weighted_mean_impl; + + template<typename Sample, typename Weight, typename LeftRight> + struct weighted_peaks_over_threshold_impl; + + template<typename Sample, typename Weight, typename LeftRight> + struct weighted_peaks_over_threshold_prob_impl; + + template<typename Sample, typename Weight> + struct with_p_square_cumulative_distribution_weighted_median_impl; + + template<typename Sample, typename Weight> + struct weighted_extended_p_square_impl; + + template<typename N, typename Sample, typename Weight> + struct weighted_moment_impl; + + template<typename Sample, typename Weight> + struct weighted_p_square_cumulative_distribution_impl; + + template<typename Sample, typename Weight, typename Impl> + struct weighted_p_square_quantile_impl; + + template<typename Sample, typename Weight> + struct weighted_skewness_impl; + + template<typename Sample, typename Weight, typename Tag> + struct weighted_sum_impl; + + template<typename Sample, typename Weight, typename Tag> + struct weighted_sum_kahan_impl; + + template<typename Sample, typename Weight, typename LeftRight> + struct non_coherent_weighted_tail_mean_impl; + + template<typename Sample, typename Weight, typename LeftRight> + struct weighted_tail_quantile_impl; + + template<typename Sample, typename Weight, typename Impl, typename LeftRight, typename VariateType> + struct weighted_tail_variate_means_impl; + + template<typename Sample, typename Weight, typename MeanFeature> + struct lazy_weighted_variance_impl; + + template<typename Sample, typename Weight, typename MeanFeature, typename Tag> + struct weighted_variance_impl; + + template<typename Sample> + struct rolling_window_plus1_impl; + + template<typename Sample> + struct rolling_window_impl; + + template<typename Sample> + struct rolling_sum_impl; + + template<typename Sample> + struct rolling_count_impl; + + template<typename Sample> + struct rolling_mean_impl; +} // namespace impl + +/////////////////////////////////////////////////////////////////////////////// +// stats +// A more descriptive name for an MPL sequence of statistics. +template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> +struct stats; + +template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_ACCUMULATORS_MAX_FEATURES, typename Feature, mpl::na)> +struct with_error; + +// modifiers for the mean and variance stats +struct lazy {}; +struct immediate {}; + +// modifiers for the variance stat +// struct fast {}; +// struct accurate {}; + +// modifiers for order +struct right {}; +struct left {}; +// typedef right default_order_tag_type; + +// modifiers for the tail_variate_means stat +struct absolute {}; +struct relative {}; + +// modifiers for median and weighted_median stats +struct with_density {}; +struct with_p_square_cumulative_distribution {}; +struct with_p_square_quantile {}; + +// modifiers for peaks_over_threshold stat +struct with_threshold_value {}; +struct with_threshold_probability {}; + +// modifiers for extended_p_square_quantile and weighted_extended_p_square_quantile stats +struct weighted {}; +struct unweighted {}; +struct linear {}; +struct quadratic {}; + +// modifiers for p_square_quantile +struct regular {}; +struct for_median {}; + +// modifier for sum_kahan, sum_of_weights_kahan, sum_of_variates_kahan, weighted_sum_kahan +struct kahan {}; + +}} // namespace boost::accumulators + +#endif |