File indexing completed on 2025-01-18 09:28:21
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_STAT_STATISTICS_TAIL_VARIATE_HPP_EAN_28_10_2005
0009 #define BOOST_STAT_STATISTICS_TAIL_VARIATE_HPP_EAN_28_10_2005
0010
0011 #include <boost/range.hpp>
0012 #include <boost/mpl/always.hpp>
0013 #include <boost/mpl/placeholders.hpp>
0014 #include <boost/iterator/reverse_iterator.hpp>
0015 #include <boost/iterator/permutation_iterator.hpp>
0016 #include <boost/accumulators/framework/accumulator_base.hpp>
0017 #include <boost/accumulators/framework/extractor.hpp>
0018 #include <boost/accumulators/framework/depends_on.hpp>
0019 #include <boost/accumulators/statistics_fwd.hpp>
0020 #include <boost/accumulators/statistics/tail.hpp>
0021 #include <boost/serialization/vector.hpp>
0022
0023 namespace boost { namespace accumulators
0024 {
0025
0026 namespace impl
0027 {
0028
0029
0030 template<typename VariateType, typename VariateTag, typename LeftRight>
0031 struct tail_variate_impl
0032 : accumulator_base
0033 {
0034
0035 typedef
0036 typename detail::tail_range<
0037 typename std::vector<VariateType>::const_iterator
0038 , std::vector<std::size_t>::iterator
0039 >::type
0040 result_type;
0041
0042 template<typename Args>
0043 tail_variate_impl(Args const &args)
0044 : variates(args[tag::tail<LeftRight>::cache_size], args[parameter::keyword<VariateTag>::get() | VariateType()])
0045 {
0046 }
0047
0048 template<typename Args>
0049 void assign(Args const &args, std::size_t index)
0050 {
0051 this->variates[index] = args[parameter::keyword<VariateTag>::get()];
0052 }
0053
0054 template<typename Args>
0055 result_type result(Args const &args) const
0056 {
0057
0058 extractor<tag::tail<LeftRight> > const some_tail = {};
0059 return this->do_result(some_tail(args));
0060 }
0061
0062 private:
0063 template<typename TailRng>
0064 result_type do_result(TailRng const &rng) const
0065 {
0066 return detail::make_tail_range(
0067 this->variates.begin()
0068 , rng.end().base().base()
0069 , rng.begin().base().base()
0070 );
0071 }
0072
0073
0074 template<class Archive>
0075 void serialize(Archive & ar, const unsigned int file_version)
0076 {
0077 ar & variates;
0078 }
0079
0080 private:
0081 std::vector<VariateType> variates;
0082 };
0083
0084 }
0085
0086
0087
0088
0089 namespace tag
0090 {
0091 template<typename VariateType, typename VariateTag, typename LeftRight>
0092 struct tail_variate
0093 : depends_on<tail<LeftRight> >
0094 {
0095
0096
0097 typedef mpl::always<accumulators::impl::tail_variate_impl<VariateType, VariateTag, LeftRight> > impl;
0098 };
0099
0100 struct abstract_tail_variate
0101 : depends_on<>
0102 {
0103 };
0104
0105 template<typename LeftRight>
0106 struct tail_weights
0107 : depends_on<tail<LeftRight> >
0108 {
0109
0110
0111 typedef accumulators::impl::tail_variate_impl<mpl::_2, tag::weight, LeftRight> impl;
0112 };
0113
0114 struct abstract_tail_weights
0115 : depends_on<>
0116 {
0117 };
0118 }
0119
0120
0121
0122
0123
0124 namespace extract
0125 {
0126 extractor<tag::abstract_tail_variate> const tail_variate = {};
0127 extractor<tag::abstract_tail_weights> const tail_weights = {};
0128
0129 BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_variate)
0130 BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_weights)
0131 }
0132
0133 using extract::tail_variate;
0134 using extract::tail_weights;
0135
0136 template<typename VariateType, typename VariateTag, typename LeftRight>
0137 struct feature_of<tag::tail_variate<VariateType, VariateTag, LeftRight> >
0138 : feature_of<tag::abstract_tail_variate>
0139 {
0140 };
0141
0142 template<typename LeftRight>
0143 struct feature_of<tag::tail_weights<LeftRight> >
0144 {
0145 typedef tag::abstract_tail_weights type;
0146 };
0147
0148 }}
0149
0150 #endif