Re: [eigen] Re: ArrayXXf::matrix().applyOnTheLeft(...)

[ Thread Index | Date Index | More Archives ]

On 30.05.2014 21:25, Rhys Ulerich wrote:
Having perused the API a bit and been bitten by similar issues in
these variants...

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

...short of assigning the product into a new variable, is there a way
to write the problematic expression that doesn't trip such an

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"

Is there a reason why you need B to be an Array instead of a Matrix?
And do you really save anything by reusing B for the result variable? The operation can't be performed in-place anyways.


Dipl.-Inf., Dipl.-Math. Christoph Hertzberg
Cartesium 0.049
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: +49 (421) 218-64252

Mail converted by MHonArc 2.6.19+