This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 584 - SparseMatrix.row(i)= SparseMatrix.row(i)*constant breaks non-zero entries
Summary: SparseMatrix.row(i)= SparseMatrix.row(i)*constant breaks non-zero entries
Status: RESOLVED WORKSFORME
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: unspecified
Hardware: All All
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3.2
  Show dependency treegraph
 
Reported: 2013-04-11 22:23 UTC by Karl
Modified: 2019-12-04 12:15 UTC (History)
1 user (show)



Attachments

Description Karl 2013-04-11 22:23:26 UTC
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.
Comment 1 Gael Guennebaud 2013-06-10 16:56:16 UTC
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;
}
Comment 2 Gael Guennebaud 2013-06-14 11:36:20 UTC
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.
Comment 3 Nobody 2019-12-04 12:15:06 UTC
-- 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.

Note You need to log in before you can comment on or make changes to this bug.