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

Assign DiagonalMatrix to SparseMatrix

Tags: None
(comma "," separated)
User avatar
alecjacobson
Registered Member
Posts
26
Karma
0
Is there currently an easy way to assign a DiagonalMatrix to the more general SparseMatrix? I'd like to do something like:

Code: Select all
SparseMatrix<double> S;
DiagonalMatrix<double,Dynamic> D;
S = D;


But I get errors like:

Code: Select all
/opt/local/include/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h:44:23: error: no matching member function for call to
      'evalTo'
      other.derived().evalTo(derived());
      ~~~~~~~~~~~~~~~~^~~~~~
/opt/local/include/eigen3/Eigen/src/SparseCore/SparseMatrix.h:739:20: note: in instantiation of function template
      specialization 'Eigen::SparseMatrixBase<Eigen::SparseMatrix<double, 0, int>
      >::operator=<Eigen::DiagonalMatrix<double, -1, -1> >' requested here
    { return Base::operator=(other.derived()); }
                   ^
...:15:5: note: in instantiation of function template specialization
      'Eigen::SparseMatrix<double, 0, int>::operator=<Eigen::DiagonalMatrix<double, -1, -1> >' requested here


This would be helpful for passing DiagonalMatrix variables directly as arguments to functions expecting general SparseMatrices.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
This now works with the devel branch through operator= (as in your example) or an explicit ctor.


Bookmarks



Who is online

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