Re: [eigen] Defining a SparseMatrix with RowMajor |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Defining a SparseMatrix with RowMajor
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
- Date: Wed, 26 Sep 2012 22:26:10 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=3oBvS2BtPPGUfaolaGCHwCZ09kS66D+RBoESSiR4h1w=; b=N7k6GCbgNDh92uVtMlJaEA8Tmb2DIL3YRJ37aAlUco9awlBWw1Lk3czxOkZ+ObuRTd KfJfUYTicpGfBfw56lK2z0tuVfj9dl0glQvOH28arcOzkkCwAJGF0NJ2YhKzCt7mcc28 HEJ38OAWtLJf8pd/ULqLdZJggF8KY/a6zxs6Dv2w/EgJFMJ5Kv6CLa6swdg87aybr4fj FNugUOWPNRM9qMejgx/CMCOm/bMPJNfV6POnt4vpDG3Qoqy53Em4U90EoR7rGcKcEC0J wTOqcqTrh6a5E8nQmUq4349UmDpw1iKpHicKsibcHUvatsyxhnSFaqOseKh3uQZ0B/Gm NWrg==
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
>