Column-wise dot product in Eigen C++
c++, eigen, linear-algebra
Solution
There are many ways to achieve this, all performing lazy evaluation:
res = (A.array() * B.array()).colwise().sum();
res = (A.cwiseProduct(B)).colwise().sum();
And my favorite:
res = (A.transpose() * B).diagonal();
Problem
Is there an easy way to evaluate the column wise dot product of 2 matrices (lets call them `A` and `B`, of type `Eigen::MatrixXd`) that have dimensions `mxn`, without evaluating `A*B` or without having to resort to `for` loops? The resulting vector would need to have dimensions of `1xn` or `nx1`. Also, I'm trying to do this with Eigen in C++