|
Ublas : |
Subject: Re: [ublas] Layout type
From: Marco Guazzone (marco.guazzone_at_[hidden])
Date: 2010-05-03 08:56:29
On Mon, May 3, 2010 at 1:45 PM, Andrea Arteaga <andyspiros_at_[hidden]> wrote:
> How can I know whether a matrix is storing its elements with column-major
> storage or with row-major?
> I'm writing a template function which takes as argument a
> boost::numeric::ublas::matrix and performs some computation. I have to know
> whether I must transpose the data or not:
> template<class MatrixType>
> void my_func(const MatrixType& matrix)
> {
> const char * data =
> reinterpret_cast<const char *>(&matrix(0, 0));
>
> /* ... */
> }
> I tried with typename MatrixType::layout_type, but this typedef is private.
Hi,
You can use
MatrixType::orientation_category
which tells you if that matrix is stored in a row-major
(row_major_tag) or a column-major (column_major_tag) way.
Best,
-- Marco