Boost logo

Ublas :

Subject: [ublas] Accumulators with vectors
From: Rafael Calsaverini (rafael.calsaverini_at_[hidden])
Date: 2010-12-01 06:27:03


I was trying to use vectors with accumulators and someone suggested to use
ublas vectors that have mathematical operators already defined. But when I
tried I got what seems to be a size mismatch error. This is the code I was
trying to use:

#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics.hpp>
#include <boost/accumulators/statistics/stats.hpp>

using namespace boost::accumulators;
using namespace boost::numeric;

int main() {

  ublas::vector<double> x(3), y(3), z(3);

  x[0] = 1; x[1] = 1; x[2] = 1;
  x[0] = 1; x[1] = 1; x[2] = 2;
  x[0] = 2; x[1] = 1; x[2] = 1;

  accumulator_set < ublas::vector<double> , stats<tag::mean> > acc;

  acc(x);
  acc(y);
  acc(z);
  std::cout << mean(acc) << std::endl;

  return 0;
}

The error message is:

Check failed in file
/usr/include/boost/numeric/ublas/detail/vector_assign.hpp at line 262:
size1 == size2
terminate called after throwing an instance of
'boost::numeric::ublas::bad_argument'
  what(): bad argument
Aborted

Did any of you succeded/know how to use vectors as variables to accumulate
with boost accumulators?

---
Rafael Calsaverini
Dep. de Física Geral, Sala 336
Instituto de Física - Universidade de São Paulo
rafael.calsaverini_at_[hidden]
http://stoa.usp.br/calsaverini/weblog
CEL: (11) 7525-6222
USP: (11) 3091-6803