Boost logo

Ublas :

Subject: Re: [ublas] pointer to matrix structure
From: Kraus Philipp (philipp.kraus_at_[hidden])
Date: 2011-08-08 05:41:31


Am 08.08.2011 um 11:20 schrieb Marcel Rehberg:

> Right, this would copy the data. What I meant was to use ublas::<T,ublas::column_major> for your original matrix, right from the beginning.
>
> It does not make a difference from the ublas interface point of view. So it wouldn't require any code changes except in the definition of the matrices*. To make things easier you could use a typedef like

I think there is a difference: I read the matrix data often in the row-order, a loop over the rows and a inner loop over the columns, so if I use a column-major the loops must / should be changed. If I use a column-major matrix and iterate first over the rows and with the inner loop over the columns, it can be create a poor performance, so I would like to have a row-major matrix.

> *(Except you also use library methods that expect row major, but then I guess you'll end up copying anyway)

That's exactly my problem, some library calls like LAPack use a column-major order, so I must change my row-major to the column-major. At this time I use the copy-constructor call but it create a matrix clone and duplicates the data, on some million entries it create a very memory load. Is there a solution to swap the order of the elements for only one read option? I need only one access to the elements with another ordering?

Thanks

Phil