This bugzilla service is closed. All entries have been migrated to
Bug 817 - ArrayXXf::matrix().applyOnTheLeft(...) trips assertions
Summary: ArrayXXf::matrix().applyOnTheLeft(...) trips assertions
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - matrix products (show other bugs)
Version: 3.2
Hardware: All All
: Normal Unknown
Assignee: Nobody
Depends on:
Blocks: 3.3
  Show dependency treegraph
Reported: 2014-06-02 19:26 UTC by Rhys Ulerich
Modified: 2019-12-04 13:20 UTC (History)
1 user (show)


Description Rhys Ulerich 2014-06-02 19:26:30 UTC
The following works in Eigen 3.2.1:

VectorXf x = VectorXf::Random(48);
MatrixXf A = MatrixXf::Random(48, 6);

This continuation, which looks equivalent, trips assertions in

ArrayXXf B = ArrayXXf::Random(48, 6);

Originally reported in in which Christoph gave some insight:

This does work:
  B = (x.transpose()*B.matrix()).eval();

I seems the problem is that assigning a product to an array does not set the NeedEvalBeforeAssignment flag (which generally is not required for Array operations). This leads to B getting resized before the product is evaluated which evidently is a problem.
I'd say this is a bug in Eigen, not a usage error on your side!

The problem with B.matrix().applyOnTheLeft(...) and similar is that .matrix() expressions are writable but not resizable -- I'm not sure if this is by design. But it is similar to Maps which are not resizable either:

  // only works if no resizing is needed:
  Map<MatrixXf>(data, 48, 6).applyOnTheLeft(...);

We could make a more clear run-time assertion message for these cases.
E.g. "Operation requires resizing a non-resizable expression"

The continuation of that thread, including Christoph's comments, might require going to as the month changed in the interim.
Comment 1 Gael Guennebaud 2014-06-04 11:52:05 UTC
I'm not sure we want to enable resizing of A.matrix(). 

However the following have to work:

B = (x.transpose()*B.matrix());

and it probably already does in the evaluator branch.
Comment 2 Gael Guennebaud 2015-09-02 11:18:46 UTC
I added a regression test for the previous example:

and I'd say wontfix for 3.2
Comment 3 Nobody 2019-12-04 13:20:53 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.