This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 1005 - Error with sparse vector and transpose of matrix
Summary: Error with sparse vector and transpose of matrix
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Wrong Result
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 3.3
  Show dependency treegraph
 
Reported: 2015-04-27 04:15 UTC by Benjamin Chretien
Modified: 2019-12-04 14:34 UTC (History)
2 users (show)



Attachments
Repro code (1.03 KB, text/x-c++src)
2015-04-27 04:15 UTC, Benjamin Chretien
no flags Details

Description Benjamin Chretien 2015-04-27 04:15:26 UTC
Created attachment 566 [details]
Repro code

While trying to see whether #980 (http://eigen.tuxfamily.org/bz/show_bug.cgi?id=980) was solved on the default branch with one of our tests, I noticed an error in the actual result. If we do:

  v += m1.transpose ();

where v is a SparseVector<double> and m a SparseMatrix<double> with the adequate size, some inner loop in Eigen's code appears to be done with the wrong size (1 instead of the vector size), resulting in a wrong result.

Repro code: https://gist.github.com/bchretien/29827af68edae49cd6d7 (attached)

Output:

(1,2)
(1,2)
(1,2)
(2,2)
(3,4)

Expected output:

(1,2)
(1,2)
(1,2)
(2,4)
(3,6)
Comment 1 Christoph Hertzberg 2015-04-27 15:08:43 UTC
Here is a workaround until this gets fixed:
  v += sparseVector_t(m1.transpose ());
Comment 2 Gael Guennebaud 2015-06-08 07:34:31 UTC
Since the storage order of v and m1.transpose do not match, this should not even compile (this is the case with eigen 3.2). I also see that "sparse colmajor" + "sparse rowmajor" does compile in the devel branch, meaning that a static assert has been improperly deactivated. Let me investigate...
Comment 3 Gael Guennebaud 2015-06-08 08:28:39 UTC
Fixed. Let me also emphasize that the "workaround" proposed by Christoph is actually not a workaround, but a requirement.

https://bitbucket.org/eigen/eigen/commits/e99ca53c931b/
Changeset:   e99ca53c931b
User:        ggael
Date:        2015-06-08 08:14:08+00:00
Summary:     Bug 1005: fix regression regarding sparse coeff-wise binary operator that did not trigger a static assertion for mismatched storage
Comment 4 Nobody 2019-12-04 14:34:16 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/1005.

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