This bugzilla service is closed. All entries have been migrated to
Bug 1669 - Zero-sized matrices generate assertion failures
Summary: Zero-sized matrices generate assertion failures
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.3 (current stable)
Hardware: All All
: Normal Crash
Assignee: Nobody
Depends on:
Blocks: 3.3 3.4
  Show dependency treegraph
Reported: 2019-01-25 16:37 UTC by Kerry Loux
Modified: 2019-12-04 18:25 UTC (History)
3 users (show)


Description Kerry Loux 2019-01-25 16:37:12 UTC
In previous versions (including v3.2) inverses of zero-sized matrices were supported.  The following code, for example, would compile and execute without issue in v3.2:

Eigen::MatrixXd a;// NOTE:  using Eigen::Matrix<double, 0, 0> fails with compile-time error on the last line below
Eigen::Matrix<double, 0, 1> b;
std::cout << a.inverse() * b << std::endl;

In v3.3, this code generates the following runtime error:
Assertion failed: this->rows()>0 && this->cols()>0 && "you are using an empty matrix", file c:\lib\eigen\eigen\src\core\redux.h, line 413

It appears that the file eigen/Eigen/src/Core/Redux.h has many assertions with this "you are using an empty matrix" explanation which are not there in v3.2.

Because this was supported in v3.2 and there are good reasons to continue to support such code, I believe this behavior is a bug.
Comment 1 Gael Guennebaud 2019-01-28 17:20:57 UTC
I don't think this comes from redux, but rather from this line of code in PartialPivLU to compute L1 norm:

m_l1_norm = m_lu.cwiseAbs().colwise().sum().maxCoeff();

max/min reductions are disallowed on empty matrices. So the fix is simply to check for empty-ness here. Need to add a unit test though.
Comment 2 Gael Guennebaud 2019-01-29 09:46:47 UTC
Comment 3 Nobody 2019-12-04 18:25:06 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.