|
Ublas : |
Subject: Re: [ublas] symmetric matrices, row and column-major
From: Gunter Winkler (guwi17_at_[hidden])
Date: 2009-02-24 15:11:55
Tiago Requeijo schrieb:
> 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:
The mapping from (i,j) to storage location is defined in
basic_row_major::lower_element and basic_row_major::upper_element (see
functional.hpp).
symmetric_matrix::operator(i,j) uses the triangular_type::element(...)
method to dispatch to the corresponding storage mapping from the layout
type (row major/column major). Maybe this mapping does not work as expected.
I recently introduced the transposed_structure template to reduce the
number of implementations for the diffentent triangular types. Can you
check if the problem is caused by a wrong implementation of
transposed_structure::element()?
> 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
>
This seems to be wrong ...
mfg
Gunter