Symmetric data structure as an array for C ++

I am doing a simulation where I have to calculate a lot of averages, and I thought using boost :: batteries would be a good idea. The problem is that one of the values ​​that I want to average is a symmetric matrix, the diagonal of which is known in advance. I just have to calculate the average values ​​for Q [i] [j] if I <k.

At first I got the impression that I can use

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 batteries. But then it occurred to me that this symmetric_matrix structure could be sufficient to store only numerical values ​​(they have certain arithmetic operations) or be optimized for this kind of data in some way. Is it correct?

If boost_symmetric_matrix is ​​not suitable, I need a data structure that can hold the lower triangle of the symmetric matrix without a diagonal, and it should be suitable for storing batteries and have a nice matrix, such as syntax. Is it available from any library? If not, is there a simple implementation for this type of structure?

+5
source share
1 answer

Try Enhancing the uBLAS Triangular Matrix . Here is an example.

+1
source

All Articles