Reply to topic

Use SparseMatrix's selfAdjointView

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
2195
Karma
15
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
2195
Karma
15
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".

 
Reply to topic

Bookmarks



Who is online

Registered users: Atalanttore, Baidu [Spider], Bing [Bot], einar, Exabot [Bot], flya, Google [Bot], google01103, kdeuserk, koriun, Majestic-12 [Bot], pedrorodriguez, sashcroft, scottpetrovic, scummos, SecretCode, Sogatori, vascobasque, Yahoo [Bot]