[Accumulators] How to define the initial value ?

Hi everyone, As the code of weighted_sum_impl constructor is [ in header <boost/accumulators/statistics/weighted_sum.hpp> ] template<typename Args> weighted_sum_impl(Args const &args) : weighted_sum_( args[parameter::keyword<Tag>::get() | Sample()] * numeric::one<Weight>::value ) { } and the template parameter Tag is defined as tag::sample namespace tag { struct weighted_sum : depends_on<> { typedef accumulators::impl::weighted_sum_impl<mpl::_1, mpl::_2, tag::sample> impl; }; } How can I define this tagged argument when initializing the accumulator_set ? ( Indeed, weighted_sum_impl constructor is called at this point ) Thanks in advance for your help. Adrien

On 10/8/2010 8:58 AM, Adrien Todeschini wrote:
How can I define this tagged argument when initializing the accumulator_set ? ( Indeed, weighted_sum_impl constructor is called at this point )
Thanks in advance for your help.
It should be as simple as using the "sample" keyword in the boost::accumulators namespace, like: using namespace boost::accumulators; accumulator_set< int, features<tag::weighted_sum> > acc( sample = 42 ) HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com

It should be as simple as using the "sample" keyword in the boost::accumulators namespace, like:
using namespace boost::accumulators; accumulator_set< int, features<tag::weighted_sum> > acc( sample = 42 )
Thanks Eric. Indeed, it works ! But my problem was actually independent of this. I am using more features, and it seems that we can't use more than 4 tagged arguments !!! using namespace std; using namespace boost::accumulators; typedef accumulator_set<int, features<tag::weighted_mean, tag::weighted_density, tag::weighted_p_square_cumulative_distribution, tag::weighted_extended_p_square>, double> AccType1; typedef accumulator_set<int, features<tag::weighted_mean, tag::weighted_density, tag::weighted_p_square_cumulative_distribution>, double> AccType2; typedef accumulator_set<int, features<tag::weighted_mean, tag::weighted_density, tag::weighted_extended_p_square>, double> AccType3; double probs[] = {0.01,0.05, 0.25, 0.33, 0.5, 0.67, 0.75, 0.95, 0.99}; vector<double> q_probs(probs, probs + sizeof(probs) / sizeof(double)); AccType1 acc1(tag::weighted_density::cache_size = 10, tag::weighted_density::num_bins = 10, tag::weighted_extended_p_square::probabilities = q_probs, tag::weighted_p_square_cumulative_distribution::num_cells = 10); // compiles (4 tagged arguments) // AccType1 acc2(sample = 42, tag::weighted_density::cache_size = 10, // tag::weighted_density::num_bins = 10, // tag::weighted_extended_p_square::probabilities = q_probs, // tag::weighted_p_square_cumulative_distribution::num_cells = 10); // Error : does not compile (5 tagged arguments) AccType2 acc3(sample = 42, tag::weighted_density::cache_size = 10, tag::weighted_density::num_bins = 10, tag::weighted_p_square_cumulative_distribution::num_cells = 10); // compiles (4 tagged arguments) AccType3 acc4(sample = 42, tag::weighted_density::cache_size = 10, tag::weighted_density::num_bins = 10, tag::weighted_extended_p_square::probabilities = q_probs); // compiles (4 tagged arguments) I wanted acc2, so I thought my syntax using the "sample" keyword was wrong but it was not, as acc3 and acc4 do compile. Is that a bug ?

On 10/11/2010 8:05 AM, Adrien Todeschini wrote:
It should be as simple as using the "sample" keyword in the boost::accumulators namespace, like:
using namespace boost::accumulators; accumulator_set< int, features<tag::weighted_sum> > acc( sample = 42 )
Thanks Eric. Indeed, it works ! But my problem was actually independent of this. I am using more features, and it seems that we can't use more than 4 tagged arguments !!! <snip>
I wanted acc2, so I thought my syntax using the "sample" keyword was wrong but it was not, as acc3 and acc4 do compile. Is that a bug ? <snip>
Sounds like it. Could you try defining BOOST_PARAMETER_MAX_ARITY to be something higher, like 10? -- Eric Niebler BoostPro Computing http://www.boostpro.com

