# Ublas :

Subject: [ublas] symmetric matrices, row and column-major
From: Tiago Requeijo (tiago.requeijo.dev_at_[hidden])
Date: 2009-02-24 14:37:35

I'm having a problem with row and column major in symmetric matrices. I'm
probably not understanding correctly how the storage takes place in memory.
I assumed upper+column_major storage was the same as lower+row_major. Here's
an example:

Upper part of the symmetric matrix:

0.34 0.9 1.17 0.689 1.42
---- 1.36 0.9 0.808 0.146
---- ---- 0.572 1.55 1.61
---- ---- ---- 0.093 1.32
---- ---- ---- ---- 0.828

ublas::symmetric_matrix<double, ublas::upper, ublas::column_major> S
double* a = &(S.data()[0]);
ublas::symmetric_matrix<double, ublas::lower, ublas::column_major> S2
double* a2 = &(S2.data()[0]);

Contents of a, a2:
0.34 0.9 1.17 0.689 1.42 1.36 0.9 0.808 0.146
0.572 1.55 1.61 0.093 1.32 0.828

ublas::symmetric_matrix<double, ublas::lower, ublas::row_major> S3;
double* a3 = &(S3.data()[0]);
ublas::symmetric_matrix<double, ublas::upper, ublas::row_major> S4;
double* a4 = &(S4.data()[0]);

Contents of a3, a4:
0.34 0.9 1.36 1.17 0.9 0.572 0.689 0.808 1.55
0.093 1.42 0.146 1.61 1.32 0.828

So, ublas::lower or upper doesn't make any difference to the storage
scheme? From above it seems row/column storage always corresponds to the
ros/cols from the lower part of the matrix.