The following code multiplies the i-th column of A by the i-th element of V.
#include <Eigen/Core>
Eigen::Array<double, 8, 2>
f(const Eigen::Array<double, 8, 2>& A, const Eigen::Array<double, 1, 2>& V) {
return A.rowwise() * V;
}
Apparently if one multiplies the other way, as in
Eigen::Array<double, 8, 2>
g(const Eigen::Array<double, 8, 2>& A, const Eigen::Array<double, 1, 2>& V) {
return V * A.rowwise();
}
g++ (15.1) and clang (20.1) will reject the code (with error: no match for 'operator*' (operand types are 'const Eigen::Array<double, 1, 2>' and 'Eigen::DenseBase<Eigen::Array<double, 8, 2> >::ConstRowwiseReturnType' {aka 'const Eigen::VectorwiseOp<const Eigen::Array<double, 8, 2>, 1>'}) and error: no type named 'type' in 'struct Eigen::internal::promote_scalar_arg<double, Eigen::VectorwiseOp<const Eigen::Array<double, 8, 2>, 1>, false>')
I'm wondering why this is and what is special about the return type of rowwise/colwise.
What are the rules regarding what can be multiplied by what when broadcasting (in Eigen 3.4 - if it matters)?
find Eigen/. -name "*.h" -exec grep -H operator\\\* {} \;will answer your last question ... with 159 resultsV * A.rowwise()did work, I'd expect the result to beEigen::Array<double, 1, 2>. Or a vector of those, one for each row.