On 10/11/2010 8:05 AM, Adrien Todeschini wrote:
I am using more features, and it seems that we can't use more than 4 tagged arguments !!! <snip> Is that a bug ?
On 10/11/2010 9:39 AM, Eric Niebler wrote:
Sounds like it. Could you try defining BOOST_PARAMETER_MAX_ARITY to be something higher, like 10?
Done, but it does not solve the problem. The error message from GCC 4.4.3 compiler is : In file included from /usr/include/boost/accumulators/accumulators.hpp:12, from <my_path>/sandbox.hpp:13, from ../BiipsTest.cpp:11: /usr/include/boost/accumulators/framework/accumulator_set.hpp: In constructor ‘boost::accumulators::accumulator_set<Sample, Features, Weight>::accumulator_set(const A0&, const A1&, const A2&, const A3&, const A4&) [with A0 = boost::parameter::aux::tagged_argument<boost::accumulators::tag::sample, const int>, A1 = boost::parameter::aux::tagged_argument<boost::accumulators::tag::density_cache_size_<0>, const int>, A2 = boost::parameter::aux::tagged_argument<boost::accumulators::tag::density_num_bins_<0>, const int>, A3 = boost::parameter::aux::tagged_argument<boost::accumulators::tag::extended_p_square_probabilities_<0>, std::vector<double, std::allocator<double> > >, A4 = boost::parameter::aux::tagged_argument<boost::accumulators::tag::p_square_cumulative_distribution_num_cells_<0>, const int>, Sample = int, Features = boost::accumulators::features<boost::accumulators::tag::weighted_mean, boost::accumulators::tag::weighted_density, boost::accumulators::tag::weighted_p_square_cumulative_distribution, boost::accumulators::tag::weighted_extended_p_square, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, Weight = double]’: <my_path>/sandbox.hpp:90: instantiated from here /usr/include/boost/accumulators/framework/accumulator_set.hpp:200: error: no match for call to ‘(boost::accumulators::detail::accumulator_params) (boost::accumulators::accumulator_set<int, boost::accumulators::features<boost::accumulators::tag::weighted_mean, boost::accumulators::tag::weighted_density, boost::accumulators::tag::weighted_p_square_cumulative_distribution, boost::accumulators::tag::weighted_extended_p_square, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, double>&, const boost::parameter::aux::tagged_argument<boost::accumulators::tag::sample, const int>&, const boost::parameter::aux::tagged_argument<boost::accumulators::tag::density_cache_size_<0>, const int>&, const boost::parameter::aux::tagged_argument<boost::accumulators::tag::density_num_bins_<0>, const int>&, const boost::parameter::aux::tagged_argument<boost::accumulators::tag::extended_p_square_probabilities_<0>, std::vector<double, std::allocator<double> > >&, const boost::parameter::aux::tagged_argument<boost::accumulators::tag::p_square_cumulative_distribution_num_cells_<0>, const int>&)’ /usr/include/boost/parameter/parameters.hpp:841: note: candidates are: boost::parameter::aux::empty_arg_list boost::parameter::parameters<PS0, PS1, PS2, PS3, PS4>::operator()() const [with PS0 = boost::parameter::required<boost::accumulators::tag::accumulator, boost::parameter::aux::use_default>, PS1 = boost::parameter::optional<boost::accumulators::tag::sample, boost::parameter::aux::use_default>, PS2 = boost::parameter::void_, PS3 = boost::parameter::void_, PS4 = boost::parameter::void_] Adrien

On 10/12/2010 1:15 AM, Adrien Todeschini wrote:
On 10/11/2010 8:05 AM, Adrien Todeschini wrote:
I am using more features, and it seems that we can't use more than 4 tagged arguments !!! <snip> Is that a bug ?
On 10/11/2010 9:39 AM, Eric Niebler wrote:
Sounds like it. Could you try defining BOOST_PARAMETER_MAX_ARITY to be something higher, like 10?
Done, but it does not solve the problem.
The error message from GCC 4.4.3 compiler is : <snip>
Bummer. Can you file a bug at http://svn.boost.org? I don't want this issue to get lost. Thanks, -- Eric Niebler BoostPro Computing http://www.boostpro.com

On 10/12/2010 0:37 PM, Eric Niebler wrote:
Bummer. Can you file a bug at http://svn.boost.org? I don't want this issue to get lost.
Done : svn.boost.org/trac/boost/ticket/4730 By the way, I did not mention that I am using Boost 1.40. Can someone try on the latest release ?
participants (2)
-
Adrien Todeschini
-
Eric Niebler