Boost logo

Boost Users :

Subject: Re: [Boost-users] [Accumulators] How to define the initial value ?
From: Adrien Todeschini (adrien.todeschini_at_[hidden])
Date: 2010-10-11 11:05:08


> 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 ?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net