Testing/learning the Boost Accumulator library.
Now trying with uBlas vectors.
terminate called after throwing an instance of 'boost::numeric::ublas::bad_argument'
/*test_BoostAccumulator.cpp
This file is used for testing/learning about Boost.org Accumulator library
*/
#include<iostream>
#include "boost/accumulators/accumulators.hpp"
#include "boost/accumulators/statistics/stats.hpp"
#include "boost/accumulators/statistics/mean.hpp"
#include "boost/accumulators/statistics/variance.hpp"
#include "boost/numeric/ublas/vector.hpp"
#include "boost/numeric/ublas/io.hpp"
#include "libs/numeric/bindings/lapack/test/utils.h"
using std::cout;
using std::endl;
namespace accumulate = boost::accumulators;
namespace ublas = boost::numeric::ublas;
void WithUBlas();
int main(){
cout << "Testing/learning the Boost Accumulator library." << endl;
accumulate::accumulator_set<double,
accumulate::stats<accumulate::tag::mean,
accumulate::tag::variance(accumulate::lazy)> > acc;
// Add some data
for( int i = 0; i < 5; ++i ) acc(i+1);
// Display results
cout << "Mean = " << accumulate::mean(acc) << endl;
cout << "Variance = " << accumulate::variance(acc) << endl;
WithUBlas();
return 0;
}
void WithUBlas(){
cout << "\nNow trying with uBlas vectors." << endl;
ublas::vector<double> vec(5,1.0);
cout << "vec: " << vec << endl;
cout << "vec*2: " << vec*2 << endl;
accumulate::accumulator_set<ublas::vector<double>,
accumulate::stats<accumulate::tag::mean> > acc;
// Add some data
for( int i = 0; i < 5; ++i ) acc( vec*(i+1) );
// Display results
cout << "Displaying results\nMean = " << accumulate::mean(acc) << endl;
}