I'm having trouble to do dynamic matrix and vector dot product and surprisingly, I didn't make it find any solution since Eigen
is a prevalent library.
So the code is really simple:
int k = 3;
MatrixXd m;
m.resize(k, k);
ArrayXd a;
a.resize(k);
std::cout << "Dot product: " << m*a << std::endl;
I got error
invalid operands to binary expression ('MatrixXd' (aka 'Matrix') and 'ArrayXd' (aka 'Array')) std::cout << "Dot product: " << m*a << std::endl;
I'm confused if doing dynamic matrix and vector multiplication is feasible. Meanwhile, I found that there is .dot()
method for vectors and matrices, so which one to use, *
or .dot()
for dot product?
a
toVectorXd
to make your code work. – chtz