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

create sparse band and diagonal matrices in c++ (like spdiag

Tags: None
(comma "," separated)
bhosseinzadeh
Registered Member
Posts
1
Karma
0
I have a question, in MATLAB there is a spdiags function, creates sparse matrix by taking diagonal matrices, for example A = spdiags(B,d,m,n) creates an m-by-n sparse matrix by taking the columns of B and placing them along the diagonals specified by d. Is there any C++ codes has this function, or is any C++ library or class to do the same thing as this function do? or is it possible with Eigen and how?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
This is already possible from a diagonal matrix to a sparse matrix simply using operator=. For band matrices, it could be easily implemented through a conversion operator from Eigen::BandMatrix to Eigen::SparseMatrix.


Bookmarks



Who is online

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