Registered Member
|
Not sure if this is a bug, but it's at least surprising that it doesn't compile (with gcc or clang):
This does compile:
|
Moderator
|
Indeed, what happens here is that Y.row(0)*X returns a 1x1 matrix expression having a conversion operator to a double. This is why "1+(Y.row(0)*X)" does compile. The following expression does compile too:
by casting the right hand side to a double. The type of this sub-expression is something like "division_by_scalar<inner_product<row<matrix>,vector> >". However, this conversion operator is only available for inner-products. Therefore the complete sub-expression cannot be casted to a double to add "1". I agree this is rather weird, but there is not much we can do on our side because allowing implicit conversion to a scalar for any 1x1 expression yields much weirder side effects (we already tried). Making inner-products returning a scalar instead of 1x1 expression is also worse. Workarounds are numerous, like using Y.row(0).dot(X), or (Y.row(0)*X).value(), or (Y.row(0)*X)(0)... |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]