Registered Member
|
Hello.
I have developed the following method as an Eigen plugin to perform a multiple dot product between corresponding column vectors in two matrices:
This works well according to my tests BUT id like this method to return an expression type instead of a calculated vector, so that I can take advantage of lazy evaluation. I've tried a number of approaches but I must confess I'm getting lost in the template forest. Any help will be appreciated. JLE |
Moderator
|
I don't get it, what your function is doing is just computing the diagonal of a matrix-matrix product:
(A.transpose() * B).diagonal() This is already optimized to compute only the diagonal coefficient in a lazy way. |
Registered Member
|
Ok, I should clarify this.
I understand that returning a Matrix<RealScalar, 1, Dynamic> forces the expression to be evaluated as a vector. As long as I'm using this method within other expressions, I'd prefer to return an expression type instead of a regular vector. I'd like to know if this is possible. Thanks, JLE |
Moderator
|
What I'm saying is that there is no need for writing a custom member for that. If you still want it, then you must remove the branches and always returns the same expression, for instance: (derived().transpose() * other.derived()).diagonal() which type should be :
Diagonal<const CoeffBasedProduct<const Transpose<const Derived>, const OtherDerived, 0>, 0> |
Registered Member
|
The following works for a multiple dot product between two (mxn) matrices:
However, that method doesn't address the cases when one of the operands is a column vector. I understand I should write specific methods for those cases. The reason why I want a method like the first colwiseDot I wrote is to maintain some readability of code like this:
Thank you for illuminating my way from Matlab to Eigen. JLE |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]