I have a successfully defined sparse matrix. I can output it normally with: cout<<mysparsematrix<<endl; but when I do the assignment: mysparsemat.row(i)= mysparsemat.row(i)*5 cout<<mysparsematrix<<endl; breaks.... What's going wrong somewhere is in the status of "non-zero entries"... For the output below, i=1 Pre-reassignment I get output of: Nonzero entries: (7,1) (_,_) (_,_) (7,0) (4,2) (6,3) (0,4) (_,_) (4,1) (2,3) (_,_) (_,_) (6,1) (2,2) (5,4) (_,_) (_,_) (0,1) (5,3) (_,_) Post re-assignment I get output of: Nonzero entries: (7,1) (_,_) (_,_) (35,0) (20,2) (30,3) (0,4) (_,_) (0,1074790400) (0,1074790400) (_,_) (_,_) (6,1) (2,2) (5,4) (_,_) (_,_) (0,1) (5,3) (_,_) Notice that it multiplied the row correctly (i.e. (35,0) etc)... But broke the non-zero entries after that.
Works for me: #include <Eigen/Sparse> #include <iostream> int main(){ Eigen::SparseMatrix<double, Eigen::RowMajor> m(5,5); m.insert(0,2) = 1; m.insert(1,4) = 8; m.insert(2,0) = 4; m.insert(2,2) = 3; m.insert(3,0) = 3; m.insert(4,2) = 2; std::cout << m << "\n\n"; m.row(2) = m.row(2) * 5; std::cout << m << "\n\n"; return 0; }
This is covered here: https://bitbucket.org/eigen/eigen/commits/035491313a06/ Changeset: 035491313a06 User: ggael Date: 2013-06-14 10:52:19 Summary: Extend sparse-block unit test to explicitly cover bug 584 I'm closing this bug as works_for_me. If that don't, then please re-open, and upload a reproducible test case.
-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/584.