Created attachment 653 [details]
While investigating an error in our code relying on Eigen, I noticed the following behavior. Given a MatrixXd a, the result of this operation on a block b of a MatrixXd m is wrong:
b.noalias() = 2. * x.transpose() * a;
when noalias() is used and x is a VectorXd. As a result, the block b of the matrix contains the wrong data (misplaced in memory). However, if x is a MatrixXd with the proper size, things work normally. I attached a repro code that shows the issue. I tested in on Eigen 3.2.7 and 3.3-beta1.
Am I doing something wrong here?
I confirm. The problem is when extracting the inner-stride of the destination using:
which is not necessarily correct when the destination expression is not a vector expression at compile-time, as with m.block(1, 0, 1, 2). This works fine with m.row(1), which is the workaround you should follow.
On Eigen's side, a quick fix would be enforce the destination to be a vector by calling:
This should not produce any runtime overhead.
Duly noted, thanks for the quick answer!
Summary: Bug 1166: fix shortcomming in gemv when the destination is not a vector at compile-time.
btw, thanks for find that one.
Well thanks for the quick fix (and maintenance release), it's greatly appreciated!
-- 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/1166.