Re: [eigen] Defining a SparseMatrix with RowMajor

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi,

SparseMatrix<scalar, RowMajor> is the type to use to get a row major
compressed sparse matrix. You can use SparseMatrixType::IsRowMajor to
know if the sparse matrix type you get is row or column major.

Please note that the storage order is defined at compile time. So if
you declare a function taking a SparseMatrix<scalar> as argument and
pass a  SparseMatrix<scalar, RowMajor>, then the row major input will
be converted to a column major matrix...

hope that complete Michael's answer.

cheers,
gael

On Wed, Sep 26, 2012 at 6:39 PM, Philipp Berger
<newsletters@xxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> I've been playing around with Eigens SparseMatrix and am now trying to
> implement an export function to my own SparseMatrix class. As my own
> class uses CSR/CRS plus some additional details, I planned on copying
> the data from the Eigen SM after calling makeCompressed() through
> valuePtr(), innerIndexPtr() and outerIndexPtr().
>
> But after some tests and many printf's, it seems I am unable to define
> the Eigen SM as RowMajor.
> I used:
> Eigen::SparseMatrix<int, 1> esm(10, 10);
>
> But the resulting matrix is always ColMajor. What is the correct way to
> define a RowMajor Eigen SparseMatrix? I could not find any hints on that.
>
> Additionally, I would like to know how I can detect whether a given
> SparseMatrix is RowMajor or ColMajor - there seems to be no function
> like "isRowMajor()", etc. - but that is required for me to export the
> data through valuePtr(), innerIndexPtr() and outerIndexPtr() - or is
> this a misunderstanding on my side?
>
> Thank you very much, I appreciate your help,
>
> Philipp
>



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/