I have the following function, which is used in combination with ceres::Jet<> as scalar:
inline Eigen::Matrix<typename Eigen::MatrixBase<Derived1>::Scalar, 2, 1> reproject(
const Eigen::MatrixBase<Derived1>& pt,
const Eigen::MatrixBase<Derived2>& W
return (W * pt.homogeneous()).hnormalized();
If I don't call .eval() before .hnormalized() this results in the following compilation error:
/usr/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h:137:14: error: no viable conversion from 'const
Eigen::ReturnByValue<Eigen::internal::homogeneous_left_product_impl<Eigen::Homogeneous<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 0>, Eigen::Matrix<double, 3, 3, 0,
3, 3> > >::YOU_ARE_TRYING_TO_ACCESS_A_SINGLE_COEFFICIENT_IN_A_SPECIAL_EXPRESSION_WHERE_THAT_IS_NOT_ALLOWED_BECAUSE_THAT_WOULD_BE_INEFFICIENT' to 'const double'
/usr/include/eigen3/Eigen/src/Geometry/Homogeneous.h:163:40: note: in instantiation of member function
'Eigen::DenseCoeffsBase<Eigen::ReturnByValue<Eigen::internal::homogeneous_left_product_impl<Eigen::Homogeneous<Eigen::Matrix<double, 2, 1, 0, 2, 1>, 0>,
Eigen::Matrix<double, 3, 3, 0, 3, 3> > >, 0>::coeff' requested here
ColsAtCompileTime==1?1:size()-1) / coeff(size()-1);
I'm using Clang 3.6 and Eigen 3.2.4.
By the way, this happens when using double as scalar as well.
The cleanest/most efficient workaround would be to store W as a Transform (and omit the homogeneous() and hnormalized() calls).
But I agree that your code should compile.
I don't see how storing W in a Transform can be more efficient. Wouldn't that still require to call .homogeneous() and .hnormalized(), would it?
(In reply to Sergiu Dotenco from comment #3)
> I don't see how storing W in a Transform can be more efficient. Wouldn't
> that still require to call .homogeneous() and .hnormalized(), would it?
I admit that I did not check the code. I wrongfully assumed, Transform * vector automatically normalizes when assigning to a vector of size dim (and not dim+1).
Indeed, hnormalized should perform the call to eval for you.
In Eigen 3.3, evaluators should refactor this expression to:
(W.leftCols<2>() * pt + W.col(2)).hnormalized()
and, support for:
W * lazyProduct( pt.homogeneous() )
has also to be added.
Actually, this is already working fine in the devel branch.
The following changeset add support for lazyProduct:
Date: 2015-06-08 13:43:41+00:00
Summary: Bug 997: add missing evaluators for m.lazyProduct(v.homogeneous())
Backporting to 3.2 is impossible, so I vote for wontfix for 3.2 and fixed for the devel branch.
-- GitLab Migration Automatic Message --
This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/997.