This bugzilla service is closed. All entries have been migrated to
Bug 1384 - SparseMatrix division by scalar seems to be using dense math
Summary: SparseMatrix division by scalar seems to be using dense math
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Performance Problem
Assignee: Nobody
Depends on:
Reported: 2017-01-25 16:37 UTC by Alec Jacobson
Modified: 2019-12-04 16:45 UTC (History)
2 users (show)


Description Alec Jacobson 2017-01-25 16:37:20 UTC
In Eigen 3.2.9 the follow code is fast/instantaneous:

  Eigen::SparseMatrix<double> I = Eigen::SparseMatrix<double>(100000,100000);
  Eigen::SparseMatrix<double> B = I / 100.0;

this suggests that Eigen was only doing the division on the non-zeros (and there aren't any so it's fast).

However, in Eigen 3.3.1 and 3.3.90 the code takes _a very long time_ and uses >1GB in memory. This suggests that its using dense rather than sparse math.

In my library we're doing operations like this to sparse matrices all of the time. Is this sparse matrix divided by scalar no longer supported?
Comment 1 Gael Guennebaud 2017-01-30 12:39:53 UTC
Thank you for the report. (devel) (3.3)
Summary:     Bug 1384: fix evaluation of "sparse/scalar" that used the wrong evaluation path.
Comment 2 Nobody 2019-12-04 16:45:46 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to'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:

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