Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symmetric array-like data structure for c++

I'm doing a simulation where I must calculate many averages and I thought that using boost::accumulators would be a good idea. The problem is that one of the quantities I want to average is a symmetric matrix, whose diagonal is known beforehand. SO I just need to calculate the averages for Q[i][j] if i < j.

At first I got the impression that I could use a

using namespace boost::accumulators;
using namespace boost::numeric::ublas;
typedef accumulator_set<double, stats<tag::mean> > accumulator;

symmetric_matrix<accumulator, lower> foo;  // a symmetric matrix of accumulators

to hold my accumulators. But then it occurred to me that this symmetric_matrix structure might be adequate to hold numerical values only (they have arithmetic operations defined) or are optimized for this kind of data in some way. Is this right?

If symmetric_matrix from boost are not adequate, I need a data structure that can hold the lower triangle of a symmetric matrix without the diagonal, and it must be suitable to hold the accumulators and have a nice matrix like syntax. Is this readily available from some library? If not, is there an easy implementation for this kind of structure around?

like image 946
Rafael S. Calsaverini Avatar asked Nov 14 '22 22:11

Rafael S. Calsaverini


1 Answers

Try the Boost uBLAS Triangular matrix. Here is an example.

like image 193
yasouser Avatar answered Dec 22 '22 09:12

yasouser