This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Use SparseMatrix's selfAdjointView

Tags: None
(comma "," separated)
thiloschneider
Registered Member
Posts
2
Karma
0

Use SparseMatrix's selfAdjointView

Fri Oct 26, 2012 1:42 pm
According to the Eigen documentation, I would expect the following to work:

Code: Select all
#include "Eigen/Dense"
#include "Eigen/Sparse"
SparseMatrix<double> mymatrix = SomeFunctionReturningASparseMatrix();

SparseMatrix<double> test = mymatrix.selfadjointView<Lower>();

However, I get the compile-time-error

Code: Select all
conversion from 'Eigen::SparseSelfAdjointView<Eigen::SparseMatrix<double>, 2u>' to
non-scalar type 'Eigen::SparseMatrix<double>' requested

What am I doing wrong? Missing include?

Second question: As far as I was able to find, Eigen does not yet support multiplication of SparseSelfadjointViews with SparseMatrices. Am I missing something, or is this in fact not implemented?

Thank's for your help!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
For the first issue, the following should do the job:
Code: Select all
SparseMatrix<double> test;
test = mymatrix.selfadjointView<Lower>();

For te second, you are right, such product is not supported.
thiloschneider
Registered Member
Posts
2
Karma
0
You are right, this one does work as expected. Thanks!

However, I do not really understand the semantic difference. For my own learning, could you give me some insights on why the declaration and copy operation may not happen in one single line? Somehow, I seem to have some C++ misunderstanding on that topic.

Are there any known plans to support sparse-sparse-multiplication in the future?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
sparse-sparse products do work. regarding your initial issue, it's because when you do:

A a = b;

you do not call operator= but the constructor, and in addition the conversion constructor (assuming b is not of type A), must not be "explicit".
bouman
Registered Member
Posts
4
Karma
0
Dear Eigen,

I have a sparse complex symmetric matrix A.
Can I also store only the upper-triangular part of A and then get a "symmetric" view on it?

i.e. something like
A.selfadjointView<UpperAndSymmetric>();
or
A.selfsymmetricView<Upper>();

The function
A.selfadjointView<Upper>();
gives me a Hermitian matrix, which is not what I need (as my A is complex-symmetric, not Hermitian).

Kind regards,
Niek
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]