Registered Member
|
Hello,
I have a quite silly problem, which I can not solve. I have a 3xN Matrix (M) and a N RowVector (v) (I've chosen a RowVector to remove the transpose), where each column of the matrix should be multiplied with the corresponding coefficient of the vector. My expression reads:
However, when I put this expression as return type of a function I get a lot of invalid memory access from valgrind or std::bad_alloc. I have a small sample program:
Do you have any sugguestions? Thank you in advance! Matthias PS: using Eigen 3.2 |
Moderator
|
This is probably because of the Vectorwise proxy object which is deleted too early. By passing the call to rowwise() should fix the issue. Anyway, a better and simpler expression is:
M * v.asDiagonal() which returns a DiagonalProduct<Matrix<>,DiagonalWrapper<>,OnTheRight> expression in 3.2. In 3.3 it will return a generic Product<Matrix<>,DiagonalWrapper<>,LazyProduct>. |
Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar